LiRen-qiu 4 months ago
parent 0c4f22e6cc
commit 979b1295a5

@ -0,0 +1,145 @@
---
description:
globs:
alwaysApply: true
---
# 组件架构设计指南
## 1. 组件命名规范
* **PascalCase 命名法:** 所有Vue组件使用大驼峰命名法 (如: `FileUpload.vue`)
* **功能前缀:** 根据功能区域添加前缀:
* 处理页面组件: `Process*`
* 分析页面组件: `Analysis*`
* 通用UI组件: `Base*`
* 布局组件: `Layout*`
## 2. 组件目录结构
```
src/
├── components/ # 通用组件
│ ├── base/ # 基础UI组件
│ ├── layout/ # 布局相关组件
│ ├── process/ # 处理页面组件
│ └── analysis/ # 分析页面组件
├── views/ # 页面级组件
│ ├── Process.vue # 处理页面
│ └── Analysis.vue # 分析页面
├── store/ # Vuex状态管理
│ ├── index.js # Store入口
│ ├── modules/ # 模块化store
│ │ ├── app.js # 应用全局状态
│ │ ├── process.js # 处理流程状态
│ │ └── analysis.js # 分析页面状态
├── router/ # 路由配置
│ └── index.js
├── api/ # API交互
│ ├── index.js # API入口和拦截器
│ ├── process.js # 处理相关API
│ └── analysis.js # 分析相关API
├── assets/ # 静态资源
│ ├── css/ # 样式
│ ├── fonts/ # 字体
│ └── images/ # 图片
└── utils/ # 工具函数
├── file.js # 文件处理工具
├── format.js # 格式化工具
└── mock.js # 模拟数据
```
## 3. 组件设计原则
1. **单一职责原则:** 每个组件只负责一项功能
2. **可复用性:** 设计可重用的组件,避免重复代码
3. **Props 向下传递:** 父组件通过 props 向子组件传递数据
4. **Events 向上传递:** 子组件通过 events ($emit) 向父组件传递事件
5. **状态管理清晰:** 明确组件本地状态与全局状态的界限
## 4. `/process` 页面组件层次结构
```
Process.vue (容器组件)
├── ProcessHeader.vue (标题和描述)
├── ProcessSteps.vue (步骤指示器)
└── Step内容区域 (根据currentStep动态切换)
├── FileUpload.vue (步骤1)
│ └── DataPreview.vue (弹出对话框)
├── ProcessStep.vue (步骤2 - 预处理)
│ └── ResultCard.vue (结果展示)
├── ProcessStep.vue (步骤3 - 合并格式)
│ └── ResultCard.vue (结果展示)
├── ProcessStep.vue (步骤4 - 单词纠错)
│ └── ResultCard.vue (结果展示)
└── ProcessStep.vue (步骤5 - 大模型分析)
└── ResultCard.vue (结果展示)
```
## 5. `/analysis` 页面组件层次结构
```
Analysis.vue (容器组件)
├── AnalysisHeader.vue (标题和描述)
├── AnalysisMain.vue (主内容区域 - Grid布局)
│ ├── TermsPanel.vue (左侧词频列表)
│ ├── WordCloud.vue (中间词云)
│ ├── TrendChart.vue (右上趋势图)
│ └── DetailsTabs.vue (下方主面板)
│ ├── SummaryTab.vue (摘要标签页)
│ ├── ContextView.vue (上下文标签页)
│ ├── CollocatesView.vue (搭配词标签页)
│ ├── DocumentsTab.vue (可选 - 文档标签页)
│ └── PhrasesTab.vue (可选 - 短语标签页)
└── AnalysisFooter.vue (可选 - 页脚控制区域)
```
## 6. 组件通信策略
1. **Props & Events:** 父子组件之间的基本通信方式
2. **Vuex:** 跨组件/跨页面的状态共享
3. **事件总线 (EventBus):** 仅在必要时用于非父子组件通信
4. **$refs:** 直接访问子组件实例,仅用于特殊情况
## 7. 组件文档
每个组件应当包含:
1. **组件名称和描述注释**
2. **Props 定义和验证**
3. **Emitted Events 说明**
4. **Slots 用法 (如有)**
5. **依赖的外部资源**
示例:
```js
/**
* FileUpload.vue - 文件上传组件
* 支持拖拽上传Excel和CSV文件并提供文件列表预览
*/
export default {
name: 'FileUpload',
props: {
acceptTypes: {
type: Array,
default: () => ['.xlsx', '.xls', '.csv'],
required: false
},
maxSize: {
type: Number,
default: 10, // MB
required: false
}
},
// ...
methods: {
/**
* 触发file-uploaded事件
* @param {File} file - 上传的文件对象
* @param {Array} data - 解析后的文件数据
*/
handleFileUpload(file, data) {
this.$emit('file-uploaded', { file, data });
}
}
}
```

