diff --git a/frontend/README.md b/frontend/README.md index 85f9468..883fe95 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -26,6 +26,15 @@ npm run dev 后端 API 默认通过 Vite 代理转发到 `http://localhost:7861`(见 `vite.config.ts`)。 +开发环境默认启用前端 Mock。如需联调真实后端,使用: + +```bash +VITE_ENABLE_MOCK=false npm run dev +``` + +生产构建默认不包含 Mock;仅在演示构建中可显式设置 +`VITE_ENABLE_MOCK=true`。 + ## 构建 ```bash diff --git a/frontend/scripts/regression-training-log-layout.mjs b/frontend/scripts/regression-training-log-layout.mjs index 05245ea..215b245 100644 --- a/frontend/scripts/regression-training-log-layout.mjs +++ b/frontend/scripts/regression-training-log-layout.mjs @@ -117,7 +117,8 @@ assert.match( assert.match(source, /import \{ getSystemInfo \} from '@\/api\/modules\/system'/, '训练概览必须复用系统 GPU 监控数据源') assert.match(source, /Promise\.all\(\[datasetPromise, loadLog\(currentTask\), loadGpuStatus\(\)\]\)/, 'GPU 状态必须和训练日志一起刷新') assert.match(source, /if \(refreshInFlight\) return/, '轮询刷新必须阻止并发重叠') -assert.match(source, /onUnmounted\([\s\S]*?clearInterval\(timer\)/, '组件卸载时必须清理轮询定时器') +assert.match(source, /usePolling/, '训练日志必须使用统一轮询机制') +assert.match(source, /stopPolling\(\)/, '训练结束后必须停止轮询') const overview = findElements( templateAst, diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 856a59f..c9dc7e9 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,7 +1,9 @@ diff --git a/frontend/src/api/request.ts b/frontend/src/api/request.ts index 3ee62a7..4c44b53 100644 --- a/frontend/src/api/request.ts +++ b/frontend/src/api/request.ts @@ -17,10 +17,6 @@ const service: AxiosInstance = axios.create({ timeout: 30000, }) -// 安装 mock adapter(拦截所有 axios 请求返回 mock 数据,方便前端独立开发调试) -import { installMockAdapter } from '@/mock/adapter' -installMockAdapter(service) - // 请求拦截器 service.interceptors.request.use( (config) => config, diff --git a/frontend/src/env.d.ts b/frontend/src/env.d.ts index 323c78a..443a7fa 100644 --- a/frontend/src/env.d.ts +++ b/frontend/src/env.d.ts @@ -1,5 +1,14 @@ /// +interface ImportMetaEnv { + /** 是否启用前端 Mock;开发环境默认开启,生产环境默认关闭。 */ + readonly VITE_ENABLE_MOCK?: 'true' | 'false' +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} + declare module '*.vue' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index 0a67cda..6cb75d7 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -1,6 +1,7 @@ diff --git a/frontend/src/views/login/LoginView.vue b/frontend/src/views/login/LoginView.vue index aa89d4b..3b5e5e8 100644 --- a/frontend/src/views/login/LoginView.vue +++ b/frontend/src/views/login/LoginView.vue @@ -136,7 +136,7 @@ async function handleLogin() { position: relative; color: #fff; background-color: #121127; - background-image: url('@/assets/login-hero-flow.png'); + background-image: url('@/assets/login-hero-flow.jpg'); background-size: cover; background-position: center; overflow: hidden; diff --git a/frontend/src/views/system/HardwareView.vue b/frontend/src/views/system/HardwareView.vue index 765cfcd..0ea331c 100644 --- a/frontend/src/views/system/HardwareView.vue +++ b/frontend/src/views/system/HardwareView.vue @@ -1,6 +1,8 @@