chore: 初始化前端项目脚手架与构建配置

Vue 3 + TypeScript + Vite 工程配置,包含 package.json、tsconfig、vite.config.ts 及 .gitignore(忽略 node_modules/dist/自动生成类型声明)。
This commit is contained in:
caoxiaozhu
2026-07-10 16:44:23 +08:00
parent ecb138ed25
commit 855308e5fa
10 changed files with 4476 additions and 0 deletions

22
frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
node_modules
dist
dist-ssr
*.local
# 自动生成的类型声明
auto-imports.d.ts
components.d.ts
# Editor
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

66
frontend/README.md Normal file
View File

@@ -0,0 +1,66 @@
# 远光软件微调平台 - 前端Vue 3
> 由原 `web/` 静态多页面 HTML 项目改造而来。
## 技术栈
- **Vue 3** + **TypeScript** + **Vite**
- **Vue Router 4** - 路由
- **Pinia** - 状态管理
- **Element Plus** - UI 组件库(主色 `#1890ff`
- **axios** - HTTP 请求
- **Chart.js** - 训练曲线图表
- **marked + DOMPurify** - Markdown 渲染
- **md-editor-v3** - Prompt 编辑器
- **@vueuse/core** - 组合式工具
## 快速开始
```bash
cd frontend
npm install
npm run dev
```
开发服务器默认运行在 `http://localhost:6801`
后端 API 默认通过 Vite 代理转发到 `http://localhost:7861`(见 `vite.config.ts`)。
## 构建
```bash
npm run build # 类型检查 + 生产构建,产物在 dist/
npm run preview # 本地预览构建产物
npm run type-check # 仅类型检查
```
## 目录结构
```
src/
├── api/ # axios 封装 + 各业务模块 API
├── components/ # 公共组件(侧边栏、顶部栏、通用列表等)
├── composables/ # 组合式函数(流式对话、图表、轮询等)
├── constants/ # 常量与映射表
├── layouts/ # 主布局
├── router/ # 路由配置 + 登录守卫
├── stores/ # Pinia 状态auth/system/models/tools
├── styles/ # 全局样式与主题
├── types/ # TypeScript 类型定义
└── views/ # 页面视图
├── login/ # 登录
├── fine-tune/ # 模型调优
├── eval/ # 模型评测
├── inference/ # 模型推理
├── compare/ # 模型对比
├── model/ # 模型管理
├── dataset/ # 数据集
├── tools/ # 其他工具
└── system/ # 平台性能 / 日志
```
## 与原 web/ 项目的关系
-`web/` 目录**保留不动**,作为功能对照参照。
- 新前端位于 `frontend/`,新旧可并存。
- 后端 API 端点完全不变,仅前端实现方式改为 Vue SPA。

16
frontend/index.html Normal file
View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<title>远光软件微调平台</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

4242
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

41
frontend/package.json Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "yg-ft-platform-frontend",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
"type-check": "vue-tsc -b --noEmit",
"test:data-process-wizard": "node scripts/regression-data-process-wizard.mjs",
"test:model-manage": "node scripts/regression-model-manage.mjs",
"test:training-log-layout": "node scripts/regression-training-log-layout.mjs",
"test:page-surface": "node scripts/regression-page-surface.mjs"
},
"dependencies": {
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9",
"chart.js": "^4.4.7",
"dompurify": "^3.2.3",
"echarts": "^6.1.0",
"element-plus": "^2.9.1",
"marked": "^15.0.5",
"md-editor-v3": "^5.1.4",
"pinia": "^2.3.0",
"vue": "^3.5.13",
"vue-echarts": "^8.0.1",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"@types/node": "^26.1.1",
"@vitejs/plugin-vue": "^5.2.1",
"sass": "^1.83.0",
"typescript": "~5.7.2",
"unplugin-auto-import": "^0.19.0",
"unplugin-vue-components": "^0.28.0",
"vite": "^6.0.7",
"vue-tsc": "^2.2.0"
}
}

7
frontend/src/env.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "preserve",
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"types": ["element-plus/global"]
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "auto-imports.d.ts", "components.d.ts"]
}

7
frontend/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"strict": true,
"types": ["node"]
},
"include": ["vite.config.ts"]
}

34
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,34 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'node:path'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver({ importStyle: false })],
}),
Components({
resolvers: [ElementPlusResolver({ importStyle: false })],
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
server: {
port: 6801,
proxy: {
// 后端服务固定在 7861 端口,前端统一走 /api 相对路径
'/api': {
target: 'http://localhost:7861',
changeOrigin: true,
},
},
},
})