@ -0,0 +1,717 @@
---
description:
globs:
alwaysApply: true
---
# 实现指南 - 航班对话数据处理系统
## 1. 布局实现
### 顶部标题区域
```vue
<!-- App.vue -->
<template>
<div class="app-container">
<header class="app-header">
<h1 class="app-title">航班对话数据处理系统</h1>
<p class="app-subtitle">SVG/Excel数据预处理、合并格式、单词纠错、大模型分析一站式解决方案</p>
</header>
<main class="app-content">
<router-view />
</main>
</div>
</template>
<style>
.app-container {
height: 100vh;
background-color: #f0f8ff;
}
.app-header {
background: linear-gradient(135deg, #1890ff, #096dd9);
color: white;
padding: 24px 0;
text-align: center;
}
.app-title {
font-size: 36px;
font-weight: bold;
margin-bottom: 8px;
}
.app-subtitle {
font-size: 16px;
opacity: 0.9;
}
.app-content {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
</style>
```
### 文件上传组件
结合Element UI的`el-upload`组件实现拖拽上传功能:
```vue
<!-- components/process/FileUpload.vue -->
<template>
<div class="file-upload-container">
<div class="upload-area">
<el-upload
class="upload-dragger"
drag
action="/api/upload"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
:on-progress="handleProgress"
:before-upload="beforeUpload"
:file-list="fileList"
:on-remove="handleRemove"
:multiple="false"
>
<i class="el-icon-upload cloud-icon"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
</el-upload>
<div class="upload-tip">支持上传 SVG 和 Excel 文件</div>
</div>
<div v-if="uploadedFile" class="upload-actions">
<el-button type="primary" @click="previewData">查看/编辑数据</el-button>
<el-button type="success" @click="goToNextStep" :disabled="!canProceed">下一步: 预处理</el-button>
</div>
<!-- 数据预览对话框 -->
<el-dialog
title="数据预览"
:visible.sync="previewDialogVisible"
width="80%"
:before-close="handleDialogClose"
>
<el-table :data="previewData" border style="width: 100%">
<!-- 根据实际数据动态生成列 -->
<el-table-column
v-for="(column, index) in tableColumns"
:key="index"
:prop="column.prop"
:label="column.label"
></el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="handleDialogClose">取消</el-button>
<el-button type="primary" @click="saveData">保存</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { mapActions } from 'vuex';
export default {
name: 'FileUpload',
data() {
return {
fileList: [],
uploadedFile: null,
uploadProgress: 0,
previewDialogVisible: false,
previewData: [],
tableColumns: [],
canProceed: false
};
},
methods: {
...mapActions('process', ['uploadFile', 'saveFileData', 'nextStep']),
beforeUpload(file) {
// 检查文件类型
const isSVG = file.type === 'image/svg+xml';
const isExcel =
file.type === 'application/vnd.ms-excel' ||
file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
if (!isSVG && !isExcel) {
this.$message.error('请上传SVG或Excel格式的文件!');
return false;
}
// 检查文件大小
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
this.$message.error('文件大小不能超过10MB!');
return false;
}
return true;
},
handleUploadSuccess(response, file, fileList) {
this.uploadedFile = {
id: response.fileId,
name: file.name,
response
};
this.$message.success('文件上传成功');
// 将文件数据保存到store
this.uploadFile(file).then(() => {
// 处理预览数据
if (response.previewData) {
this.previewData = response.previewData;
// 生成表格列
if (this.previewData.length > 0) {
this.tableColumns = Object.keys(this.previewData[0]).map(key => ({
prop: key,
label: key
}));
}
}
});
},
handleUploadError() {
this.$message.error('文件上传失败,请重试');
},
handleProgress(event, file) {
this.uploadProgress = parseInt(event.percent);
},
handleRemove() {
this.uploadedFile = null;
this.fileList = [];
this.canProceed = false;
},
previewData() {
this.previewDialogVisible = true;
},
handleDialogClose() {
this.previewDialogVisible = false;
},
saveData() {
// 保存编辑后的数据
this.saveFileData(this.previewData);
this.previewDialogVisible = false;
this.canProceed = true;
this.$message.success('数据保存成功');
},
goToNextStep() {
if (this.canProceed) {
this.nextStep();
}
}
}
};
</script>
<style scoped>
.file-upload-container {
display: flex;
flex-direction: column;
align-items: center;
}
.upload-area {
width: 80%;
margin: 20px auto;
}
.upload-dragger {
width: 100%;
height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
}
.cloud-icon {
font-size: 60px;
color: #8c8c8c;
margin-bottom: 15px;
}
.el-upload__text {
font-size: 16px;
color: #606266;
}
.upload-tip {
text-align: center;
margin-top: 15px;
color: #909399;
font-size: 14px;
}
.upload-actions {
margin-top: 20px;
display: flex;
gap: 16px;
}
</style>
```
### 步骤指示器组件
根据图片实现底部的步骤指示器:
```vue
<!-- components/process/ProcessSteps.vue -->
<template>
<div class="process-steps">
<div class="steps-container">
<div
v-for="(step, index) in steps"
:key="index"
class="step-item"
>
<div
class="step-circle"
:class="{
'active': currentStep === index + 1,
'completed': currentStep > index + 1
}"
>
<span v-if="currentStep <= index + 1">{{ index + 1 }}</span>
<i v-else class="el-icon-check"></i>
</div>
<div class="step-label">{{ step }}</div>
<div v-if="index < steps.length - 1" class="step-line"></div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'ProcessSteps',
props: {
currentStep: {
type: Number,
required: true
}
},
data() {
return {
steps: ['上传文件', '预处理', '合并格式', '单词纠错', '大模型分析']
};
}
};
</script>
<style scoped>
.process-steps {
margin: 40px 0;
width: 100%;
}
.steps-container {
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
padding: 0 20px;
}
.step-item {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
z-index: 1;
flex: 1;
}
.step-circle {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #d9d9d9;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
margin-bottom: 8px;
}
.step-circle.active {
background-color: #52c41a;
}
.step-circle.completed {
background-color: #52c41a;
}
.step-label {
font-size: 14px;
color: #606266;
text-align: center;
}
.step-line {
position: absolute;
top: 20px;
right: -50%;
width: 100%;
height: 2px;
background-color: #d9d9d9;
z-index: -1;
}
.step-item:last-child .step-line {
display: none;
}
</style>
```
### 主视图组件
整合上传和步骤指示器组件实现Process页面
```vue
<!-- views/Process.vue -->
<template>
<div class="process-container">
<div class="process-main">
<!-- 根据当前步骤显示对应内容 -->
<file-upload v-if="currentStep === 1" />
<preprocessing v-else-if="currentStep === 2" />
<merge-format v-else-if="currentStep === 3" />
<word-correction v-else-if="currentStep === 4" />
<model-analysis v-else-if="currentStep === 5" />
</div>
<!-- 底部步骤指示器 -->
<process-steps :current-step="currentStep" />
</div>
</template>
<script>
import { mapState } from 'vuex';
import FileUpload from '@/components/process/FileUpload.vue';
import Preprocessing from '@/components/process/Preprocessing.vue';
import MergeFormat from '@/components/process/MergeFormat.vue';
import WordCorrection from '@/components/process/WordCorrection.vue';
import ModelAnalysis from '@/components/process/ModelAnalysis.vue';
import ProcessSteps from '@/components/process/ProcessSteps.vue';
export default {
name: 'Process',
components: {
FileUpload,
Preprocessing,
MergeFormat,
WordCorrection,
ModelAnalysis,
ProcessSteps
},
computed: {
...mapState('process', ['currentStep'])
}
};
</script>
<style scoped>
.process-container {
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
padding: 30px;
margin-bottom: 30px;
min-height: 60vh;
display: flex;
flex-direction: column;
}
.process-main {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20px 0;
}
</style>
```
## 2. 全局样式设置
创建全局样式文件,适配参考图的设计风格:
```css
/* src/assets/css/main.css */
/* 全局重置 */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #f0f8ff;
color: #333;
}
/* Element UI 样式覆盖 */
.el-upload-dragger {
width: 100%;
height: 200px;
border: 1px dashed #d9d9d9;
border-radius: 6px;
}
.el-upload-dragger:hover {
border-color: #1890ff;
}
/* 按钮样式 */
.el-button--primary {
background-color: #1890ff;
border-color: #1890ff;
}
.el-button--success {
background-color: #52c41a;
border-color: #52c41a;
}
/* 步骤相关样式 */
.custom-steps .el-step__head.is-process {
color: #52c41a;
border-color: #52c41a;
}
.custom-steps .el-step__title.is-process {
font-weight: bold;
color: #52c41a;
}
/* 响应式设计 */
@media (max-width: 768px) {
.app-title {
font-size: 28px;
}
.app-subtitle {
font-size: 14px;
}
.process-steps {
flex-direction: column;
align-items: flex-start;
}
.step-line {
display: none;
}
}
```
## 3. 路由配置
更新路由配置以匹配新的页面标题:
```js
// src/router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import Process from '../views/Process.vue'
import Analysis from '../views/Analysis.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
redirect: '/process'
},
{
path: '/process',
name: 'Process',
component: Process,
meta: { title: '航班对话数据处理系统' }
},
{
path: '/analysis',
name: 'Analysis',
component: Analysis,
meta: { title: '航班对话数据分析' }
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
document.title = to.meta.title || '航班对话数据处理系统'
next()
})
export default router
```
## 4. API服务模拟
修改API模拟以匹配新的数据处理步骤
```js
// src/utils/mock.js
import Mock from 'mockjs'
// 上传文件响应
Mock.mock('/api/upload', 'post', {
code: 0,
data: {
fileName: '@name',
fileId: '@guid',
rowCount: '@integer(100, 1000)',
columnCount: '@integer(5, 20)',
previewData: Array(5).fill().map(() => ({
id: '@id',
dialog: '@sentence(5, 15)',
timestamp: '@datetime("yyyy-MM-dd HH:mm:ss")',
flight: 'CA@integer(1000, 9999)',
speaker: '@pick(["passenger", "agent"])'
}))
}
})
// 预处理响应
Mock.mock('/api/preprocess', 'post', {
code: 0,
data: {
processedRows: '@integer(80, 90)',
totalRows: '@integer(90, 100)',
duration: '@float(1, 5, 2)',
summary: '预处理已完成,共处理 @integer(80, 100) 行对话数据,识别了 @integer(10, 30) 个话题,标准化了 @integer(5, 15) 个格式不一致的时间戳。',
sampleData: Array(3).fill().map(() => ({
id: '@id',
original: '@sentence(5, 15)',
processed: '@sentence(5, 15)',
changes: '@integer(1, 5)'
}))
}
})
// 其他API响应保持不变...
```
## 5. 状态管理调整
更新Vuex状态管理以适应新需求
```js
// src/store/modules/process.js
import { uploadFile, preprocessData, mergeFormat, correctWords, analyzeData } from '@/api/process'
const state = {
currentStep: 1,
uploadedFiles: [],
fileData: null,
// ... 保持其他状态不变
}
const mutations = {
// ... 保持原有mutation不变
}
const actions = {
// 更新上传文件方法来适应SVG和Excel文件
async uploadFile({ commit }, file) {
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'processing' })
try {
// 针对不同类型文件的处理
const fileType = file.name.endsWith('.svg') ? 'svg' : 'excel';
const formData = new FormData();
formData.append('file', file);
formData.append('fileType', fileType);
const response = await uploadFile(formData)
commit('ADD_UPLOADED_FILE', { id: Date.now(), file, response })
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'completed' })
return response
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'error' })
throw error
}
},
// ... 保持其他action不变
}
const getters = {
// ... 保持原有getter不变
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}
```
## 6. 颜色与样式变量设置
创建样式变量文件以统一管理颜色:
```scss
// src/assets/css/variables.scss
// 主色系
$primary-color: #1890ff; // 主色
$primary-color-light: #40a9ff;
$primary-color-dark: #096dd9;
// 功能色
$success-color: #52c41a; // 成功/步骤激活色
$warning-color: #faad14; // 警告色
$error-color: #f5222d; // 错误色
$info-color: #1890ff; // 信息色
// 中性色
$background-color: #f0f8ff; // 整体背景色
$component-background: #ffffff; // 组件背景色
$border-color: #d9d9d9; // 边框色
$disabled-color: #bfbfbf; // 禁用状态
$text-color: #262626; // 主文本色
$text-color-secondary: #8c8c8c; // 次文本色
// 尺寸
$header-height: 120px;
$border-radius-base: 8px;
$box-shadow-base: 0 2px 8px rgba(0, 0, 0, 0.15);
// 字体
$font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
$font-size-base: 14px;
$font-size-large: 16px;
$font-size-small: 12px;
$font-size-title: 36px;
$font-size-subtitle: 16px;
```
以上是实现参考图所示界面的核心代码和配置,包括顶部标题区域、文件上传组件、步骤指示器以及相关样式。根据需要可以进一步完善各个处理步骤的具体组件实现。

