Merge remote-tracking branch 'origin/feature/refactor' into feature/refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"version": "1.0.1",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "concurrently \"vite\" \"yarn watch:main\" \"yarn electron-dev\"",
|
||||
|
||||
@@ -98,6 +98,8 @@ export type { TimeSetGetOut } from './models/TimeSetGetOut';
|
||||
export type { TimeSetIndexItem } from './models/TimeSetIndexItem';
|
||||
export type { TimeSetReorderIn } from './models/TimeSetReorderIn';
|
||||
export type { TimeSetUpdateIn } from './models/TimeSetUpdateIn';
|
||||
export type { UpdateCheckIn } from './models/UpdateCheckIn';
|
||||
export type { UpdateCheckOut } from './models/UpdateCheckOut';
|
||||
export type { UserConfig_Notify } from './models/UserConfig_Notify';
|
||||
export type { UserCreateOut } from './models/UserCreateOut';
|
||||
export type { UserDeleteIn } from './models/UserDeleteIn';
|
||||
@@ -109,5 +111,6 @@ export type { UserReorderIn } from './models/UserReorderIn';
|
||||
export type { UserSetIn } from './models/UserSetIn';
|
||||
export type { UserUpdateIn } from './models/UserUpdateIn';
|
||||
export type { ValidationError } from './models/ValidationError';
|
||||
export type { VersionOut } from './models/VersionOut';
|
||||
|
||||
export { Service } from './services/Service';
|
||||
|
||||
@@ -3,26 +3,25 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type HistoryIndexItem = {
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
date: string;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
status: HistoryIndexItem.status;
|
||||
/**
|
||||
* 对应JSON文件
|
||||
*/
|
||||
jsonFile: string;
|
||||
};
|
||||
export namespace HistoryIndexItem {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
export enum status {
|
||||
DONE = '完成',
|
||||
ERROR = '异常',
|
||||
}
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
date: string
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
status: HistoryIndexItem.status
|
||||
/**
|
||||
* 对应JSON文件
|
||||
*/
|
||||
jsonFile: string
|
||||
}
|
||||
export namespace HistoryIndexItem {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
export enum status {
|
||||
DONE = '完成',
|
||||
ERROR = '异常',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
frontend/src/api/models/UpdateCheckIn.ts
Normal file
11
frontend/src/api/models/UpdateCheckIn.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type UpdateCheckIn = {
|
||||
/**
|
||||
* 当前前端版本号
|
||||
*/
|
||||
current_version: string;
|
||||
};
|
||||
|
||||
31
frontend/src/api/models/UpdateCheckOut.ts
Normal file
31
frontend/src/api/models/UpdateCheckOut.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type UpdateCheckOut = {
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
code?: number;
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
status?: string;
|
||||
/**
|
||||
* 操作消息
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* 是否需要更新前端
|
||||
*/
|
||||
if_need_update: boolean;
|
||||
/**
|
||||
* 最新前端版本号
|
||||
*/
|
||||
latest_version: string;
|
||||
/**
|
||||
* 版本更新信息字典
|
||||
*/
|
||||
update_info: Record<string, Array<string>>;
|
||||
};
|
||||
|
||||
35
frontend/src/api/models/VersionOut.ts
Normal file
35
frontend/src/api/models/VersionOut.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type VersionOut = {
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
code?: number;
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
status?: string;
|
||||
/**
|
||||
* 操作消息
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* 后端代码是否为最新
|
||||
*/
|
||||
if_latest: boolean;
|
||||
/**
|
||||
* 后端代码当前哈希值
|
||||
*/
|
||||
current_hash: string;
|
||||
/**
|
||||
* 后端代码当前时间戳
|
||||
*/
|
||||
current_time: string;
|
||||
/**
|
||||
* 后端当前版本号
|
||||
*/
|
||||
current_version: string;
|
||||
};
|
||||
|
||||
@@ -53,6 +53,8 @@ import type { TimeSetGetIn } from '../models/TimeSetGetIn';
|
||||
import type { TimeSetGetOut } from '../models/TimeSetGetOut';
|
||||
import type { TimeSetReorderIn } from '../models/TimeSetReorderIn';
|
||||
import type { TimeSetUpdateIn } from '../models/TimeSetUpdateIn';
|
||||
import type { UpdateCheckIn } from '../models/UpdateCheckIn';
|
||||
import type { UpdateCheckOut } from '../models/UpdateCheckOut';
|
||||
import type { UserCreateOut } from '../models/UserCreateOut';
|
||||
import type { UserDeleteIn } from '../models/UserDeleteIn';
|
||||
import type { UserGetIn } from '../models/UserGetIn';
|
||||
@@ -61,10 +63,22 @@ import type { UserInBase } from '../models/UserInBase';
|
||||
import type { UserReorderIn } from '../models/UserReorderIn';
|
||||
import type { UserSetIn } from '../models/UserSetIn';
|
||||
import type { UserUpdateIn } from '../models/UserUpdateIn';
|
||||
import type { VersionOut } from '../models/VersionOut';
|
||||
import type { CancelablePromise } from '../core/CancelablePromise';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
import { request as __request } from '../core/request';
|
||||
export class Service {
|
||||
/**
|
||||
* 获取后端git版本信息
|
||||
* @returns VersionOut Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static getGitVersionApiInfoVersionPost(): CancelablePromise<VersionOut> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'POST',
|
||||
url: '/api/info/version',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取关卡号下拉框信息
|
||||
* @param requestBody
|
||||
@@ -956,4 +970,45 @@ export class Service {
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 检查更新
|
||||
* @param requestBody
|
||||
* @returns UpdateCheckOut Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static checkUpdateApiUpdateCheckPost(
|
||||
requestBody: UpdateCheckIn,
|
||||
): CancelablePromise<UpdateCheckOut> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'POST',
|
||||
url: '/api/update/check',
|
||||
body: requestBody,
|
||||
mediaType: 'application/json',
|
||||
errors: {
|
||||
422: `Validation Error`,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 下载更新
|
||||
* @returns OutBase Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static downloadUpdateApiUpdateDownloadPost(): CancelablePromise<OutBase> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'POST',
|
||||
url: '/api/update/download',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 安装更新
|
||||
* @returns OutBase Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static installUpdateApiUpdateInstallPost(): CancelablePromise<OutBase> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'POST',
|
||||
url: '/api/update/install',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
<span class="logo-glow" aria-hidden="true"></span>
|
||||
<img src="@/assets/AUTO-MAS.ico" alt="AUTO-MAS" class="title-logo" />
|
||||
<span class="title-text">AUTO-MAS</span>
|
||||
<span class="version-text">
|
||||
v{{ version }}
|
||||
<span v-if="updateInfo?.if_need_update" class="update-hint" :title="getUpdateTooltip()">
|
||||
检测到更新 {{ updateInfo.latest_version }} 请尽快更新
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,26 +22,18 @@
|
||||
<!-- 右侧:窗口控制按钮 -->
|
||||
<div class="title-bar-right">
|
||||
<div class="window-controls">
|
||||
<button
|
||||
class="control-button minimize-button"
|
||||
@click="minimizeWindow"
|
||||
title="最小化"
|
||||
>
|
||||
<button class="control-button minimize-button" @click="minimizeWindow" title="最小化">
|
||||
<MinusOutlined />
|
||||
</button>
|
||||
<button
|
||||
class="control-button maximize-button"
|
||||
<button
|
||||
class="control-button maximize-button"
|
||||
@click="toggleMaximize"
|
||||
:title="isMaximized ? '还原' : '最大化'"
|
||||
>
|
||||
<BorderOutlined v-if="!isMaximized" />
|
||||
<CopyOutlined v-else />
|
||||
</button>
|
||||
<button
|
||||
class="control-button close-button"
|
||||
@click="closeWindow"
|
||||
title="关闭"
|
||||
>
|
||||
<button class="control-button close-button" @click="closeWindow" title="关闭">
|
||||
<CloseOutlined />
|
||||
</button>
|
||||
</div>
|
||||
@@ -47,10 +45,47 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { MinusOutlined, BorderOutlined, CopyOutlined, CloseOutlined } from '@ant-design/icons-vue'
|
||||
import { useTheme } from '@/composables/useTheme'
|
||||
import { Service } from '@/api'
|
||||
import type { UpdateCheckOut } from '@/api'
|
||||
|
||||
const { isDark } = useTheme()
|
||||
const isMaximized = ref(false)
|
||||
|
||||
// 使用 import.meta.env 或直接定义版本号,确保打包后可用
|
||||
const version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
|
||||
const updateInfo = ref<UpdateCheckOut | null>(null)
|
||||
|
||||
// 获取是否有更新
|
||||
const getAppVersion = async () => {
|
||||
try {
|
||||
const ver = await Service.checkUpdateApiUpdateCheckPost({
|
||||
current_version: version,
|
||||
})
|
||||
updateInfo.value = ver
|
||||
return ver || '获取版本失败!'
|
||||
} catch (error) {
|
||||
console.error('Failed to get app version:', error)
|
||||
return '获取版本失败!'
|
||||
}
|
||||
}
|
||||
|
||||
// 生成更新提示的详细信息
|
||||
const getUpdateTooltip = () => {
|
||||
if (!updateInfo.value?.update_info) return ''
|
||||
|
||||
const updateDetails = []
|
||||
for (const [category, items] of Object.entries(updateInfo.value.update_info)) {
|
||||
if (items && items.length > 0) {
|
||||
updateDetails.push(`${category}:`)
|
||||
items.forEach(item => {
|
||||
updateDetails.push(`• ${item}`)
|
||||
})
|
||||
updateDetails.push('')
|
||||
}
|
||||
}
|
||||
return updateDetails.join('\n')
|
||||
}
|
||||
|
||||
const minimizeWindow = async () => {
|
||||
try {
|
||||
await window.electronAPI?.windowMinimize()
|
||||
@@ -62,7 +97,7 @@ const minimizeWindow = async () => {
|
||||
const toggleMaximize = async () => {
|
||||
try {
|
||||
await window.electronAPI?.windowMaximize()
|
||||
isMaximized.value = await window.electronAPI?.windowIsMaximized() || false
|
||||
isMaximized.value = (await window.electronAPI?.windowIsMaximized()) || false
|
||||
} catch (error) {
|
||||
console.error('Failed to toggle maximize:', error)
|
||||
}
|
||||
@@ -78,10 +113,11 @@ const closeWindow = async () => {
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
isMaximized.value = await window.electronAPI?.windowIsMaximized() || false
|
||||
isMaximized.value = (await window.electronAPI?.windowIsMaximized()) || false
|
||||
} catch (error) {
|
||||
console.error('Failed to get window state:', error)
|
||||
}
|
||||
await getAppVersion()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -124,11 +160,11 @@ onMounted(async () => {
|
||||
left: 55px; /* 调整:更贴近图标 */
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 200px; /* 缩小尺寸以适配 32px 高度 */
|
||||
width: 200px; /* 缩小尺寸以适配 32px 高度 */
|
||||
height: 100px;
|
||||
pointer-events: none;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle at 50% 50%, var(--ant-color-primary) 0%, rgba(0,0,0,0) 70%);
|
||||
background: radial-gradient(circle at 50% 50%, var(--ant-color-primary) 0%, rgba(0, 0, 0, 0) 70%);
|
||||
filter: blur(24px); /* 降低模糊避免越界过多 */
|
||||
opacity: 0.4;
|
||||
z-index: 0;
|
||||
@@ -153,10 +189,23 @@ onMounted(async () => {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.version-text {
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
opacity: 0.8;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.title-bar-dark .title-text {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.title-bar-dark .version-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.title-bar-center {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
@@ -218,4 +267,79 @@ onMounted(async () => {
|
||||
.title-bar-dark .maximize-button:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
</style>
|
||||
|
||||
.update-hint {
|
||||
font-weight: 500;
|
||||
margin-left: 4px;
|
||||
cursor: help;
|
||||
background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #8b00ff, #ff0000);
|
||||
background-size: 400% 400%;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
animation:
|
||||
rainbow-flow 3s ease-in-out infinite,
|
||||
glow-pulse 2s ease-in-out infinite;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.update-hint::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
right: -2px;
|
||||
bottom: -2px;
|
||||
background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #8b00ff, #ff0000);
|
||||
background-size: 400% 400%;
|
||||
border-radius: 4px;
|
||||
z-index: -1;
|
||||
opacity: 0.3;
|
||||
filter: blur(8px);
|
||||
animation: rainbow-flow 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.title-bar-dark .update-hint::before {
|
||||
opacity: 0.5;
|
||||
filter: blur(10px);
|
||||
}
|
||||
|
||||
@keyframes rainbow-flow {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes glow-pulse {
|
||||
0% {
|
||||
filter: brightness(1) saturate(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
filter: brightness(1.2) saturate(1.3);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
100% {
|
||||
filter: brightness(1) saturate(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,9 +5,18 @@ export interface ElectronAPI {
|
||||
selectFolder: () => Promise<string | null>
|
||||
selectFile: (filters?: Array<{ name: string; extensions: string[] }>) => Promise<string | null>
|
||||
|
||||
// 窗口控制
|
||||
windowMinimize: () => Promise<void>
|
||||
windowMaximize: () => Promise<void>
|
||||
windowClose: () => Promise<void>
|
||||
windowIsMaximized: () => Promise<boolean>
|
||||
|
||||
// 管理员权限检查
|
||||
checkAdmin: () => Promise<boolean>
|
||||
|
||||
// 重启为管理员
|
||||
restartAsAdmin: () => Promise<void>
|
||||
|
||||
// 环境检查
|
||||
checkEnvironment: () => Promise<{
|
||||
pythonExists: boolean
|
||||
@@ -53,7 +62,6 @@ export interface ElectronAPI {
|
||||
callback: (progress: { progress: number; status: string; message: string }) => void
|
||||
) => void
|
||||
removeDownloadProgressListener: () => void
|
||||
restartAsAdmin: () => Promise<void>
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -2,6 +2,9 @@ import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
|
||||
// 读取package.json中的版本号
|
||||
const packageJson = require('./package.json')
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
@@ -12,4 +15,8 @@ export default defineConfig({
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
// 在编译时将版本号注入到环境变量中
|
||||
'import.meta.env.VITE_APP_VERSION': JSON.stringify(packageJson.version)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user