Compare commits
17
Commits
68082afc78
...
8d5c9db47f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d5c9db47f | ||
|
|
b8b0b73cd8 | ||
|
|
81f91b320a | ||
|
|
de45c8039c | ||
|
|
c2493e4c71 | ||
|
|
0059e0ec71 | ||
|
|
96d574b99f | ||
|
|
69861d54bb | ||
|
|
769d26fa97 | ||
|
|
04df078fcf | ||
|
|
bcec8512f4 | ||
|
|
297320446c | ||
|
|
a87fdba4cc | ||
|
|
a43267db73 | ||
|
|
9af479d833 | ||
|
|
a00e576516 | ||
|
|
02ce825c53 |
@@ -0,0 +1,152 @@
|
||||
# LPT 前端应用(lpt-fe)
|
||||
|
||||
> Vue 3 + TypeScript + Vite 单页应用。
|
||||
|
||||
## Git 提交规范
|
||||
|
||||
- 提交信息必须简短且使用中文,不要使用英文长句。
|
||||
- 格式:`类型: 简述`,例如 `feat: 新增学习会话页面`、`fix: 修复路由守卫401跳转`、`docs: 补充组件说明`。
|
||||
|
||||
## 技术栈
|
||||
|
||||
- 框架:Vue 3 + TypeScript + Vite 5
|
||||
- UI 库:Element Plus 2.8
|
||||
- HTTP:Axios(`withCredentials: true`,自动携带 Cookie `satoken`)
|
||||
- 思维导图:mind-elixir 5.13
|
||||
- Markdown:marked 18.0
|
||||
- 测试:Vitest + Playwright
|
||||
|
||||
## 项目结构
|
||||
|
||||
```text
|
||||
lpt-fe/src/
|
||||
├── api/ → API 接口层
|
||||
├── components/ → 页面组件
|
||||
├── components/composables/ → 组合式函数
|
||||
├── router/ → 路由配置
|
||||
├── utils/ → 工具函数
|
||||
├── assets/ → 全局样式与资源
|
||||
└── __tests__/ → 单元测试
|
||||
```
|
||||
|
||||
核心组件:`Login.vue`、`Welcome.vue`、`Study.vue`、`StartTask.vue`、`Review.vue`、`ReviewDetail.vue`、`ReviewRecall.vue`、`TaskForm.vue`、`MindMapViewer.vue`、`MarkdownRenderer.vue`。
|
||||
|
||||
## 路由表
|
||||
|
||||
| 路径 | 组件 | 说明 |
|
||||
|------|------|------|
|
||||
| `/login` | Login.vue | 登录页(无需认证) |
|
||||
| `/welcome` | Welcome.vue | 首页 |
|
||||
| `/study` | Study.vue | 学习任务列表 |
|
||||
| `/start-task/:taskNum` | StartTask.vue | 学习会话 |
|
||||
| `/add-task` | TaskForm.vue | 创建任务 |
|
||||
| `/update-task/:taskId` | TaskForm.vue | 更新任务 |
|
||||
| `/review` | Review.vue | 复习总览 |
|
||||
| `/review/detail/:type/:id` | ReviewDetail.vue | 复习详情 |
|
||||
| `/review/recall/:taskNum` | ReviewRecall.vue | 回忆复习 |
|
||||
|
||||
## 认证与请求
|
||||
|
||||
- Axios `withCredentials: true`,Cookie `satoken` 自动携带。
|
||||
- 401 处理:HTTP 层和业务层双重检测,清理 `localStorage.isLoggedIn` 后跳转 `/login`。
|
||||
- `validateResponse`:`code !== 200` 时 reject。
|
||||
- Vite 代理:`/api` → `http://localhost:5157`,自动重写去掉 `/api` 前缀。
|
||||
|
||||
## Markdown 学习材料
|
||||
|
||||
- 编辑:textarea 输入,支持 `[文字](url)` 和裸 URL。
|
||||
- 预览:`renderMarkdown(raw)` 同步函数,使用 `__LINK_N__` 占位符防止嵌套 HTML。
|
||||
- 保存:`convertMaterialUrls()` 异步拉取标题,替换裸 URL 为 `[标题](url)`。
|
||||
- `getUrlTitle(url)`:调用 `/utils/fetch-title`,带内存缓存和请求去重。
|
||||
|
||||
## 应用场景
|
||||
|
||||
- TaskForm 编辑页使用 `el-dialog` 弹窗管理应用场景。
|
||||
- Study 详情页使用 `getUrlTitle` 展示应用场景链接标题。
|
||||
|
||||
## 样式与交互约定
|
||||
|
||||
- 链接使用绿色系 `var(--green-600)`,虚线下划线,hover 变实线。
|
||||
- 区块分隔使用 `.detail-block`:`border-top` + `padding-top`,首个除外。
|
||||
- 小字提示使用 12px `var(--text-secondary)`。
|
||||
- `Study.vue` 任务清单每页 20 条。
|
||||
- `StartTask.vue` 编辑任务时先 GET 详情,合并后再 PUT,避免覆盖其他字段。
|
||||
- `MindMapViewer.vue` 支持只读、编辑、selectable、colorByCompare 模式;selectable 模式下点击节点 emit `node-select`。
|
||||
- ReviewRecall 中 `standardExpanded` 展开后节点可点击,用于选择复习起点。
|
||||
|
||||
## 前端代码标准
|
||||
|
||||
### 按钮规范
|
||||
|
||||
- 页面主操作 / 卡片 CTA:`size="large"`,如 Study 开始任务、TaskForm 保存、Welcome 快速入口。
|
||||
- 区块工具栏 / 页内操作:默认尺寸,如 Review 刷新、ReviewRecall 面板操作、历史记录。
|
||||
- 表格/列表行内操作:`size="small" text`,如 查看记录、回忆复习、编辑、删除。
|
||||
- 弹窗 footer:默认尺寸;确认按钮 `type="success"`,取消按钮默认;危险操作统一 `type="danger"`。
|
||||
- 正向/保存语义统一 `success`,次级编辑语义可用 `primary`,不要在同一功能上混用。
|
||||
- 窄屏(`max-width: 768px`)操作区按钮纵向全宽,全局规则位于 `src/assets/main.css` 的 `.action-row / .edit-actions / .fragment-edit-actions`。
|
||||
|
||||
### 移动端适配
|
||||
|
||||
- 断点约定:按钮/弹窗使用 768px,卡片与汇总布局使用 900px。
|
||||
- 弹窗:窄屏宽度 `calc(100% - 24px)`,body 允许纵向滚动,footer 按钮等宽;全局规则位于 `main.css` 的 `@media (max-width: 768px)`,新增弹窗不需要再逐页适配。
|
||||
- 多按钮弹窗(如 Welcome 回忆卡片)在窄屏纵向堆叠。
|
||||
- 列表页优先使用卡片列表而非 `el-table`,桌面与移动端视觉统一,参考 `Review.vue` 的 `.task-list`。
|
||||
- 文案不缩写:使用完整字段名,如 `学习报告数量`、`学习残片数量`,不使用 `报告数`、`残片数`。
|
||||
|
||||
### 代码整洁
|
||||
|
||||
- Markdown 渲染统一使用 `src/utils/markdown.ts` 的 `renderMarkdown`,禁止在组件内复制实现。
|
||||
- 应用场景状态常量统一使用 `src/utils/taskApplication.ts` 的 `applicationStatusOptions`。
|
||||
- 不保留无消费者代码:未使用的 import、prop、事件、API 封装、CSS class、组件文件与依赖应及时删除。
|
||||
- 组件公开 props/events 只在有实际消费者时保留,例如 MindMapViewer 通过 `toOutline()` 导出编辑内容,不依赖无人监听的 change 事件。
|
||||
- Vite 模板遗留文件(示例组件、icon、logo)不进入业务代码。
|
||||
|
||||
### 提交前检查
|
||||
|
||||
- 运行 `npx vue-tsc --noEmit`、`npm run test`、`npm run build`。
|
||||
- 提交信息按 Git 提交规范使用中文短句;样式类改动用 `style:`,清理类用 `refactor:` / `chore:`。
|
||||
|
||||
## 开发配置
|
||||
|
||||
- 开发端口:5158
|
||||
- 代理:`/api` → `http://localhost:5157`
|
||||
- 环境变量:`.env.development` / `.env.production` / `.env.uat`
|
||||
|
||||
## 启动命令
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
npm run build
|
||||
npm run test
|
||||
npm run test:e2e
|
||||
npx vue-tsc --noEmit
|
||||
```
|
||||
|
||||
编译检查也可以使用:
|
||||
|
||||
```bash
|
||||
npx vite build
|
||||
npx vue-tsc --noEmit
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
- 多阶段构建:`node:20-alpine` 编译 → `nginx:alpine` 运行。
|
||||
- 暴露端口:80。
|
||||
- 构建参数:`BUILD_MODE`,默认 production。
|
||||
|
||||
## 关联项目
|
||||
|
||||
| 项目 | 路径 | 端口 | 说明 |
|
||||
|------|------|------|------|
|
||||
| lpt-be | `../lpt-be/` | 5157 | Spring Boot 后端,前端通过 `/api` 代理调用 |
|
||||
| lpt-ai | `../lpt-ai/` | 5199 | AI 服务,前端不直接调用 |
|
||||
|
||||
## 调用关系
|
||||
|
||||
```text
|
||||
浏览器 → lpt-fe (5158) ──/api──→ lpt-be (5157) ──HTTP──→ lpt-ai (5199)
|
||||
│
|
||||
└── MySQL (8109)
|
||||
```
|
||||
@@ -1,46 +0,0 @@
|
||||
# LPT 前端规范
|
||||
|
||||
## 技术栈
|
||||
- Vue 3 + TypeScript + Vite
|
||||
- Element Plus UI
|
||||
- Axios(`src/utils/request.ts`)
|
||||
- mind-elixir(思维导图)
|
||||
|
||||
## 认证与请求
|
||||
- axios `withCredentials: true`,Cookie `satoken` 自动携带
|
||||
- 401 处理(`handleError`):HTTP 层和业务层双重检测,清 `localStorage.isLoggedIn` → `router.push("/login")`
|
||||
- `validateResponse`:`code !== 200` → reject
|
||||
|
||||
## Markdown 学习材料
|
||||
- 编辑:textarea 输入,支持 `[文字](url)` 和裸 URL
|
||||
- 预览/展示:`renderMarkdown(raw)` 同步函数
|
||||
- 使用占位符 `__LINK_N__` 避免正则二次匹配产生嵌套 HTML
|
||||
- `[文字](url)` → `<a>` 标签
|
||||
- 裸 URL → `<a>` 标签(展示时用 getUrlTitle 获取标题)
|
||||
- 保存:`convertMaterialUrls()` 在 createTask/updateTask 前异步拉取标题,替换裸 URL 为 `[标题](url)`
|
||||
- `getUrlTitle(url)`:调 `/utils/fetch-title`,内存缓存 + 请求去重
|
||||
|
||||
## 应用场景
|
||||
- TaskForm 编辑页:弹窗形式(el-dialog),列表展示用 `getUrlTitle` 获取链接标题
|
||||
- Study 详情页:同上
|
||||
|
||||
## 样式规范
|
||||
- 链接:绿色系(`var(--green-600)`),虚线下划线,hover 变实线
|
||||
- 区块分隔:`.detail-block` 有 `border-top` + `padding-top`,首个除外
|
||||
- 小字提示:12px `var(--text-secondary)`
|
||||
|
||||
## 任务清单分页
|
||||
- Study.vue:每页 20 条,`el-pagination` 在列表底部
|
||||
|
||||
## 学习会话页面
|
||||
- StartTask.vue 展示学习材料(可点击链接),支持弹窗编辑
|
||||
- 编辑时先 GET 任务详情,合并后 PUT 更新(保护其他字段不被覆盖)
|
||||
|
||||
## 思维导图
|
||||
- MindMapViewer 封装 mind-elixir
|
||||
- selectable 模式:点击节点 emit `node-select`
|
||||
- ReviewRecall 中 standardExpanded 展开后节点可点击选复习起点
|
||||
|
||||
## 编译
|
||||
- `npx vite build`
|
||||
- `npx vue-tsc --noEmit`(类型检查)
|
||||
@@ -1,53 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: lpt-fe
|
||||
namespace: lpt-dev
|
||||
labels:
|
||||
app: lpt-fe
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: lpt-fe
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: lpt-fe
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
containers:
|
||||
- name: lpt-fe
|
||||
image: 192.168.123.199:5000/lpt-fe:dev
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 128Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 80
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 80
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: lpt-fe
|
||||
namespace: lpt-dev
|
||||
labels:
|
||||
app: lpt-fe
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
app: lpt-fe
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
nodePort: 30080
|
||||
protocol: TCP
|
||||
Generated
+208
-1631
File diff suppressed because it is too large
Load Diff
@@ -20,13 +20,10 @@
|
||||
"dependencies": {
|
||||
"async-validator": "^4.2.5",
|
||||
"axios": "^1.7.7",
|
||||
"css-loader": "^7.1.2",
|
||||
"element-plus": "^2.8.7",
|
||||
"marked": "^18.0.5",
|
||||
"mind-elixir": "^5.13.0",
|
||||
"normalize": "^0.3.1",
|
||||
"normalize.css": "^8.0.1",
|
||||
"style-loader": "^4.0.0",
|
||||
"vue": "^3.5.12",
|
||||
"vue-router": "^4.4.5"
|
||||
},
|
||||
@@ -39,7 +36,6 @@
|
||||
"@vue/test-utils": "^2.4.10",
|
||||
"@vue/tsconfig": "^0.5.1",
|
||||
"jsdom": "^24.1.3",
|
||||
"npm-run-all2": "^7.0.1",
|
||||
"tsx": "^4.23.0",
|
||||
"typescript": "~5.6.0",
|
||||
"vite": "^5.4.10",
|
||||
|
||||
Generated
-67
@@ -11,21 +11,12 @@ dependencies:
|
||||
axios:
|
||||
specifier: ^1.7.7
|
||||
version: 1.16.1
|
||||
css-loader:
|
||||
specifier: ^7.1.2
|
||||
version: 7.1.4(webpack@5.107.2)
|
||||
element-plus:
|
||||
specifier: ^2.8.7
|
||||
version: 2.14.0(vue@3.5.34)
|
||||
normalize:
|
||||
specifier: ^0.3.1
|
||||
version: 0.3.1
|
||||
normalize.css:
|
||||
specifier: ^8.0.1
|
||||
version: 8.0.1
|
||||
style-loader:
|
||||
specifier: ^4.0.0
|
||||
version: 4.0.0(webpack@5.107.2)
|
||||
vue:
|
||||
specifier: ^3.5.12
|
||||
version: 3.5.34(typescript@5.6.3)
|
||||
@@ -58,9 +49,6 @@ devDependencies:
|
||||
jsdom:
|
||||
specifier: ^24.1.3
|
||||
version: 24.1.3
|
||||
npm-run-all2:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.2
|
||||
typescript:
|
||||
specifier: ~5.6.0
|
||||
version: 5.6.3
|
||||
@@ -1271,29 +1259,6 @@ packages:
|
||||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
|
||||
/css-loader@7.1.4(webpack@5.107.2):
|
||||
resolution: {integrity: sha512-vv3J9tlOl04WjiMvHQI/9tmIrCxVrj6PFbHemBB1iihpeRbi/I4h033eoFIhwxBBqLhI0KYFS7yvynBFhIZfTw==}
|
||||
engines: {node: '>= 18.12.0'}
|
||||
peerDependencies:
|
||||
'@rspack/core': 0.x || ^1.0.0 || ^2.0.0-0
|
||||
webpack: ^5.27.0
|
||||
peerDependenciesMeta:
|
||||
'@rspack/core':
|
||||
optional: true
|
||||
webpack:
|
||||
optional: true
|
||||
dependencies:
|
||||
icss-utils: 5.1.0(postcss@8.5.15)
|
||||
postcss: 8.5.15
|
||||
postcss-modules-extract-imports: 3.1.0(postcss@8.5.15)
|
||||
postcss-modules-local-by-default: 4.2.0(postcss@8.5.15)
|
||||
postcss-modules-scope: 3.2.1(postcss@8.5.15)
|
||||
postcss-modules-values: 4.0.0(postcss@8.5.15)
|
||||
postcss-value-parser: 4.2.0
|
||||
semver: 7.8.1
|
||||
webpack: 5.107.2(postcss@8.5.15)
|
||||
dev: false
|
||||
|
||||
/cssesc@3.0.0:
|
||||
resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -1931,34 +1896,11 @@ packages:
|
||||
resolution: {integrity: sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg==}
|
||||
dev: false
|
||||
|
||||
/normalize@0.3.1:
|
||||
resolution: {integrity: sha512-DfyFcERXw4cjxUBgmATdxnCipRFoRvj0tNo+MWwjhebV9GZz2HYoNkXodEqS565uomk0CxEs90nEwrmj+aI9RQ==}
|
||||
dependencies:
|
||||
stylus: 0.64.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/npm-normalize-package-bin@4.0.0:
|
||||
resolution: {integrity: sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==}
|
||||
engines: {node: ^18.17.0 || >=20.5.0}
|
||||
dev: true
|
||||
|
||||
/npm-run-all2@7.0.2:
|
||||
resolution: {integrity: sha512-7tXR+r9hzRNOPNTvXegM+QzCuMjzUIIq66VDunL6j60O4RrExx32XUhlrS7UK4VcdGw5/Wxzb3kfNcFix9JKDA==}
|
||||
engines: {node: ^18.17.0 || >=20.5.0, npm: '>= 9'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
ansi-styles: 6.2.3
|
||||
cross-spawn: 7.0.6
|
||||
memorystream: 0.3.1
|
||||
minimatch: 9.0.9
|
||||
pidtree: 0.6.0
|
||||
read-package-json-fast: 4.0.0
|
||||
shell-quote: 1.8.4
|
||||
which: 5.0.0
|
||||
dev: true
|
||||
|
||||
/nwsapi@2.2.23:
|
||||
resolution: {integrity: sha512-7wfH4sLbt4M0gCDzGE6vzQBo0bfTKjU7Sfpqy/7gs1qBfYz2vEJH6vXcBKpO3+6Yu1telwd0t9HpyOoLEQQbIQ==}
|
||||
dev: true
|
||||
@@ -2283,15 +2225,6 @@ packages:
|
||||
dependencies:
|
||||
ansi-regex: 6.2.2
|
||||
|
||||
/style-loader@4.0.0(webpack@5.107.2):
|
||||
resolution: {integrity: sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==}
|
||||
engines: {node: '>= 18.12.0'}
|
||||
peerDependencies:
|
||||
webpack: ^5.27.0
|
||||
dependencies:
|
||||
webpack: 5.107.2(postcss@8.5.15)
|
||||
dev: false
|
||||
|
||||
/stylus@0.64.0:
|
||||
resolution: {integrity: sha512-ZIdT8eUv8tegmqy1tTIdJv9We2DumkNZFdCF5mz/Kpq3OcTaxSuCAYZge6HKK2CmNC02G1eJig2RV7XTw5hQrA==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
@@ -32,12 +32,6 @@ export interface RecallRecord {
|
||||
createdTime: string;
|
||||
}
|
||||
|
||||
export interface FindNodeResult {
|
||||
path: string;
|
||||
nodeTitle: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
/** 获取/自动生成标准思维导图 */
|
||||
export const getStandardMindMap = (taskNum: string) => {
|
||||
return request.get(`/review/standard-mind-map/${taskNum}`);
|
||||
@@ -69,8 +63,3 @@ export const findNode = (taskNum: string, content: string) => {
|
||||
export const listRecallRecords = (taskNum: string) => {
|
||||
return request.get(`/review/standard-mind-map/${taskNum}/recall-records`);
|
||||
};
|
||||
|
||||
/** 获取单条回忆对比记录 */
|
||||
export const getRecallRecord = (recordId: number) => {
|
||||
return request.get(`/review/standard-mind-map/recall-records/${recordId}`);
|
||||
};
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
|
||||
|
Before Width: | Height: | Size: 276 B |
@@ -35,6 +35,67 @@ a:hover {
|
||||
box-shadow: var(--shadow-soft);
|
||||
}
|
||||
|
||||
/* 按钮操作区统一规范:窄屏下操作按钮纵向全宽 */
|
||||
.action-row .el-button,
|
||||
.edit-actions .el-button,
|
||||
.fragment-edit-actions .el-button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.action-row,
|
||||
.edit-actions,
|
||||
.fragment-edit-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-row .el-button,
|
||||
.edit-actions .el-button,
|
||||
.fragment-edit-actions .el-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* 移动端弹窗适配:覆盖 Element Plus 内联宽度并约束 footer */
|
||||
@media (max-width: 768px) {
|
||||
.el-dialog {
|
||||
--el-dialog-width: calc(100% - 24px) !important;
|
||||
--el-dialog-margin-top: 5vh;
|
||||
max-height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
max-height: calc(100vh - 200px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.el-dialog__footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.el-dialog__footer .el-button {
|
||||
flex: 1;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.el-message-box {
|
||||
max-width: calc(100% - 24px);
|
||||
}
|
||||
|
||||
.el-message-box__btns {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.el-message-box__btns .el-button {
|
||||
flex: 1;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.fade-up-enter-active,
|
||||
.fade-up-leave-active {
|
||||
transition: opacity 0.22s ease, transform 0.22s ease;
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
msg: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="greetings">
|
||||
<h1 class="green">{{ msg }}</h1>
|
||||
<h3>
|
||||
You’ve successfully created a project with
|
||||
<a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
|
||||
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
|
||||
</h3>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
h1 {
|
||||
font-weight: 500;
|
||||
font-size: 2.6rem;
|
||||
position: relative;
|
||||
top: -10px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.greetings h1,
|
||||
.greetings h3 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.greetings h1,
|
||||
.greetings h3 {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -27,13 +27,9 @@ const props = defineProps<{
|
||||
height?: string;
|
||||
/** 节点可选择模式(点击节点触发 node-select 事件) */
|
||||
selectable?: boolean;
|
||||
/** 当前选中的节点路径(用于高亮,仅在 selectable 模式下生效) */
|
||||
selectedPath?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 编辑模式下结构变化时抛出最新大纲文本 */
|
||||
(e: "change", outline: string): void;
|
||||
/** 点击带溯源信息的节点 */
|
||||
(e: "node-click", node: { sourceType: string; sourceId: number }): void;
|
||||
/** 选择模式下点击节点,返回标题+路径 */
|
||||
@@ -156,12 +152,6 @@ const render = () => {
|
||||
});
|
||||
instance.init(toElixirData(props.tree));
|
||||
|
||||
if (props.editable) {
|
||||
instance.bus.addListener("operation", () => {
|
||||
emit("change", toOutline());
|
||||
});
|
||||
}
|
||||
|
||||
// mind-elixir v5: selectNode(el) is called on every node click, but the
|
||||
// selectNewNode event is never fired (it requires selectNode(el, true),
|
||||
// which the default click handler never passes). Monkey-patch selectNode
|
||||
|
||||
+70
-35
@@ -66,7 +66,7 @@ onMounted(() => {
|
||||
<section class="review-page">
|
||||
<div class="table-toolbar">
|
||||
<span class="toolbar-placeholder"></span>
|
||||
<el-button type="success" plain size="small" :loading="loading" @click="loadTasks">刷新</el-button>
|
||||
<el-button type="success" plain :loading="loading" @click="loadTasks">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<div class="summary-grid">
|
||||
@@ -84,37 +84,45 @@ onMounted(() => {
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<article class="surface-card table-card">
|
||||
<el-table v-loading="loading" :data="tasks" stripe @row-click="openTaskReview">
|
||||
<el-table-column prop="taskName" label="任务名" min-width="180" />
|
||||
<el-table-column prop="effectiveTime" label="累计有效学习时长" min-width="150">
|
||||
<template #default="{ row }">
|
||||
{{ formatEffectiveTime(row.effectiveTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="reportCount" label="学习报告数" min-width="120" />
|
||||
<el-table-column prop="fragmentCount" label="学习残片数" min-width="120" />
|
||||
<el-table-column label="操作" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
text
|
||||
type="success"
|
||||
:loading="openingTaskNum === row.taskNum"
|
||||
@click.stop="openTaskReview(row)"
|
||||
>
|
||||
查看记录
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
type="primary"
|
||||
@click.stop="router.push(`/review/recall/${row.taskNum}`)"
|
||||
>
|
||||
回忆复习
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</article>
|
||||
<div v-if="tasks.length > 0" v-loading="loading" class="task-list">
|
||||
<article
|
||||
v-for="row in tasks"
|
||||
:key="row.taskNum"
|
||||
class="surface-card task-card"
|
||||
@click="openTaskReview(row)"
|
||||
>
|
||||
<div class="task-head">
|
||||
<strong>{{ row.taskName }}</strong>
|
||||
</div>
|
||||
<div class="task-meta">
|
||||
<span>累计有效学习时长:{{ formatEffectiveTime(row.effectiveTime) }}</span>
|
||||
</div>
|
||||
<div class="task-stats">
|
||||
<span>学习报告数量:{{ row.reportCount || 0 }}</span>
|
||||
<span>学习残片数量:{{ row.fragmentCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="task-actions">
|
||||
<el-button
|
||||
text
|
||||
type="success"
|
||||
size="small"
|
||||
:loading="openingTaskNum === row.taskNum"
|
||||
@click.stop="openTaskReview(row)"
|
||||
>
|
||||
查看记录
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
type="success"
|
||||
size="small"
|
||||
@click.stop="router.push(`/review/recall/${row.taskNum}`)"
|
||||
>
|
||||
回忆复习
|
||||
</el-button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<el-empty v-if="!loading && tasks.length === 0" description="暂无复习任务" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -153,14 +161,41 @@ onMounted(() => {
|
||||
color: var(--green-900);
|
||||
}
|
||||
|
||||
.table-card {
|
||||
padding: 10px;
|
||||
.task-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.table-card :deep(.el-table__row) {
|
||||
.task-card {
|
||||
padding: 14px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.task-head strong {
|
||||
display: block;
|
||||
color: var(--green-900);
|
||||
font-size: 15px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.task-meta,
|
||||
.task-stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 14px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.task-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.summary-grid {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
@@ -252,8 +252,8 @@ watch(
|
||||
placeholder="请输入学习内容"
|
||||
/>
|
||||
<div class="edit-actions">
|
||||
<el-button @click="cancelEdit">取消</el-button>
|
||||
<el-button type="success" :loading="saving" @click="saveEdit">保存</el-button>
|
||||
<el-button size="small" @click="cancelEdit">取消</el-button>
|
||||
<el-button type="success" size="small" :loading="saving" @click="saveEdit">保存</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 只读模式 -->
|
||||
@@ -480,11 +480,4 @@ watch(
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.form-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
recallCompare,
|
||||
updateStandardMindMap,
|
||||
listRecallRecords,
|
||||
findNode,
|
||||
type StandardMindMap,
|
||||
type RecallRecord,
|
||||
} from "@/api/standardMindMap";
|
||||
@@ -51,6 +50,7 @@ const editViewer = ref<InstanceType<typeof MindMapViewer> | null>(null);
|
||||
// 回忆历史
|
||||
const historyRecords = ref<RecallRecord[]>([]);
|
||||
const showHistory = ref(false);
|
||||
const historyLoading = ref(false);
|
||||
|
||||
// 解析标准导图 JSON 为树节点
|
||||
const standardTree = computed<MindMapTreeNode | null>(() => {
|
||||
@@ -250,6 +250,8 @@ const resetComparison = () => {
|
||||
hasCompared.value = false;
|
||||
focusPath.value = "";
|
||||
recallTree.value = buildEmptyRecallTree();
|
||||
standardExpanded.value = true;
|
||||
editingStandard.value = false;
|
||||
};
|
||||
|
||||
// 编辑标准导图
|
||||
@@ -294,12 +296,19 @@ const cancelStandardEdit = () => {
|
||||
|
||||
// 查看回忆历史
|
||||
const loadHistory = async () => {
|
||||
if (showHistory.value) {
|
||||
showHistory.value = false;
|
||||
return;
|
||||
}
|
||||
historyLoading.value = true;
|
||||
try {
|
||||
const res = await listRecallRecords(taskNum.value);
|
||||
historyRecords.value = res?.data || [];
|
||||
showHistory.value = true;
|
||||
} catch {
|
||||
ElMessage.error("加载历史记录失败");
|
||||
} finally {
|
||||
historyLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -311,6 +320,8 @@ const selectHistoryRecord = (record: RecallRecord) => {
|
||||
const tree = parseOutlineToTree(record.recallContent);
|
||||
if (tree) recallTree.value = tree;
|
||||
hasCompared.value = true;
|
||||
focusPath.value = record.focusPath || "";
|
||||
standardExpanded.value = true;
|
||||
} catch {
|
||||
ElMessage.error("解析对比记录失败");
|
||||
}
|
||||
@@ -374,10 +385,9 @@ onMounted(() => {
|
||||
<section class="recall-page">
|
||||
<!-- 顶部操作栏 -->
|
||||
<div class="page-header">
|
||||
<el-button size="small" @click="router.back()">← 返回</el-button>
|
||||
<h2>回忆复习</h2>
|
||||
<el-button size="small" @click="loadHistory" v-if="!showHistory">
|
||||
历史记录
|
||||
<el-button :loading="historyLoading" @click="loadHistory">
|
||||
{{ showHistory ? "收起历史" : "历史记录" }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
@@ -385,12 +395,12 @@ onMounted(() => {
|
||||
<div class="review-scope surface-card" v-if="focusPath">
|
||||
<span class="scope-label">复习起点</span>
|
||||
<el-tag size="small" type="success" effect="light">{{ focusPath }}</el-tag>
|
||||
<el-button size="small" text @click="focusPath = ''">重选节点</el-button>
|
||||
<el-button size="small" text @click="resetComparison">重选节点</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 节点选择确认弹窗 -->
|
||||
<el-dialog v-model="focusConfirmVisible" title="确认复习起点" width="400px">
|
||||
<p v-if="selectedNodeInfo">
|
||||
<p v-if="selectedNodeInfo" class="focus-confirm-text">
|
||||
以 「<strong>{{ selectedNodeInfo.title }}</strong>」 为起点,
|
||||
复习该知识点下的 <strong>{{ selectedNodeInfo.childCount }}</strong> 个子知识点?
|
||||
</p>
|
||||
@@ -421,9 +431,9 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<!-- 回忆历史 -->
|
||||
<article class="surface-card" v-if="showHistory && historyRecords.length > 0">
|
||||
<article class="surface-card" v-if="showHistory">
|
||||
<h3>回忆历史</h3>
|
||||
<div class="history-list">
|
||||
<div v-if="historyRecords.length > 0" class="history-list">
|
||||
<div
|
||||
v-for="record in historyRecords"
|
||||
:key="record.id"
|
||||
@@ -437,6 +447,7 @@ onMounted(() => {
|
||||
<span class="history-detail">✅{{ record.matchedCount }} ❌{{ record.missedCount }} ➕{{ record.extraCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无回忆记录" :image-size="48" />
|
||||
</article>
|
||||
|
||||
<!-- 折叠时引导:告知用户展开标准导图 -->
|
||||
@@ -478,18 +489,16 @@ onMounted(() => {
|
||||
<div class="panel-actions">
|
||||
<el-button
|
||||
v-if="hasCompared"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="resetComparison"
|
||||
>
|
||||
返回完整导图
|
||||
</el-button>
|
||||
<el-button size="small" @click="standardExpanded = !standardExpanded">
|
||||
<el-button @click="standardExpanded = !standardExpanded">
|
||||
{{ standardExpanded ? "折叠" : "展开" }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="standardExpanded"
|
||||
size="small"
|
||||
type="warning"
|
||||
:loading="regenerating"
|
||||
@click="handleRegenerate"
|
||||
@@ -498,7 +507,6 @@ onMounted(() => {
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="standardExpanded && !editingStandard"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="startEditStandard"
|
||||
>
|
||||
@@ -610,11 +618,13 @@ onMounted(() => {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.focus-confirm-text {
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.surface-card {
|
||||
padding: 20px 22px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-soft, #e0e0e0);
|
||||
}
|
||||
|
||||
.surface-card h3 {
|
||||
@@ -855,11 +865,6 @@ onMounted(() => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.scope-hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary, #999);
|
||||
}
|
||||
|
||||
.session-badge {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { getFragmentsBySession, updateFragments } from "@/api/reportFragments";
|
||||
import { getExpectation, getReportDraft, getTaskFragments, getTaskReports, upsertExpectation } from "@/api/studySessions";
|
||||
import router from "@/router";
|
||||
import MarkdownRenderer from "@/components/MarkdownRenderer.vue";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
|
||||
const {
|
||||
fragmentsDialogVisible,
|
||||
@@ -151,28 +152,7 @@ const taskInfo = ref({
|
||||
const editingMaterial = ref(false);
|
||||
const editMaterialContent = ref("");
|
||||
const savingMaterial = ref(false);
|
||||
const materialHtml = computed(() => {
|
||||
const raw = taskInfo.value.materialUrl || "";
|
||||
if (!raw.trim()) return "";
|
||||
let html = raw;
|
||||
const links: string[] = [];
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m: string, text: string, url: string) => {
|
||||
const tag = `<a href="${url.replace(/"/g, """)}" target="_blank" rel="noopener">${text}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
const clean = url.replace(/[.。,,;;!!??)】」』\]]+$/, "");
|
||||
const tag = `<a href="${clean.replace(/"/g, """)}" target="_blank" rel="noopener">${clean}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/\n/g, "<br>");
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
html = html.replace(`__LINK_${i}__`, links[i]);
|
||||
}
|
||||
return html;
|
||||
});
|
||||
const materialHtml = computed(() => renderMarkdown(taskInfo.value.materialUrl || ""));
|
||||
|
||||
function startEditMaterial() {
|
||||
editMaterialContent.value = taskInfo.value.materialUrl;
|
||||
@@ -663,6 +643,7 @@ onUnmounted(() => {
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="expectationContent = expectationSaved; expectationDialogVisible = true"
|
||||
>
|
||||
修改
|
||||
@@ -749,12 +730,12 @@ onUnmounted(() => {
|
||||
/>
|
||||
<div class="fragment-edit-actions">
|
||||
<el-button size="small" @click="cancelEditFragment">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="savingFragment" @click="saveEditFragment(fragment.id)">保存</el-button>
|
||||
<el-button size="small" type="success" :loading="savingFragment" @click="saveEditFragment(fragment.id)">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="fragment-content">{{ fragment.content }}</span>
|
||||
<el-button size="small" @click="startEditFragment(fragment)">编辑</el-button>
|
||||
<el-button text type="primary" size="small" @click="startEditFragment(fragment)">编辑</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</article>
|
||||
@@ -1104,10 +1085,6 @@ onUnmounted(() => {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.action-row .el-button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fragments-card {
|
||||
padding: 20px;
|
||||
}
|
||||
@@ -1165,20 +1142,12 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.top-head {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-row .el-button {
|
||||
width: 100%;
|
||||
.summary-toolbar .el-button {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,14 +1240,4 @@ onUnmounted(() => {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.history-content {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-primary);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.report-item .history-content {
|
||||
margin: 0;
|
||||
}</style>
|
||||
</style>
|
||||
|
||||
+14
-38
@@ -5,6 +5,8 @@ import router from "@/router";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { getReviewTaskStatsByTask } from "@/api/review";
|
||||
import { getActiveSession } from "@/api/studySessions";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { applicationStatusOptions } from "@/utils/taskApplication";
|
||||
|
||||
import {
|
||||
getPriorityWeights,
|
||||
@@ -44,41 +46,10 @@ const taskApplications = ref<TaskApplication[]>([]);
|
||||
const applicationsLoading = ref(false);
|
||||
const appUrlTitles = ref<Record<number, string>>({});
|
||||
|
||||
const applicationStatusOptions: { label: string; value: TaskApplication["status"] }[] = [
|
||||
{ label: "待应用", value: "TODO" },
|
||||
{ label: "进行中", value: "DOING" },
|
||||
{ label: "已完成", value: "DONE" },
|
||||
];
|
||||
|
||||
const selectedTask = computed(() =>
|
||||
tasks.value.find((item) => item.taskId === selectedTaskId.value) || null
|
||||
);
|
||||
|
||||
const escapeHtml = (s: string) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
const escapeAttr = (s: string) => s.replace(/"/g, """).replace(/&/g, "&");
|
||||
|
||||
function renderMarkdown(raw: string): string {
|
||||
if (!raw.trim()) return "";
|
||||
let html = raw;
|
||||
const links: string[] = [];
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m: string, text: string, url: string) => {
|
||||
const tag = `<a href="${escapeAttr(url)}" target="_blank" rel="noopener">${escapeHtml(text)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
const clean = url.replace(/[.。,,;;!!???)]」》]]+$/, "");
|
||||
const tag = `<a href="${escapeAttr(clean)}" target="_blank" rel="noopener">${escapeHtml(clean)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/\n/g, "<br>");
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
html = html.replace(`__LINK_${i}__`, links[i]);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
const materialHtml = computed(() => renderMarkdown(selectedTask.value?.materialUrl || ""));
|
||||
|
||||
const formatEffectiveTime = (seconds: number): string => {
|
||||
@@ -457,12 +428,12 @@ onMounted(() => {
|
||||
|
||||
<aside class="surface-card action-card">
|
||||
<div class="block-title">常用操作</div>
|
||||
<el-button size="large" @click="fetchTasks" :loading="loading">刷新列表</el-button>
|
||||
<el-button @click="fetchTasks" :loading="loading">刷新列表</el-button>
|
||||
<el-button type="success" size="large" @click="startTask">开始任务</el-button>
|
||||
<el-button size="large" @click="addTask">添加任务</el-button>
|
||||
<el-button size="large" @click="changeTask">更新任务</el-button>
|
||||
<el-button size="large" @click="openWeightsDialog">权重配置</el-button>
|
||||
<el-button type="danger" size="large" @click="removeTask">删除任务</el-button>
|
||||
<el-button @click="addTask">添加任务</el-button>
|
||||
<el-button @click="changeTask">更新任务</el-button>
|
||||
<el-button @click="openWeightsDialog">权重配置</el-button>
|
||||
<el-button type="danger" @click="removeTask">删除任务</el-button>
|
||||
</aside>
|
||||
</main>
|
||||
</div>
|
||||
@@ -791,8 +762,13 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.page-head {
|
||||
flex-direction: column;
|
||||
.weight-row {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.weight-label {
|
||||
width: 64px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.action-card {
|
||||
|
||||
+12
-60
@@ -11,6 +11,8 @@ import {
|
||||
type TaskApplication,
|
||||
} from "@/api/tasks";
|
||||
import { getUrlTitle } from "@/utils/fetchTitle";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { applicationStatusOptions } from "@/utils/taskApplication";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -32,11 +34,6 @@ const priority = ref({
|
||||
});
|
||||
|
||||
const priorityOptions = [0, 1, 2, 3, 4, 5];
|
||||
const applicationStatusOptions: { label: string; value: TaskApplication["status"] }[] = [
|
||||
{ label: "待应用", value: "TODO" },
|
||||
{ label: "进行中", value: "DOING" },
|
||||
{ label: "已完成", value: "DONE" },
|
||||
];
|
||||
|
||||
const applications = ref<TaskApplication[]>([]);
|
||||
const applicationLoading = ref(false);
|
||||
@@ -276,56 +273,20 @@ const isMobile = computed(() => screenWidth.value <= 900);
|
||||
// 学习材料 Markdown 预览
|
||||
const showPreview = ref(false);
|
||||
const materialPreview = ref("");
|
||||
const previewLoading = ref(false);
|
||||
|
||||
const escapeHtml = (s: string) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
const escapeAttr = (s: string) => s.replace(/"/g, """).replace(/&/g, "&");
|
||||
|
||||
function renderMarkdown(raw: string, urlTitles: Record<string, string> = {}): string {
|
||||
if (!raw.trim()) return "";
|
||||
let html = raw;
|
||||
// 1) [text](url) → <a> 占位,防止后续裸 URL 匹配进属性里
|
||||
const links: string[] = [];
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m: string, text: string, url: string) => {
|
||||
const tag = `<a href="${escapeAttr(url)}" target="_blank" rel="noopener">${escapeHtml(text)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
// 2) 裸 URL → <a> 占位
|
||||
html = html.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
const clean = url.replace(/[.。,,;;!!??)】」』\]]+$/, "");
|
||||
const label = urlTitles[clean] || url;
|
||||
const tag = `<a href="${escapeAttr(clean)}" target="_blank" rel="noopener">${escapeHtml(label)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
// 3) 换行
|
||||
html = html.replace(/\n/g, "<br>");
|
||||
// 4) 还原占位
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
html = html.replace(`__LINK_${i}__`, links[i]);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
async function previewMaterial() {
|
||||
showPreview.value = true;
|
||||
const raw = materialUrl.value || "";
|
||||
if (!raw.trim()) { materialPreview.value = ""; return; }
|
||||
previewLoading.value = true;
|
||||
try {
|
||||
const titles: Record<string, string> = {};
|
||||
const bareUrls = new Set<string>();
|
||||
raw.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
bareUrls.add(url.replace(/[.。,,;;!!??)】」』\]]+$/, ""));
|
||||
return url;
|
||||
});
|
||||
const results = await Promise.all([...bareUrls].map(async (u) => ({ u, t: await getUrlTitle(u) })));
|
||||
results.forEach(({ u, t }) => { titles[u] = t; });
|
||||
materialPreview.value = renderMarkdown(raw, titles);
|
||||
} finally {
|
||||
previewLoading.value = false;
|
||||
}
|
||||
const titles: Record<string, string> = {};
|
||||
const bareUrls = new Set<string>();
|
||||
raw.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
bareUrls.add(url.replace(/[.。,,;;!!??)】」』\]]+$/, ""));
|
||||
return url;
|
||||
});
|
||||
const results = await Promise.all([...bareUrls].map(async (u) => ({ u, t: await getUrlTitle(u) })));
|
||||
results.forEach(({ u, t }) => { titles[u] = t; });
|
||||
materialPreview.value = renderMarkdown(raw, titles);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -410,7 +371,7 @@ async function previewMaterial() {
|
||||
<div class="group" v-if="isUpdateMode" v-loading="applicationLoading">
|
||||
<div class="application-header">
|
||||
<h3>应用场景</h3>
|
||||
<el-button type="primary" @click="openApplicationDialog()">添加应用场景</el-button>
|
||||
<el-button type="success" @click="openApplicationDialog()">添加应用场景</el-button>
|
||||
</div>
|
||||
<div class="application-list" v-if="applications.length > 0">
|
||||
<div class="application-item" v-for="item in applications" :key="item.id">
|
||||
@@ -608,15 +569,6 @@ async function previewMaterial() {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-row .el-button {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.application-main {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -12,7 +12,6 @@ interface SessionGroup {
|
||||
taskNum: string;
|
||||
content: string;
|
||||
hasReport: boolean;
|
||||
fragmentCount: number;
|
||||
navigateType: string;
|
||||
navigateId: number;
|
||||
}
|
||||
@@ -43,7 +42,6 @@ const sessionGroups = computed<SessionGroup[]>(() => {
|
||||
taskNum: first.taskNum,
|
||||
content,
|
||||
hasReport: !!report,
|
||||
fragmentCount: fragments.length,
|
||||
navigateType: report ? "report" : "fragment",
|
||||
navigateId: report ? report.id : (fragments[0]?.id ?? 0),
|
||||
});
|
||||
@@ -195,6 +193,7 @@ onMounted(() => {
|
||||
v-model="recallCard.visible"
|
||||
:title="recallCard.group?.taskName || '回忆一下'"
|
||||
width="560px"
|
||||
class="recall-card-dialog"
|
||||
>
|
||||
<template v-if="recallCard.group">
|
||||
<p class="recall-question">
|
||||
@@ -216,11 +215,11 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button v-if="!recallCard.revealed" type="success" @click="revealRecallContent">
|
||||
<el-button v-if="!recallCard.revealed" type="success" plain @click="revealRecallContent">
|
||||
回忆好了,展开对照
|
||||
</el-button>
|
||||
<el-button v-else type="success" @click="openRecallDetail">进入详情页</el-button>
|
||||
<el-button type="success" plain @click="goToRecallFromCard">前往回忆复习</el-button>
|
||||
<el-button v-else type="success" plain @click="openRecallDetail">进入详情页</el-button>
|
||||
<el-button type="success" @click="goToRecallFromCard">前往回忆复习</el-button>
|
||||
<el-button @click="recallCard.visible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -456,4 +455,14 @@ onMounted(() => {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.recall-card-dialog :deep(.el-dialog__footer) {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.recall-card-dialog :deep(.el-dialog__footer .el-button) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,6 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
const remainingTime = ref(25 * 60 * 1000);
|
||||
const timerRunning = ref(false);
|
||||
const timerIsOver = ref(false);
|
||||
const audioActivated = ref(false);
|
||||
|
||||
let timerInterval: number;
|
||||
const audio = new Audio(audioUrl);
|
||||
@@ -65,10 +64,8 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
await audio.play();
|
||||
audio.pause();
|
||||
audio.currentTime = 0;
|
||||
audioActivated.value = true;
|
||||
return true;
|
||||
} catch {
|
||||
audioActivated.value = false;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -82,7 +79,6 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
await audio.play();
|
||||
audio.pause();
|
||||
audio.currentTime = 0;
|
||||
audioActivated.value = true;
|
||||
resolve(true);
|
||||
} catch {
|
||||
resolve(false);
|
||||
@@ -95,7 +91,6 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
return {
|
||||
timerMinutes,
|
||||
timerSeconds,
|
||||
remainingTime,
|
||||
timerRunning,
|
||||
timerIsOver,
|
||||
runCountdown,
|
||||
@@ -103,6 +98,5 @@ export function useTimer(audioUrl: string = '/resource/notification.mp3') {
|
||||
clear,
|
||||
checkAudioPermission,
|
||||
requestAudioPermission,
|
||||
audioActivated,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
|
||||
<path
|
||||
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
|
||||
<path
|
||||
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
|
||||
<path
|
||||
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
|
||||
<path
|
||||
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -1,19 +0,0 @@
|
||||
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
|
||||
<template>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-hidden="true"
|
||||
role="img"
|
||||
class="iconify iconify--mdi"
|
||||
width="24"
|
||||
height="24"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
|
||||
fill="currentColor"
|
||||
></path>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
export const escapeHtml = (s: string) =>
|
||||
s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
|
||||
export const escapeAttr = (s: string) => s.replace(/"/g, """).replace(/&/g, "&");
|
||||
|
||||
export function renderMarkdown(raw: string, urlTitles: Record<string, string> = {}): string {
|
||||
if (!raw.trim()) return "";
|
||||
let html = raw;
|
||||
const links: string[] = [];
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m: string, text: string, url: string) => {
|
||||
const tag = `<a href="${escapeAttr(url)}" target="_blank" rel="noopener">${escapeHtml(text)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/https?:\/\/[^\s)\u3001\uFF09\u300D\u300B<>]+/g, (url) => {
|
||||
const clean = url.replace(/[.。,,;;!!??)】」』\]]+$/, "");
|
||||
const label = urlTitles[clean] || clean;
|
||||
const tag = `<a href="${escapeAttr(clean)}" target="_blank" rel="noopener">${escapeHtml(label)}</a>`;
|
||||
links.push(tag);
|
||||
return `__LINK_${links.length - 1}__`;
|
||||
});
|
||||
html = html.replace(/\n/g, "<br>");
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
html = html.replace(`__LINK_${i}__`, links[i]);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { TaskApplication } from "@/api/tasks";
|
||||
|
||||
export const applicationStatusOptions: { label: string; value: TaskApplication["status"] }[] = [
|
||||
{ label: "待应用", value: "TODO" },
|
||||
{ label: "进行中", value: "DOING" },
|
||||
{ label: "已完成", value: "DONE" },
|
||||
];
|
||||
Reference in New Issue
Block a user