@ -0,0 +1,781 @@
---
description:
globs:
alwaysApply: true
---
# 项目实施指南
## 1. 关键依赖包安装
### 基础框架
```bash
# 核心依赖
npm install vue@2.6.14
npm install vuex@3.6.2
npm install vue-router@3.5.3
```
### UI组件
```bash
# Element UI
npm install element-ui@2.15.10
# 按需引入插件
npm install babel-plugin-component -D
```
### 数据可视化
```bash
# ECharts
npm install echarts@5.4.0
npm install vue-echarts@6.2.3
# 词云
npm install echarts-wordcloud@2.1.0
# 或者 D3 词云
npm install d3@7.8.0
npm install d3-cloud@1.2.5
```
### 数据处理
```bash
# Excel/CSV处理
npm install xlsx@0.18.5
npm install papaparse@5.3.2
# HTTP请求
npm install axios@1.2.0
```
### 开发工具
```bash
# Mock数据
npm install mockjs@1.1.0
```
## 2. 项目目录结构建立
按照以下步骤创建项目基本结构:
```bash
# 创建视图目录
mkdir -p src/views
touch src/views/Process.vue
touch src/views/Analysis.vue
# 创建组件目录
mkdir -p src/components/{base,layout,process,analysis}
touch src/components/layout/Header.vue
touch src/components/layout/Footer.vue
# 创建路由目录
mkdir -p src/router
touch src/router/index.js
# 创建状态管理目录
mkdir -p src/store/modules
touch src/store/index.js
touch src/store/modules/{app.js,process.js,analysis.js}
# 创建API交互目录
mkdir -p src/api
touch src/api/index.js
touch src/api/{process.js,analysis.js}
# 创建工具函数目录
mkdir -p src/utils
touch src/utils/{file.js,format.js,mock.js}
# 创建资源目录
mkdir -p src/assets/{css,fonts,images}
touch src/assets/css/main.css
```
## 3. 核心配置文件设置
### 路由配置 (`src/router/index.js`)
```js
import Vue from 'vue'
import VueRouter from 'vue-router'
import Process from '../views/Process.vue'
import Analysis from '../views/Analysis.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
redirect: '/process'
},
{
path: '/process',
name: 'Process',
component: Process,
meta: { title: '文档处理' }
},
{
path: '/analysis',
name: 'Analysis',
component: Analysis,
meta: { title: '数据分析' }
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
document.title = to.meta.title || '文档智能处理平台'
next()
})
export default router
```
### Vuex状态管理 (`src/store/index.js`)
```js
import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import process from './modules/process'
import analysis from './modules/analysis'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
app,
process,
analysis
}
})
```
### Element UI引入 (`src/main.js`)
```js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './utils/mock'
// Element UI
import {
Button, Steps, Step, Upload, Table, TableColumn, Dialog,
Card, Loading, Tabs, TabPane, Message, Notification, Alert
} from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 注册Element UI组件
Vue.use(Button)
Vue.use(Steps)
Vue.use(Step)
Vue.use(Upload)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Dialog)
Vue.use(Card)
Vue.use(Loading)
Vue.use(Tabs)
Vue.use(TabPane)
Vue.use(Alert)
// 挂载Element UI消息组件
Vue.prototype.$message = Message
Vue.prototype.$notify = Notification
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
```
### API请求封装 (`src/api/index.js`)
```js
import axios from 'axios'
import { Message } from 'element-ui'
// 创建axios实例
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API || '/api',
timeout: 15000
})
// 请求拦截器
service.interceptors.request.use(
config => {
// 可添加token等认证信息
return config
},
error => {
console.error('请求错误:', error)
return Promise.reject(error)
}
)
// 响应拦截器
service.interceptors.response.use(
response => {
const res = response.data
// 根据实际API返回格式调整
if (res.code === 0) {
return res.data
}
Message({
message: res.message || '请求错误',
type: 'error',
duration: 5 * 1000
})
return Promise.reject(new Error(res.message || '请求错误'))
},
error => {
console.error('响应错误:', error)
Message({
message: error.message || '网络错误',
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
}
)
export default service
```
## 4. 核心Vuex模块实现示例
### `src/store/modules/process.js`
```js
import { uploadFile, preprocessData, mergeFormat, correctWords, analyzeData } from '@/api/process'
const state = {
currentStep: 1,
uploadedFiles: [],
fileData: null,
preprocessResults: null,
mergeResults: null,
correctionResults: null,
analysisResults: null,
stepStatus: {
upload: 'pending',
preprocess: 'pending',
merge: 'pending',
correction: 'pending',
analysis: 'pending'
}
}
const mutations = {
SET_CURRENT_STEP(state, step) {
state.currentStep = step
},
ADD_UPLOADED_FILE(state, file) {
state.uploadedFiles.push(file)
},
REMOVE_UPLOADED_FILE(state, fileId) {
state.uploadedFiles = state.uploadedFiles.filter(file => file.id !== fileId)
},
SET_FILE_DATA(state, data) {
state.fileData = data
},
SET_PREPROCESS_RESULTS(state, results) {
state.preprocessResults = results
state.stepStatus.preprocess = 'completed'
},
SET_MERGE_RESULTS(state, results) {
state.mergeResults = results
state.stepStatus.merge = 'completed'
},
SET_CORRECTION_RESULTS(state, results) {
state.correctionResults = results
state.stepStatus.correction = 'completed'
},
SET_ANALYSIS_RESULTS(state, results) {
state.analysisResults = results
state.stepStatus.analysis = 'completed'
},
UPDATE_STEP_STATUS(state, { step, status }) {
state.stepStatus[step] = status
}
}
const actions = {
// 上传文件
async uploadFile({ commit }, file) {
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'processing' })
try {
const response = await uploadFile(file)
commit('ADD_UPLOADED_FILE', { id: Date.now(), file, response })
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'completed' })
return response
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'upload', status: 'error' })
throw error
}
},
// 保存编辑后的数据
saveFileData({ commit }, data) {
commit('SET_FILE_DATA', data)
},
// 预处理数据
async preprocessData({ commit, state }) {
if (!state.fileData) return Promise.reject(new Error('没有数据可处理'))
commit('UPDATE_STEP_STATUS', { step: 'preprocess', status: 'processing' })
try {
const results = await preprocessData(state.fileData)
commit('SET_PREPROCESS_RESULTS', results)
return results
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'preprocess', status: 'error' })
throw error
}
},
// 合并格式
async mergeFormat({ commit, state }) {
if (!state.preprocessResults) return Promise.reject(new Error('请先进行预处理'))
commit('UPDATE_STEP_STATUS', { step: 'merge', status: 'processing' })
try {
const results = await mergeFormat(state.preprocessResults)
commit('SET_MERGE_RESULTS', results)
return results
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'merge', status: 'error' })
throw error
}
},
// 单词纠错
async correctWords({ commit, state }) {
if (!state.mergeResults) return Promise.reject(new Error('请先进行格式合并'))
commit('UPDATE_STEP_STATUS', { step: 'correction', status: 'processing' })
try {
const results = await correctWords(state.mergeResults)
commit('SET_CORRECTION_RESULTS', results)
return results
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'correction', status: 'error' })
throw error
}
},
// 大模型分析
async analyzeData({ commit, state }) {
if (!state.correctionResults) return Promise.reject(new Error('请先进行单词纠错'))
commit('UPDATE_STEP_STATUS', { step: 'analysis', status: 'processing' })
try {
const results = await analyzeData(state.correctionResults)
commit('SET_ANALYSIS_RESULTS', results)
return results
} catch (error) {
commit('UPDATE_STEP_STATUS', { step: 'analysis', status: 'error' })
throw error
}
},
// 前进到下一步
nextStep({ commit, state }) {
if (state.currentStep < 5) {
commit('SET_CURRENT_STEP', state.currentStep + 1)
}
},
// 返回上一步
prevStep({ commit, state }) {
if (state.currentStep > 1) {
commit('SET_CURRENT_STEP', state.currentStep - 1)
}
}
}
const getters = {
canProceedToNextStep: state => {
switch (state.currentStep) {
case 1: return state.stepStatus.upload === 'completed' && state.fileData !== null
case 2: return state.stepStatus.preprocess === 'completed'
case 3: return state.stepStatus.merge === 'completed'
case 4: return state.stepStatus.correction === 'completed'
case 5: return state.stepStatus.analysis === 'completed'
default: return false
}
},
isCurrentStepProcessing: state => {
const stepMap = {
1: 'upload',
2: 'preprocess',
3: 'merge',
4: 'correction',
5: 'analysis'
}
const currentStepKey = stepMap[state.currentStep]
return state.stepStatus[currentStepKey] === 'processing'
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}
```
## 5. 组件实现建议
### Process.vue基本结构
```vue
<template>
<div class="process-container">
<!-- 页面头部 -->
<div class="process-header">
<h1 class="process-title">文档智能处理流程</h1>
<p class="process-subtitle">上传、预处理、分析您的 Excel/CSV 数据</p>
<div class="process-icon">
<!-- 中央处理图标 -->
<img src="@/assets/images/process-icon.svg" alt="处理流程" />
</div>
</div>
<!-- 步骤条 -->
<div class="process-steps">
<el-steps :active="currentStep" finish-status="success" align-center>
<el-step title="上传文件"></el-step>
<el-step title="预处理"></el-step>
<el-step title="合并格式"></el-step>
<el-step title="单词纠错"></el-step>
<el-step title="模型分析"></el-step>
</el-steps>
</div>
<!-- 步骤内容区域 -->
<div class="step-content">
<!-- 根据currentStep显示对应的组件 -->
<file-upload v-if="currentStep === 1" />
<processing-step
v-else-if="currentStep === 2"
title="数据预处理"
:status="stepStatus.preprocess"
@process="handlePreprocess"
/>
<processing-step
v-else-if="currentStep === 3"
title="合并格式"
:status="stepStatus.merge"
@process="handleMergeFormat"
/>
<processing-step
v-else-if="currentStep === 4"
title="单词纠错"
:status="stepStatus.correction"
@process="handleWordCorrection"
/>
<processing-step
v-else-if="currentStep === 5"
title="大模型分析"
:status="stepStatus.analysis"
@process="handleAnalysis"
/>
</div>
<!-- 辅助信息区域 -->
<div class="process-footer">
<a href="#" class="privacy-link">如何保护我的文件?</a>
<div class="notification-option">
<el-checkbox v-model="notifyWhenDone">处理完成后通知我</el-checkbox>
<el-input
v-if="notifyWhenDone"
v-model="notifyEmail"
placeholder="请输入您的邮箱"
size="small"
style="width: 200px; margin-left: 10px;"
></el-input>
</div>
</div>
</div>
</template>
<script>
import { mapState, mapGetters, mapActions } from 'vuex'
import FileUpload from '@/components/process/FileUpload.vue'
import ProcessingStep from '@/components/process/ProcessingStep.vue'
export default {
name: 'Process',
components: {
FileUpload,
ProcessingStep
},
data() {
return {
notifyWhenDone: false,
notifyEmail: ''
}
},
computed: {
...mapState('process', ['currentStep', 'stepStatus']),
...mapGetters('process', ['canProceedToNextStep', 'isCurrentStepProcessing'])
},
methods: {
...mapActions('process', [
'preprocessData',
'mergeFormat',
'correctWords',
'analyzeData',
'nextStep'
]),
async handlePreprocess() {
try {
await this.preprocessData()
this.$message.success('预处理完成')
} catch (error) {
this.$message.error(`预处理失败: ${error.message}`)
}
},
async handleMergeFormat() {
try {
await this.mergeFormat()
this.$message.success('格式合并完成')
} catch (error) {
this.$message.error(`格式合并失败: ${error.message}`)
}
},
async handleWordCorrection() {
try {
await this.correctWords()
this.$message.success('单词纠错完成')
} catch (error) {
this.$message.error(`单词纠错失败: ${error.message}`)
}
},
async handleAnalysis() {
try {
await this.analyzeData()
this.$message.success('分析完成')
this.$notify({
title: '分析完成',
message: '文档分析已完成,点击"查看分析结果"按钮查看详细分析。',
type: 'success',
duration: 5000
})
} catch (error) {
this.$message.error(`分析失败: ${error.message}`)
}
}
}
}
</script>
<style scoped>
.process-container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.process-header {
text-align: center;
margin-bottom: 40px;
}
.process-title {
font-size: 36px;
font-weight: bold;
margin-bottom: 10px;
color: #262626;
}
.process-subtitle {
font-size: 18px;
color: #666;
margin-bottom: 20px;
}
.process-icon {
margin: 20px 0;
}
.process-icon img {
width: 100px;
height: 100px;
}
.process-steps {
margin-bottom: 40px;
}
.step-content {
background-color: #fff;
border-radius: 8px;
padding: 30px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
min-height: 300px;
}
.process-footer {
margin-top: 30px;
display: flex;
justify-content: space-between;
font-size: 14px;
color: #8c8c8c;
}
.privacy-link {
color: #1890ff;
text-decoration: none;
}
.notification-option {
display: flex;
align-items: center;
}
</style>
```
## 6. 模拟数据设置
### `src/utils/mock.js`
```js
import Mock from 'mockjs'
// 上传文件响应
Mock.mock('/api/upload', 'post', {
code: 0,
data: {
fileName: '@name',
fileId: '@guid',
rowCount: '@integer(100, 1000)',
columnCount: '@integer(5, 20)',
previewData: Array(5).fill().map(() => ({
id: '@id',
name: '@cname',
content: '@sentence(5, 15)',
date: '@date',
value: '@float(0, 100, 2, 2)'
}))
}
})
// 预处理响应
Mock.mock('/api/preprocess', 'post', {
code: 0,
data: {
processedRows: '@integer(80, 90)',
totalRows: '@integer(90, 100)',
duration: '@float(1, 5, 2)',
summary: '预处理已完成,共处理 @integer(80, 100) 行数据,清洗了 @integer(10, 30) 个异常值,标准化了 @integer(5, 15) 个格式不一致的字段。',
sampleData: Array(3).fill().map(() => ({
id: '@id',
original: '@sentence(5, 15)',
processed: '@sentence(5, 15)',
changes: '@integer(1, 5)'
}))
}
})
// 合并格式响应
Mock.mock('/api/merge', 'post', {
code: 0,
data: {
mergedFormats: '@integer(3, 10)',
consistencyScore: '@float(80, 99, 2)',
duration: '@float(0.5, 3, 2)',
summary: '合并格式已完成,统一了 @integer(3, 10) 种不同的数据格式,数据一致性得分达到 @float(80, 99, 2)%。',
sampleData: Array(3).fill().map(() => ({
id: '@id',
beforeMerge: '@sentence(5, 15)',
afterMerge: '@sentence(5, 15)',
formatType: '@word(4, 8)'
}))
}
})
// 单词纠错响应
Mock.mock('/api/correct', 'post', {
code: 0,
data: {
totalWords: '@integer(1000, 5000)',
correctedWords: '@integer(10, 100)',
accuracyRate: '@float(95, 99, 2)',
duration: '@float(1, 4, 2)',
summary: '单词纠错已完成,检查了 @integer(1000, 5000) 个单词,纠正了 @integer(10, 100) 个拼写错误,准确率达到 @float(95, 99, 2)%。',
corrections: Array(5).fill().map(() => ({
id: '@id',
original: '@word(3, 8)',
corrected: '@word(3, 8)',
confidence: '@float(60, 100, 2)'
}))
}
})
// 大模型分析响应
Mock.mock('/api/analyze', 'post', {
code: 0,
data: {
documentId: '@guid',
analysisDate: '@datetime',
duration: '@float(3, 10, 2)',
summary: '文档分析已完成,提取了关键词、词频、文本共现关系等信息。可以在分析页面查看详细结果。',
// 词频数据
termFrequencies: Array(50).fill().map(() => ({
term: '@word(2, 8)',
frequency: '@integer(1, 300)',
isHighlighted: '@boolean'
})),
// 文档段落分析数据,用于趋势图
documentSegments: Array(10).fill().map((_, index) => ({
segmentId: index + 1,
segmentName: `段落${index + 1}`,
termFrequencies: Array(20).fill().map(() => ({
term: '@word(2, 8)',
frequency: '@float(0, 0.1, 4)'
}))
})),
// 上下文数据
contexts: Array(20).fill().map(() => ({
term: '@word(2, 8)',
instances: Array('@integer(1, 10)').fill().map(() => ({
leftContext: '@sentence(3, 8)',
keyword: '@word(2, 8)',
rightContext: '@sentence(3, 8)',
sourceParagraph: '@integer(1, 10)'
}))
})),
// 搭配词数据
collocates: Array(20).fill().map(() => ({
term: '@word(2, 8)',
cooccurrences: Array('@integer(3, 15)').fill().map(() => ({
word: '@word(2, 8)',
frequency: '@integer(1, 50)',
position: '@pick(["left", "right"])',
distance: '@integer(1, 5)'
}))
}))
}
})
```
以上实施指南提供了项目的核心结构、配置和几个关键组件的实现示例,可作为项目实施的起点。后续可根据具体需求继续扩展和完善各个组件和功能。

@ -0,0 +1,80 @@
---
description:
globs:
alwaysApply: true
---
# Project Overview: Vue 2 Text Analysis Application
## 1. Project Goal
Develop a Vue 2 frontend application with two main views:
* A multi-step file processing interface (`/process`).
* A results analysis and visualization interface (`/analysis`), inspired by Voyant Tools.
## 2. Core Technology Stack
* **Framework:** Vue 2 (Options API preferred)
* **Build Tool:** Vue CLI ([vue.config.js](mdc:vue2/vue.config.js))
* **Language:** JavaScript (ES6+) or TypeScript
* **State Management:** Vuex (Expected in `src/store/`)
* **Routing:** Vue Router (Expected in `src/router/`)
* **UI Library:** Element UI (Recommended)
* **Charting:** ECharts or Chart.js
* **Word Cloud:** D3-Cloud or ECharts Wordcloud
## 3. Application Structure
The application is divided into two main views/routes:
* **`/process`**: Handles the file processing workflow.
* **`/analysis`**: Displays the analysis results visually.
Router configuration is expected in `src/router/index.js` (or similar).
Vuex store configuration is expected in `src/store/index.js` (or similar).
The main application entry point is likely `[src/main.js](mdc:vue2/src/main.js)`.
## 4. Key Features
### `/process` View (File Processing)
* **UI Style:** Inspired by a specific visual design (blue background, clear steps).
* **Workflow:** A 5-step process guided by an `el-steps` component:
1. **File Upload:** Supports Excel/CSV, drag-and-drop, includes a modal (`el-dialog` with `el-table`) for viewing/editing uploaded data.
2. **Preprocessing:** Calls backend API, displays intermediate results.
3. **Merge Format:** Calls backend API, displays intermediate results.
4. **Word Correction:** Calls backend API, displays intermediate results.
5. **LLM Analysis:** Calls backend API, stores final results in Vuex, navigates to `/analysis`.
* **User Interaction:** Step-by-step progression, loading indicators, error handling.
### `/analysis` View (Results Analysis)
* **UI Layout:** Multi-panel design resembling Voyant Tools.
* **Components:**
* **Terms Panel (Left):** `el-table` showing keyword frequencies, sortable, interactive.
* **TermsBerry Panel (Center):** Word cloud visualization (ECharts/D3).
* **Trends Panel (Top Right):** Line chart (ECharts) showing keyword frequency trends across document segments.
* **Details Panel (Bottom):** `el-tabs` for switching between:
* Summary: Basic text stats.
* Contexts (KWIC): Keyword in context view.
* Collocates: Words frequently appearing near the selected term.
* (Optional) Documents, Phrases.
* **Data Source:** Relies on analysis results stored in the Vuex store.
* **Interactivity:** Panels are linked; selecting a term updates other panels.
## 5. State Management (Vuex)
* Manages analysis results passed from the `/process` view.
* Handles interactive state for the `/analysis` view (e.g., selected terms).
* Components interact with the store using standard Vuex helpers (`mapState`, `mapActions`, etc.).
## 6. Backend Interaction
* Frontend primarily handles UI, state management, and user interaction.
* Assumes backend APIs handle the heavy lifting for file parsing, preprocessing, analysis, and correction steps.
## 7. Code Requirements
* Follow Vue 2 best practices.
* Maintain clear component structure.
* Implement robust error handling and loading states.
* Focus on clean UI presentation using Element UI.

@ -0,0 +1,138 @@
---
description:
globs:
alwaysApply: true
---
\
---
description:
globs:
alwaysApply: true
---
# 项目开发计划与实施
## 1. 项目开发阶段
本Vue 2项目计划分为以下几个开发阶段
1. **基础架构搭建**
* 配置Vue Router路由系统
* 设置Vuex状态管理
* 引入Element UI组件库
* 配置项目结构和基本样式
2. **`/process`页面开发**
* 实现5步骤处理流程UI
* 开发文件上传与预览功能
* 实现各处理步骤的状态管理
* 连接后端API(模拟或实际API)
3. **`/analysis`页面开发**
* 实现多面板布局
* 集成图表库与词云功能
* 开发数据可视化组件
* 实现面板间的联动交互
4. **优化与完善**
* 性能优化
* 响应式设计适配
* 错误处理完善
* 用户体验改进
## 2. 组件结构设计
### 全局组件
* `App.vue` - 应用根组件
* `components/layout/Header.vue` - 页面头部
* `components/layout/Footer.vue` - 页面底部(如需)
### `/process`页面组件
* `views/Process.vue` - 处理页面容器
* `components/process/ProcessSteps.vue` - 步骤指示器
* `components/process/FileUpload.vue` - 文件上传组件
* `components/process/DataPreview.vue` - 数据预览对话框
* `components/process/ProcessingStep.vue` - 通用处理步骤组件
* `components/process/ResultCard.vue` - 处理结果展示卡片
### `/analysis`页面组件
* `views/Analysis.vue` - 分析页面容器
* `components/analysis/TermsPanel.vue` - 词频列表面板
* `components/analysis/WordCloud.vue` - 词云面板
* `components/analysis/TrendChart.vue` - 趋势图面板
* `components/analysis/DetailsTabs.vue` - 详细信息标签页
* `components/analysis/ContextView.vue` - 上下文查看组件
* `components/analysis/CollocatesView.vue` - 搭配词查看组件
## 3. 状态管理计划
Vuex store将分为以下几个模块
* **app** - 全局应用状态
```
state: {
loading: false,
error: null
}
```
* **process** - 处理流程相关状态
```
state: {
currentStep: 1,
uploadedFiles: [],
fileData: null,
preprocessResults: null,
mergeResults: null,
correctionResults: null,
analysisResults: null,
stepStatus: {
upload: 'pending',
preprocess: 'pending',
merge: 'pending',
correction: 'pending',
analysis: 'pending'
}
}
```
* **analysis** - 分析页面相关状态
```
state: {
selectedTerms: [],
termFrequencies: [],
documentSegments: [],
contexts: {},
collocates: {}
}
```
## 4. API交互计划
### 模拟API端点
* `/api/upload` - 上传文件
* `/api/preprocess` - 预处理数据
* `/api/merge` - 合并格式
* `/api/correct` - 单词纠错
* `/api/analyze` - 大模型分析
### API交互模式
* 使用Axios进行HTTP请求
* 实现请求拦截器处理认证
* 实现响应拦截器处理错误
* 模拟API响应用于开发阶段
## 5. UI设计指南
* **主色调:** 蓝色系(#1890ff作为主色配合适当的渐变)
* **布局:** 居中设计内容区域最大宽度1200px
* **组件样式:** 遵循Element UI设计语言适当自定义
* **响应式:** 支持至少三种尺寸(桌面,平板,移动)
## 6. 开发里程碑
1. **第一周:** 基础架构搭建,路由配置,状态管理设置
2. **第二周:** `/process`页面UI开发文件上传功能实现
3. **第三周:** 处理步骤流程实现API连接(或模拟)
4. **第四周:** `/analysis`页面基础布局,数据可视化组件集成
5. **第五周:** 完善分析页面功能,实现面板联动
6. **第六周:** 测试、优化与完善

@ -0,0 +1,161 @@
---
description:
globs:
alwaysApply: true
---
# 技术栈详细说明
## 1. Vue 2 框架
* **版本:** Vue 2.6+ (或最新的Vue 2.x版本)
* **主要API风格:** Options API
* **文件格式:** 单文件组件 (.vue)
* **生命周期钩子:** `created`, `mounted`, `updated`, `destroyed`等
* **参考文档:** [Vue 2.x官方文档](mdc:https:/v2.vuejs.org)
## 2. 状态管理 (Vuex)
* **版本:** Vuex 3.x (与Vue 2兼容的版本)
* **结构:** 模块化Store设计
* **核心概念:**
* State: 应用状态
* Getters: 从状态派生的计算属性
* Mutations: 同步修改状态的方法
* Actions: 可以包含异步操作的逻辑
* Modules: 将store分割成模块
* **参考文档:** [Vuex 3.x文档](mdc:https:/v3.vuex.vuejs.org)
## 3. 路由 (Vue Router)
* **版本:** Vue Router 3.x
* **配置方式:**
```js
const routes = [
{ path: '/', redirect: '/process' },
{ path: '/process', component: Process },
{ path: '/analysis', component: Analysis }
];
```
* **路由模式:** History模式 (建议)
* **参考文档:** [Vue Router 3.x文档](mdc:https:/v3.router.vuejs.org)
## 4. UI组件库 (Element UI)
* **版本:** Element UI 2.x
* **安装命令:** `npm install element-ui@2.x`
* **引入方式:**
* 完整引入
* 按需引入 (推荐需配置babel-plugin-component)
* **主要组件:**
* `el-steps`: 处理流程步骤条
* `el-upload`: 文件上传
* `el-dialog`: 模态对话框
* `el-table`: 数据表格
* `el-tabs`: 标签页
* `el-card`: 卡片容器
* `el-button`: 按钮
* **主题定制:** 可通过SCSS变量覆盖实现
* **参考文档:** [Element UI文档](mdc:https:/element.eleme.io/#/zh-CN/component/installation)
## 5. 图表可视化
### ECharts (推荐)
* **版本:** ECharts 5.x
* **安装:** `npm install echarts@5`
* **Vue集成:** 使用`vue-echarts`或自定义组件包装
* **主要图表类型:**
* 折线图 (用于趋势图)
* 词云图 (需配合echarts-wordcloud)
* **参考文档:** [ECharts文档](mdc:https:/echarts.apache.org/zh/index.html)
### Chart.js (备选)
* **版本:** Chart.js 2.x (与Vue 2兼容)
* **安装:** `npm install chart.js@2.9.4 vue-chartjs`
* **Vue集成:** 使用`vue-chartjs`
* **参考文档:** [Chart.js文档](mdc:https:/www.chartjs.org/docs/2.9.4)
## 6. 词云
### ECharts Wordcloud
* **安装:** `npm install echarts-wordcloud`
* **使用方式:** 配合ECharts使用
* **参考文档:** [echarts-wordcloud GitHub](mdc:https:/github.com/ecomfe/echarts-wordcloud)
### D3-Cloud (备选)
* **安装:** `npm install d3-cloud d3`
* **Vue集成:** 需自定义组件进行封装
* **参考文档:** [d3-cloud GitHub](mdc:https:/github.com/jasondavies/d3-cloud)
## 7. HTTP请求
### Axios
* **版本:** 最新版
* **安装:** `npm install axios`
* **拦截器配置:**
```js
axios.interceptors.request.use(config => {...})
axios.interceptors.response.use(response => {...}, error => {...})
```
* **参考文档:** [Axios文档](mdc:https:/axios-http.com)
## 8. 开发工具配置
### ESLint
* **配置:** `.eslintrc.js`
* **规则集:** 标准Vue规则集
* **推荐插件:** `eslint-plugin-vue`
### Babel
* **配置:** `babel.config.js`
* **预设:** `@vue/cli-plugin-babel/preset`
* **插件:** `babel-plugin-component` (用于Element UI按需引入)
### Vue CLI配置
* **配置文件:** `vue.config.js`
* **主要配置项:**
```js
module.exports = {
publicPath: '/',
outputDir: 'dist',
assetsDir: 'static',
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true
}
}
}
}
```
## 9. 文件解析库
### Excel/CSV处理
* **xlsx:** `npm install xlsx` (处理Excel文件)
* **papaparse:** `npm install papaparse` (处理CSV文件)
## 10. 模拟API
### Mock.js
* **安装:** `npm install mockjs`
* **基本用法:**
```js
import Mock from 'mockjs'
Mock.mock('/api/upload', 'post', {
'code': 0,
'data': {...}
})
```
* **参考文档:** [Mock.js文档](mdc:http:/mockjs.com)

@ -0,0 +1,151 @@
---
description:
globs:
alwaysApply: true
---
# UI设计与交互指南
## 1. 全局设计原则
* **一致性:** 整个应用保持一致的视觉语言和交互模式
* **直观性:** 界面元素和交互方式应该易于理解和操作
* **响应性:** 所有操作应有明确的反馈,特别是在异步操作过程中
* **可访问性:** 适当的颜色对比度和操作区域大小,确保良好的可用性
## 2. 颜色系统
### 主要颜色
- **主色调**: 蓝色系 (#1890ff) - 用于顶部背景和主要按钮
- **强调色**: 绿色 (#52c41a) - 用于当前活跃步骤的指示和成功状态
- **背景色**: 浅蓝色 (#f0f8ff) - 整体页面背景
- **内容区背景**: 白色 (#ffffff) - 内容区卡片背景
### 辅助颜色
- **灰色系**: #d9d9d9 (边框), #8c8c8c (次要文本), #f5f5f5 (分割线)
- **警告色**: 橙色 (#faad14) - 用于警告信息
- **错误色**: 红色 (#f5222d) - 用于错误提示
## 3. 排版
### 字体家族
```css
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
```
### 字体大小
- **页面标题**: 36px, 粗体
- **页面副标题**: 16px, 常规
- **组件标题**: 20px, 粗体
- **正文文本**: 14px, 常规
- **辅助文本**: 12px, 常规
## 4. 布局结构
### 整体布局
- **顶部区域**: 蓝色渐变背景高度约为120px包含标题和副标题
- 标题文字: "航班对话数据处理系统"
- 副标题文字: "SVG/Excel数据预处理、合并格式、单词纠错、大模型分析一站式解决方案"
- **内容区域**: 白色卡片式容器圆角8px带有轻微阴影
- 上传文件区域: 居中显示,拖拽上传组件
- 底部步骤指示器: 横向布局的5个步骤指示
### 主页布局示例
```
┌────────────────────────────────────────────────────┐
│ │
│ 航班对话数据处理系统 (蓝色背景) │
│ SVG/Excel数据预处理、合并格式、单词纠错、大模型分析一站式解决方案 │
│ │
├────────────────────────────────────────────────────┤
│ │
│ │
│ ╭───────────╮ │
│ │ ☁️ │ │
│ │ │ │
│ │ 将文件拖到此处,│ │
│ │ 或点击上传 │ │
│ │ │ │
│ ╰───────────╯ │
│ │
│ 支持上传 SVG 和 Excel 文件 │
│ │
│ │
├────────────────────────────────────────────────────┤
│ │
│ ⓵─────────⓶─────────⓷─────────⓸─────────⓹ │
│ 上传文件 预处理 合并格式 单词纠错 大模型分析 │
│ │
└────────────────────────────────────────────────────┘
```
## 5. 组件样式
### 上传组件
- **拖拽区域**: 虚线边框高度约200px宽度80%
- **图标**: 云图标,灰色(#8c8c8c)尺寸60px
- **提示文字**: 14px颜色#606266
- **文件类型提示**: 12px颜色#909399
### 步骤指示器
- **步骤圆圈**: 直径40px圆形
- 默认状态: 灰色背景(#d9d9d9)
- 活跃状态: 绿色背景(#52c41a)
- 完成状态: 绿色背景(#52c41a),白色对勾图标
- **步骤标签**: 14px颜色#606266
- **连接线**: 高度2px颜色#d9d9d9
### 按钮
- **主要按钮**: 蓝色背景(#1890ff),白色文字
- **成功按钮**: 绿色背景(#52c41a),白色文字
- **默认按钮**: 白色背景,灰色边框(#d9d9d9),黑色文字
## 6. 响应式设计
### 桌面端 (>= 1024px)
- 内容区域最大宽度: 1200px
- 上传组件宽度: 80%
### 平板端 (768px - 1023px)
- 内容区域宽度: 90%
- 上传组件宽度: 90%
- 字体尺寸略微缩小
### 移动端 (<= 767px)
- 内容区域宽度: 95%
- 上传组件宽度: 100%
- 标题字体减小到24px
- 步骤指示器改为垂直布局
## 7. 动画效果
### 过渡效果
- 所有状态变化使用0.3秒的平滑过渡
- 上传组件hover效果: 边框色变为主色(#1890ff)
- 步骤切换时的淡入淡出效果
### 加载动画
- 文件上传中: 环形进度指示器
- 数据处理中: 脉冲波纹效果
## 8. 交互响应
### 状态反馈
- 上传成功: 绿色成功提示,显示"文件上传成功"
- 上传失败: 红色错误提示,显示具体错误信息
- 处理完成: 绿色成功提示,可进行下一步操作
### 操作引导
- 提供明确的操作提示和引导文本
- 禁用不可用的操作按钮,并提供视觉提示
- 每个步骤完成后自动显示下一步按钮
## 9. 改进建议
* **进度指示:** 在每个处理步骤中,可考虑添加进度百分比或估计剩余时间
* **文件预览:** 上传Excel后可提供简单的数据预览前几行
* **暗色模式:** 考虑添加暗色主题,减少用户在暗环境下的眼睛疲劳
* **处理历史:** 保存用户之前的处理记录,方便重复使用
* **批量处理:** 支持批量上传和处理多个文件
* **导出功能:** 在分析页面添加导出分析结果的功能PDF、Excel等
* **帮助提示:** 为每个步骤和功能添加简短的帮助提示tooltip
* **处理步骤记忆:** 刷新页面后记住用户的处理步骤和数据
Loading…
Cancel
Save