31 Commits

Author SHA1 Message Date
yuzhiran c2ba810a02 fix: use onShow lifecycle to refresh login state in member center
1. member.vue: added onShow to refresh login state when returning from login page

2. manifest.json: bump to v1.0.15

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 21:23:20 +08:00
yuzhiran 3f1239c35e fix: add network error detection and timeout for mini program JSAPI payment
1. member.vue: check for res.statusCode === 0 (network failure) before accessing data, add 30s timeout

2. manifest.json: bump to v1.0.14

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 20:54:42 +08:00
yuzhiran 1be5b34906 chore: bump version to 1.0.13
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 20:39:56 +08:00
yuzhiran c58bb27575 fix: admin page reactive import + member payment toast show real error
1. admin.vue: 添加缺失的reactive导入,修复管理后台只显示标题不显示功能的问题

2. member.vue: 支付失败toast改为显示后端真实错误信息,而非硬编码'创建订单失败'

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 20:39:49 +08:00
yuzhiran e0de29fdd0 fix: AI LLM backup model not producing content; add retry for thinking models
- Replace backup model stepfun-ai/step-3.5-flash with meta/llama-3.1-8b-instruct
  (stepfun is a thinking model that uses all tokens on reasoning and
  never outputs content, causing all 3 fallthroughs to fail)
- Add retry with doubled max_tokens when primary model returns empty
  content (deepseek-v4-flash thinking can exhaust token budget)
- Increase backup timeout to 120s and max_tokens to min 2048
- Move callApi error handling to return null instead of throw for
  cleaner fallthrough logic with timeout logging
2026-06-18 19:42:40 +08:00
yuzhiran 6a3cc8544e fix: handle WeChat Pay public key mode in callback
- verifyAndDecrypt now processes decryption even when signature
  verification fails (decryption key is separate from signature key)
- Notify handler uses returnRaw flag to always decrypt resource
- Loud log when pub_key.pem verification fails, directs admin
  to download correct public key from merchant platform
2026-06-18 19:36:19 +08:00
yuzhiran c161ffbc3c feat: payment refund support + admin payment management
- Add refund()/queryRefund()/downloadPlatformCerts() to WechatPayService
- Add refundId field to PaymentOrder schema
- Fix WeChat Pay callback to auto-download platform certs on verification failure
- Fix syncOrder to handle sprint plan properly
- Add admin refund, refund-query, order-detail endpoints
- Add refund UI (button, modal, query) to admin.vue orders tab
- Fix member.vue MP payment: pass outTradeNo instead of prepayId to pollPayResult
2026-06-18 19:33:10 +08:00
yuzhiran 7e1bf669ab fix: show toast when clicking login without agreeing to privacy terms
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:54:44 +08:00
yuzhiran bed9dce943 chore: bump version to 1.0.12
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:48:27 +08:00
yuzhiran 4ac42f6575 fix: privacy policy compliance - checkbox must be manually checked, add WeChat privacy API
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:46:57 +08:00
yuzhiran f72312ea52 docs: update with production mode, test accounts, admin auto-verify
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:21:48 +08:00
yuzhiran 7cf4636b8c fix: auto-verify admin on mount (onMounted doVerify)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:21:41 +08:00
yuzhiran 27e4d06da7 fix: show devCode modal in email login for non-production mode
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-18 18:21:34 +08:00
yuzhiran e049be280e fix: auto-copy avatars on build, show masked user ID on profile page 2026-06-18 17:58:54 +08:00
yuzhiran b9651a9ff3 chore: hide company-bank and internship entries from homepage (content empty) 2026-06-18 17:44:11 +08:00
yuzhiran 54c21e2953 refactor: rewrite company-bank and internship pages
- bank.vue: Composition API, design tokens, 2-col grid, better UX
- internship.vue: search bar, category tabs, card list layout
2026-06-18 17:27:37 +08:00
yuzhiran 0616fd955c fix: homepage layout optimization (2-col grid, guest CTA, daily question for guests)
- Unified feature grid to consistent 2-column layout
- Improved hero guest card with benefit tags
- Show daily question section for guests with login prompt
- Added AGENTS.md: H5 deployment docs, git remote, build gotchas
2026-06-18 15:53:11 +08:00
wlt df1b37fe79 feat: add positions management admin tab + career advisor homepage entry
- admin.vue: new '岗位' tab with CRUD list/modal/api functions/styles
- index.vue: add AI择业顾问 entry card linking to career page
- Backend CRUD endpoints already exist, no backend changes needed
2026-06-18 15:13:29 +08:00
wlt 103dbd3b34 feat: AI岗位专区 — 5个AI岗位置顶 + 首页分组展示
- schema: HotPosition 新增 category 字段 (ai/traditional)
- positions: 5 AI岗位 (AI算法/大模型应用/Prompt/AI产品/AI运维) + 7传统岗位
- frontend: 首页拆分 "🔥 AI热门岗位" 置顶高亮 + "更多岗位" 折叠
- ai服务: 新增 primaryFallbackModel (sensenova-6.7-flash-lite) 降级链路
2026-06-17 13:57:18 +08:00
wlt a5c4bcb821 feat: AI 择业顾问 MVP — 专业分析 + 岗位匹配 + 多轮对话
- backend: career-advice module with analyze/chat/positions endpoints
- frontend: career.vue page with profile form, AI advice, recommendation cards
- config/api/pages/user.vue: full integration into existing flow
- docs: PROJECT-STATUS v4.5, FEATURE-LIST v4.3, ROADMAP v4.3
- AGENTS.md: updated module count and career link paths
2026-06-17 10:32:23 +08:00
wlt 4cd889c081 feat: interview review module with whisper.cpp ASR + AI analysis + frontend page
New backend module 'interview-review' provides:
- Audio upload (50MB limit, MP3/M4A/WAV/AAC/OGG/MP4/WebM)
- Text transcript submission
- whisper.cpp local ASR integration (tiny + base models)
- AI analysis (4-dimension scoring: logic/expression/professionalism/stability)
- Speech analysis (filler words detection, pace, duration)
- Async processing pipeline with status polling
- Graceful fallback to mock ASR when whisper unavailable

New frontend page 'pages/review/review.vue' with 3 modes:
- List mode: review history with status indicators
- Upload mode: audio file upload or text paste
- Report mode: score radar, dimension bars, analysis details

Docs updated: PROJECT-STATUS.md v4.4, FEATURE-LIST.md v4.2, ROADMAP.md v4.2
2026-06-16 18:32:25 +08:00
yuzhiran 96c367e0f8 feat: latest code update 2026-06-16 13:18:36 +08:00
yuzhiran 5a49d15696 fix: login state refresh, hero layout, default avatar consistency 2026-06-15 11:04:00 +08:00
yuzhiran 07c6557454 fix: return 200 instead of 201 for all login endpoints (NestJS default) 2026-06-15 10:42:31 +08:00
yuzhiran 18c50726cd fix: WeChat login Content-Type header, ASR tiny model, re-upload mini-program v1.0.11 2026-06-15 10:00:22 +08:00
yuzhiran 4fa620f0a2 fix: whisper path + PNG face avatar 2026-06-13 11:26:46 +08:00
yuzhiran 112884a504 fix: PNG face avatar + whisper ASR 2026-06-13 11:04:52 +08:00
yuzhiran 93ab79d200 fix: css-only face avatar for mini-program, voice input + ASR 2026-06-12 21:47:17 +08:00
yuzhiran 8191cf4b41 feat: realistic face avatar + voice input + ASR endpoint 2026-06-12 15:32:04 +08:00
yuzhiran 6fe84b6ef8 feat: add resume entry card, rename interview to AI数字人面试 2026-06-12 14:45:49 +08:00
yuzhiran 087fb1d400 fix: avatar mode default on, show AI text in chat 2026-06-12 14:45:36 +08:00
75 changed files with 5755 additions and 947 deletions
@@ -0,0 +1,11 @@
{
"sessionID": "ses_130b21833ffe0epQvGBjpGtogZ",
"updatedAt": "2026-06-17T05:54:06.381Z",
"sources": {
"background-task": {
"state": "active",
"reason": "2 background task(s) active",
"updatedAt": "2026-06-17T05:54:06.381Z"
}
}
}
@@ -0,0 +1,10 @@
{
"sessionID": "ses_15492f54bffepl01q9FkaRyN28",
"updatedAt": "2026-06-16T01:20:56.855Z",
"sources": {
"background-task": {
"state": "idle",
"updatedAt": "2026-06-16T01:20:56.855Z"
}
}
}
+304
View File
@@ -0,0 +1,304 @@
# 职引 (ZhiYin) — AGENTS.md
> AI 模拟面试教练,专注校招。NestJS + uni-app(Vue3) + MongoDB。
---
## 一、项目结构
```
zhiyin/
├── backend/ # NestJS 10.x 后端 (端口 3006, 前缀 /api)
│ └── src/
│ ├── main.ts # 入口:DOMMatrix polyfill → NestFactory → CORS → ValidationPipe
│ ├── app.module.ts # 根模块:导入全部子模块 + JWT/Throttler/Mongoose
│ ├── common/
│ │ ├── guards/ # JwtAuthGuard (全局), admin.guard.ts
│ │ ├── strategies/ # JwtStrategy
│ │ ├── decorators/ # @CurrentUser, @Public()
│ │ └── filters/ # AllExceptionsFilter
│ └── modules/ # 20 个模块(详见下文)
├── zhiyin-app/ # uni-app 3.x 前端 (H5 + 微信小程序)
│ └── src/
│ ├── pages/ # 20 个页面 (pages.json 路由)
│ ├── services/api.ts # API 调用封装 (uni.request)
│ ├── config.ts # 端点定义 + api() 辅助函数
│ └── App.vue # 设计 Token + 全局样式
└── docs/ # 产品/架构/部署/路线图文档
```
### 后端模块清单
| 模块 | 职责 |
|------|------|
| `user` | 手机/邮箱/密码/微信登录, JWT, 配额 |
| `interview` | AI 面试核心(多轮对话 + 评分 + 报告 + 进度) |
| `ai` | AI 调用封装(deepseek-v4-flash 主 + step-3.5-flash 备) |
| `analyze` | 简历诊断 / 优化 / 技能缺口分析 |
| `resume` | 简历 CRUD |
| `member` | 会员套餐 / 权益扣减 |
| `payment` | 微信支付 v3Native + JSAPI + 回调) |
| `progress` | 进步轨迹雷达图 / 打卡日历 / 行业基准 / 岗位匹配 |
| `contribution` | 面经贡献 + 公司题库(数据飞轮核心) |
| `schedule` | 定时任务:VIP 过期降级、每日一题推送、微信 token 刷新 |
| `share` | 分享链接生成 / 访问追踪 / 积分奖励 |
| `tts` | 语音合成(TTS |
| `admin` | 管理后台 API |
| `positions` | 热门岗位维护 |
| `interview-review` | 面试复盘(音频上传 -> whisper.cpp ASR -> AI 评析 -> 口语分析) |
|`career-advice` | AI 择业顾问:专业分析 + 岗位匹配 + 推荐对话 |
| `upload` | 文件上传(PDF/图片) |
| `email` | 邮件发送 |
| `daily-question` | 每日一题 API |
| `schemas/` | 共享 Schemapricing 定价、site-config、company-bank 等) |
### 前端页面(3 Tab + 18 子页)
- **Tab1 面试**: pages/index/index → interview → report → career
- **Tab2 面经**: pages/history/history → contribute → company-bank
- **Tab3 我的**: pages/user/user → login/member/progress/resume/review/career/about/agreement/privacy/admin/share
- 其他: internship, result
---
## 二、架构约定(必须遵守)
### 模块模式
每个业务模块遵循 NestJS 标准结构:
```
模块名/
├── 模块名.module.ts # @Module({ imports: [MongooseModule.forFeature(...)], controllers, providers, exports })
├── 模块名.controller.ts # @Controller('prefix'),注入 service
├── 模块名.service.ts # @Injectable(),注入 Model
└── 模块名.schema.ts # @Schema({ timestamps: true })class + SchemaFactory
```
### 认证体系
- **全局守卫**: `JwtAuthGuard` 默认拦截所有路由(在 `app.module.ts``APP_GUARD` 注册)
- **白名单**: 公开接口加 `@Public()` 装饰器(登录、注册、支付回调、分享访问等)
- **管理员**: 管理接口加 `@UseGuards(AdminGuard)`admin controller 内部)
- **当前用户**: `@CurrentUser('userId')` 从 JWT payload 提取用户 ID
- **JWT 过期**: 7 天,在 `app.module.ts` 和每个模块的 `JwtModule.register` 中配置
### 安全硬性要求
1. **JWT_SECRET 必须来自环境变量**,不允许任何硬编码 fallback(已有历史漏洞修复)
2. **所有外部输入**经过 class-validator `ValidationPipe({ whitelist: true, forbidNonWhitelisted: true })`
3. **修改用户额度/积分**使用 `findOneAndUpdate + $inc` 原子操作,禁止 read-modify-write
4. **支付订单查询**校验 userId 归属,防止 IDOR
5. **CORS** 生产环境必须配置白名单(当前在 `main.ts` 中从 `CORS_ORIGINS` 环境变量读取)
6. **用户内容输出到响应**时避免泄漏敏感信息(验证码、密钥等)
7. **MongoDB 查询**中对外部输入的字符串做特殊字符转义(尤其在 admin 模块)
### AI 调用
- 主模型: `opencode-go` (deepseek-v4-flash)
- 备用模型: NVIDIA (stepfun-ai/step-3.5-flash)
- 主用不可用时自动切换(在 `ai` 模块处理)
- 环境变量: `AI_PRIMARY_KEY`, `AI_BACKUP_KEY`
### 支付(微信支付 v3
- Native 支付(H5 扫码): `POST /payment/create`
- JSAPI 支付(小程序内): `POST /payment/jsapi`
- 支付回调: `POST /payment/notify`@Public,验签 + 解密 + 自动开会员)
- 需要微信商户证书文件(通过 postbuild 复制到 dist
---
## 三、开发命令
### 后端
```bash
# 路径: backend/
npm run start:dev # 开发模式(watch
npm run build # 编译到 dist/
npm test # 单元测试(43 个,jest --forceExit --detectOpenHandles
npm run test:watch # 监听模式
npm run test:cov # 覆盖率报告
npm run test:e2e # 集成测试(需 MongoDB 运行)
npm run test:browser # Playwright API 测试(需后端运行)
```
### 前端
```bash
# 路径: zhiyin-app/
npm run dev:mp-weixin # 微信小程序开发(uni -p mp-weixin
npm run build:mp-weixin # 构建小程序(输出 dist/build/mp-weixin/
npm run dev:h5 # H5 开发(端口 8888,带 /api 代理到 localhost:3006
npm run build:h5 # 构建 H5(输出 dist/build/h5/
npm test # 前端单元测试(vitest,7 个)
```
### 构建检查
```bash
# 后端构建(注意 OOM:需 NODE_OPTIONS="--max-old-space-size=2048"
cd backend && NODE_OPTIONS="--max-old-space-size=2048" npx nest build
```
### 部署后端
```bash
cd backend && npx nest build
cp -rf dist/* /www/wwwroot/server/zhiyin/backend/dist/
cp -r certs /www/wwwroot/server/zhiyin/backend/dist/src/certs
pm2 restart yhl-backend
sleep 3 && curl -s http://localhost:3006/api/user/wx-login -X POST -H "Content-Type: application/json" -d '{"code":"test"}'
```
### 部署前端 H5
```bash
cd zhiyin-app && npx uni build
rm -rf /www/wwwroot/zhiyin.yzrcloud.cn/assets
cp -r dist/build/h5/index.html /www/wwwroot/zhiyin.yzrcloud.cn/
cp -r dist/build/h5/assets /www/wwwroot/zhiyin.yzrcloud.cn/
chown -R www:www /www/wwwroot/zhiyin.yzrcloud.cn/index.html /www/wwwroot/zhiyin.yzrcloud.cn/assets
# 验证无缺失文件
grep -oP '["'"'"']([a-zA-Z0-9_-]+\.[a-z]+(\.js|\.css|\.png|\.svg))["'"'"']' /www/wwwroot/zhiyin.yzrcloud.cn/assets/index-*.js | sort -u
```
### 小程序上传
```bash
cd zhiyin-app && npm run build:mp-weixin && node scripts/upload-mp.js
```
---
## 四、测试注意事项
- **e2e 测试**需要 MongoDB 运行 + `jest-setup.ts` 设置测试 JWT_SECRET
- `payment.controller.spec.ts` 涉及微信支付,需 mock 外部依赖
- `benchmark.service.spec.ts` 涉及行业基准计算
- Playwright 测试需要后端已在运行(测试 `api.browser.spec.ts`
- 测试文件位置:`backend/src/**/*.spec.ts`(单元),`backend/test/*.e2e-spec.ts`(集成),`backend/test/*.browser.spec.ts`(浏览器)
- 前端测试:`zhiyin-app/src/**/*.spec.ts`vitest + jsdom
---
## 五、定时任务(3 个 cron,在 schedule 模块)
| 服务 | 周期 | 职责 |
|------|------|------|
| `VipExpiryService` | 每日 00:00 | 扫描过期 VIP 并降级为 free 计划 |
| `DailyQuestionPushService` | 每日 09:00 | 通过微信订阅消息推送每日一题(需配置模板 ID) |
| `WechatTokenService` | 每 2 小时 | 刷新微信 access_token(缓存到 Redis |
---
## 六、项目状态与开发阶段
**当前**: Phase 0.5 完成,Phase 1MVP 上线)进行中
| 阶段 | 状态 | 关键交付 |
|------|------|---------|
| Phase 0: 战略升级 | ✅ 完成 | 定价重构(免费 + ¥19.9/月),三层壁垒设计 |
| Phase 0.5: 壁垒构建 | ✅ 完成 | 数据飞轮(面经贡献+题库),留存入围(进步轨迹+打卡日历+每日一题) |
| Phase 1: MVP 上线 | 🚧 当前 | 小程序 v1.0.11 已上传、H5 已部署、生产模式已启用、SMTP 邮箱验证码已配置 |
| Phase 1.5: 商业化 | 📋 规划 | 冲刺版 ¥49.9/月、每日一题定时推送、PMF 验证 |
| Phase 2: 增强 + 题库 | 📋 规划 | 50+ 校招岗位、技能缺口分析、公司真题库建设 |
| Phase 3: 秋招冲刺 | 📋 规划 | 高校合作、B 端服务、KOC 推广 |
详细产品规划见 `docs/PRODUCT-PLAN.md`,路线图见 `docs/ROADMAP.md`
---
## 七、环境变量
### 后端(`backend/.env`,不提交 git,在 `.gitignore` 中)
```
MONGODB_URI=mongodb://localhost:27017/zhiyin
JWT_SECRET=your-strong-secret-at-least-32-chars
NODE_ENV=production
PORT=3006
AI_PRIMARY_KEY=xxx
AI_BACKUP_KEY=xxx
WECHAT_APPID=wxf466b3c3bc411ffc
WECHAT_MCHID=xxx
WECHAT_API_KEY=xxx
WECHAT_SERIAL_NO=xxx
WECHAT_PRIVATE_KEY_PATH=/path/to/apiclient_key.pem
WX_DAILY_QUESTION_TMPL=微信订阅消息模板 ID
CORS_ORIGINS=http://localhost:8888,https://zhiyin.yzrcloud.cn
EMAIL_HOST=smtp.qiye.aliyun.com
EMAIL_PORT=465
EMAIL_SECURE=true
EMAIL_USER=contact@yuzhiran.com
EMAIL_PASSWORD=xxx
EMAIL_FROM=宇之然AI磁场 <contact@yuzhiran.com>
WHISPER_CPP_PATH=/home/wlt/whisper.cpp # whisper.cpp 路径
WHISPER_MODEL=base # ASR 模型:tiny / base / small
WHISPER_LANGUAGE=zh # ASR 语言
WHISPER_THREADS=4 # ASR CPU 线程数
```
### 前端(`zhiyin-app/.env.production`,已提交 git
```
VITE_API_BASE_URL=https://zhiyinwx.yzrcloud.cn/api
VITE_APP_NAME=AI磁场
```
---
## 八、测试 / 管理员账号
| 账号 | 密码 | 角色 | 说明 |
|------|------|------|------|
| `13701190814@139.com` | `Zhiyin2024!` | admin | 管理员,可访问管理后台 |
| `test@yzrcloud.cn` | `123456` | user | 测试账号 |
| `test@test.com` | 验证码 `123456` | admin | 旧管理员(dev 模式可用) |
管理后台路径:`/pages/admin/admin`,进入后自动验证管理员身份(`onMounted``doVerify`)。
---
## 九、Git
- 远程仓库: `http://127.0.0.1:2999/txai-dev/zhiyin.git`(本机 Gitea,带 token 认证)
- 默认分支: `master`
- 最新 tag: `v1.0.11`(小程序上传版本号源自 git tag)
---
## 十、技术细节与坑
1. **DOMMatrix polyfill**: `main.ts` 顶部有 pdf-parse 所需的浏览器 API polyfillDOMMatrix / DOMPoint),新增 PDF 相关功能时注意兼容性
2. **postbuild**: `backend/package.json` 中的 `postbuild` 脚本自动复制 `certs/``dist/src/certs/`,这是微信支付证书的必要步骤
3. **微信小程序 appid**: `zhiyin-app/manifest.json``mp-weixin.appid = wxf466b3c3bc411ffc`;开发模式 `appid = __UNI__DEV__`
4. **前端 API 调用**: `zhiyin-app/src/services/api.ts` 封装了 `uni.request`,自动处理 token 注入(从 `uni.getStorageSync('token')`)和 401 过期跳转
5. **前端环境判断**: `config.ts` 中使用 `// #ifdef H5` / `// #ifdef MP-WEIXIN` 条件编译区分 H5 和小程序
6. **API 限流**: 100 次/60 秒(在 `app.module.ts` 中配置),注意避免在定时任务和批量操作中被限
7. **验证码**: 生产模式(`NODE_ENV=production`)使用真实 SMTP 发邮件验证码;非生产模式手机验证码固定为 `123456`、邮件验证码在响应中返回 `devCode`
8. **MongoDB**: 8 个核心集合 + 2 个分享集合
9. **api.ts 陷阱**: 对象字面量必须在 `export const apiService = {``const apiService = { ... export default apiService` 中包裹,否则 uni-app 构建报错 `Expected ";" but found ":"`。git pull 后经常丢失这行声明,需手动补回
10. **H5 构建 assets 清理**: `assets/` 中的旧 hash 文件不能随意删除——`index-*.js`(主 bundle)动态 import 了所有 page chunk,删除仍在引用的文件会导致浏览器 `NS_ERROR_CORRUPTED_CONTENT`
11. **管理后台自动验证**: `admin.vue``onMounted` 自动调用 `doVerify()`,进入后台即检测 JWT 中 `role` 是否为 `admin`,不再需要手动点击"验证管理员身份"按钮
---
## 十一、交付检查清单(每次实施/修改后执行)
### Step 1: 代码评审
- [ ] 是否符合现有模块模式(schema→service→controller→module
- [ ] 是否有多余变量、import、参数
- [ ] 命名是否与项目一致
- [ ] 是否有重复代码或可复用逻辑
### Step 2: 安全评审
- [ ] 外部输入是否有注入风险(HTML、Shell、NoSQL
- [ ] 接口是否正确加了 JWT guard 或 `@Public()`
- [ ] 管理端接口是否有 AdminGuard
- [ ] 修改用户额度/积分是否用 `$inc` 原子操作
- [ ] 敏感信息是否泄漏到响应或日志中
- [ ] 用户内容输出是否做了转义
### Step 3: 性能评审
- [ ] 是否存在 N+1 查询
- [ ] 大表查询是否有索引覆盖
- [ ] 读操作是否该加 `.lean()`
- [ ] 是否有内存泄漏风险(puppeteer 等资源未释放)
### Step 4: 测试验证
```bash
cd backend && NODE_OPTIONS="--max-old-space-size=2048" npx nest build
npm test -- --forceExit --detectOpenHandles
```
### Step 5: LSP 诊断
- [ ] Changed files diagnostics clean
- [ ] 无 `as any` / `@ts-ignore` / `@ts-expect-error`
+7 -1
View File
@@ -25,6 +25,9 @@ import { DailyQuestionModule } from './modules/daily-question/daily-question.mod
import { ScheduleModule } from './modules/schedule/schedule.module' import { ScheduleModule } from './modules/schedule/schedule.module'
import { TtsModule } from './modules/tts/tts.module' import { TtsModule } from './modules/tts/tts.module'
import { PricingModule } from './modules/schemas/pricing.module' import { PricingModule } from './modules/schemas/pricing.module'
import { ShareModule } from './modules/share/share.module'
import { InterviewReviewModule } from './modules/interview-review/interview-review.module'
import { CareerAdviceModule } from './modules/career-advice/career-advice.module'
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin' const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin'
@@ -38,7 +41,7 @@ const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin
}), }),
ThrottlerModule.forRoot([{ ThrottlerModule.forRoot([{
ttl: 60000, ttl: 60000,
limit: 10, limit: 100,
}]), }]),
NestScheduleModule.forRoot(), NestScheduleModule.forRoot(),
UserModule, UserModule,
@@ -58,6 +61,9 @@ const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/zhiyin
ScheduleModule, ScheduleModule,
TtsModule, TtsModule,
PricingModule, PricingModule,
ShareModule,
InterviewReviewModule,
CareerAdviceModule,
], ],
providers: [ providers: [
JwtStrategy, JwtStrategy,
+218 -14
View File
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Body, Query, HttpException, HttpStatus, UseGuards } from '@nestjs/common' import { Controller, Get, Post, Body, Query, Param, HttpException, HttpStatus, UseGuards } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose' import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose' import { Model } from 'mongoose'
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard' import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
@@ -6,9 +6,12 @@ import { AdminGuard } from '../../common/guards/admin.guard'
import { CurrentUser } from '../../common/decorators/current-user.decorator' import { CurrentUser } from '../../common/decorators/current-user.decorator'
import { User, UserDocument } from '../user/user.schema' import { User, UserDocument } from '../user/user.schema'
import { Interview, InterviewDocument } from '../interview/interview.schema' import { Interview, InterviewDocument } from '../interview/interview.schema'
import { Resume, ResumeDocument } from '../resume/resume.schema'
import { PaymentOrder, PaymentOrderDocument } from '../payment/payment-order.schema' import { PaymentOrder, PaymentOrderDocument } from '../payment/payment-order.schema'
import { SiteConfig, SiteConfigDocument } from '../schemas/site-config.schema' import { SiteConfig, SiteConfigDocument } from '../schemas/site-config.schema'
import { ShareRecord, ShareRecordDocument, ShareVisit, ShareVisitDocument } from '../share/share.schema'
import { QuotaService } from '../user/quota.service' import { QuotaService } from '../user/quota.service'
import { PricingService } from '../schemas/pricing.service'
import { WechatPayService } from '../payment/wechat-pay.service' import { WechatPayService } from '../payment/wechat-pay.service'
const VIP_DURATION_DAYS = 30 const VIP_DURATION_DAYS = 30
@@ -21,7 +24,11 @@ export class AdminController {
@InjectModel(Interview.name) private interviewModel: Model<InterviewDocument>, @InjectModel(Interview.name) private interviewModel: Model<InterviewDocument>,
@InjectModel(PaymentOrder.name) private orderModel: Model<PaymentOrderDocument>, @InjectModel(PaymentOrder.name) private orderModel: Model<PaymentOrderDocument>,
@InjectModel(SiteConfig.name) private configModel: Model<SiteConfigDocument>, @InjectModel(SiteConfig.name) private configModel: Model<SiteConfigDocument>,
@InjectModel(ShareRecord.name) private shareModel: Model<ShareRecordDocument>,
@InjectModel(ShareVisit.name) private shareVisitModel: Model<ShareVisitDocument>,
@InjectModel(Resume.name) private resumeModel: Model<ResumeDocument>,
private quotaService: QuotaService, private quotaService: QuotaService,
private pricingService: PricingService,
private wechatPay: WechatPayService, private wechatPay: WechatPayService,
) {} ) {}
@@ -38,13 +45,28 @@ export class AdminController {
@Get('overview') @Get('overview')
async overview() { async overview() {
const [userCount, interviewCount, todayUsers, todayInterviews] = await Promise.all([ const [
userCount, interviewCount, todayUsers, todayInterviews,
resumeCount, paidDownloadCount,
planStats,
] = await Promise.all([
this.userModel.countDocuments().exec(), this.userModel.countDocuments().exec(),
this.interviewModel.countDocuments().exec(), this.interviewModel.countDocuments().exec(),
this.userModel.countDocuments({ createdAt: { $gte: new Date(Date.now() - 24 * 60 * 60 * 1000) } }).exec(), this.userModel.countDocuments({ createdAt: { $gte: new Date(Date.now() - 24 * 60 * 60 * 1000) } }).exec(),
this.interviewModel.countDocuments({ createdAt: { $gte: new Date(Date.now() - 24 * 60 * 60 * 1000) } }).exec(), this.interviewModel.countDocuments({ createdAt: { $gte: new Date(Date.now() - 24 * 60 * 60 * 1000) } }).exec(),
this.resumeModel.countDocuments().exec(),
this.resumeModel.countDocuments({ paidDownload: true }).exec(),
this.userModel.aggregate([
{ $group: { _id: '$plan', count: { $sum: 1 } } },
]).exec(),
]) ])
return { userCount, interviewCount, todayUsers, todayInterviews } const planBreakdown: Record<string, number> = {}
planStats.forEach(p => { planBreakdown[p._id || 'free'] = p.count })
return {
userCount, interviewCount, todayUsers, todayInterviews,
resumeCount, paidDownloadCount,
planBreakdown,
}
} }
@Get('users') @Get('users')
@@ -70,7 +92,12 @@ export class AdminController {
async getInterviews(@Query('page') page = '1', @Query('limit') limit = '20') { async getInterviews(@Query('page') page = '1', @Query('limit') limit = '20') {
const skip = (Math.max(1, +page) - 1) * +limit const skip = (Math.max(1, +page) - 1) * +limit
const [interviews, total] = await Promise.all([ const [interviews, total] = await Promise.all([
this.interviewModel.find().sort({ createdAt: -1 }).skip(skip).limit(+limit).populate('userId', 'phone nickname').lean().exec(), this.interviewModel.find()
.sort({ createdAt: -1 })
.skip(skip).limit(+limit)
.populate('userId', 'phone nickname')
.select('position status totalScore questionCount fillerScore fillerDensity summary createdAt')
.lean().exec(),
this.interviewModel.countDocuments().exec(), this.interviewModel.countDocuments().exec(),
]) ])
return { interviews, total, page: +page } return { interviews, total, page: +page }
@@ -80,14 +107,135 @@ export class AdminController {
async setVip(@Body('userId') targetUserId: string) { async setVip(@Body('userId') targetUserId: string) {
const user = await this.userModel.findById(targetUserId).exec() const user = await this.userModel.findById(targetUserId).exec()
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
const pricing = await this.pricingService.getConfig()
const credits = pricing.plans?.growth?.credits || { interview: 999, resumeOptimize: 20, resumeDownload: 10 }
const expireAt = new Date() const expireAt = new Date()
expireAt.setDate(expireAt.getDate() + VIP_DURATION_DAYS) expireAt.setDate(expireAt.getDate() + (pricing.plans?.growth?.durationDays || VIP_DURATION_DAYS))
user.plan = 'growth' user.plan = 'growth'
user.vipExpireAt = expireAt user.vipExpireAt = expireAt
await this.quotaService.setPlanQuota(targetUserId, 'growth', { interview: 999, resumeOptimize: 20, resumeDownload: 10 }) await this.quotaService.setPlanQuota(targetUserId, 'growth', credits)
return { success: true, plan: 'growth', expireAt } return { success: true, plan: 'growth', expireAt }
} }
@Post('user/credits')
async adjustCredits(@Body('userId') userId: string, @Body('type') type: string, @Body('amount') amount: number) {
if (!userId || !type || amount === undefined) {
throw new HttpException('参数不完整', HttpStatus.BAD_REQUEST)
}
const validTypes = ['interviewCredits', 'resumeOptimizeCredits', 'resumeDownloadCredits', 'shareCredits']
if (!validTypes.includes(type)) {
throw new HttpException('无效的额度类型', HttpStatus.BAD_REQUEST)
}
const result = await this.userModel.findByIdAndUpdate(
userId,
{ $set: { [type]: Math.max(0, Math.round(amount)) } },
).exec()
if (!result) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
return { success: true }
}
@Get('share-records')
async getShareRecords(@Query('page') page = '1', @Query('limit') limit = '20') {
const skip = (Math.max(1, +page) - 1) * +limit
const [list, total] = await Promise.all([
this.shareModel.aggregate([
{ $sort: { createdAt: -1 } },
{ $skip: skip },
{ $limit: +limit },
{
$lookup: {
from: 'users',
localField: 'userId',
foreignField: '_id',
as: 'sharer',
},
},
{ $unwind: { path: '$sharer', preserveNullAndEmptyArrays: true } },
{
$project: {
shareCode: 1,
type: 1,
title: 1,
visitCount: 1,
creditedCount: 1,
isActive: 1,
createdAt: 1,
sharer: { nickname: '$sharer.nickname', phone: '$sharer.phone', _id: '$sharer._id' },
},
},
]).exec(),
this.shareModel.countDocuments().exec(),
])
return { list, total, page: +page }
}
@Get('share-visitors')
async getShareVisitors(@Query('page') page = '1', @Query('limit') limit = '20') {
const skip = (Math.max(1, +page) - 1) * +limit
const [list, total] = await Promise.all([
this.shareVisitModel.aggregate([
{ $sort: { createdAt: -1 } },
{ $skip: skip },
{ $limit: +limit },
{
$lookup: {
from: 'users',
localField: 'sharerId',
foreignField: '_id',
as: 'sharer',
},
},
{ $unwind: { path: '$sharer', preserveNullAndEmptyArrays: true } },
{
$lookup: {
from: 'users',
localField: 'visitorUserId',
foreignField: '_id',
as: 'visitorUser',
},
},
{ $unwind: { path: '$visitorUser', preserveNullAndEmptyArrays: true } },
{
$project: {
credited: 1,
creditedAt: 1,
createdAt: 1,
sharer: { nickname: '$sharer.nickname', phone: '$sharer.phone' },
visitor: { nickname: { $ifNull: ['$visitorUser.nickname', '匿名'] }, phone: { $ifNull: ['$visitorUser.phone', ''] } },
},
},
]).exec(),
this.shareVisitModel.countDocuments().exec(),
])
return { list, total, page: +page }
}
@Get('resumes')
async getResumes(@Query('page') page = '1', @Query('limit') limit = '20') {
const skip = (Math.max(1, +page) - 1) * +limit
const [list, total] = await Promise.all([
this.resumeModel.find()
.sort({ createdAt: -1 })
.skip(skip).limit(+limit)
.populate('userId', 'phone nickname')
.select('title targetPosition version paidDownload createdAt')
.lean().exec(),
this.resumeModel.countDocuments().exec(),
])
return { list, total, page: +page }
}
@Get('user/:id')
async getUserDetail(@Param('id') id: string) {
const user = await this.userModel.findById(id).select('-password -openid').lean().exec()
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
const [interviews, resumes] = await Promise.all([
this.interviewModel.find({ userId: id }).sort({ createdAt: -1 }).limit(10).select('position status totalScore questionCount createdAt').lean().exec(),
this.resumeModel.find({ userId: id }).sort({ createdAt: -1 }).limit(10).select('title targetPosition version paidDownload createdAt').lean().exec(),
])
return { user, interviews, resumes }
}
@Get('admins') @Get('admins')
async getAdmins() { async getAdmins() {
const admins = await this.userModel.find({ role: 'admin' }).select('phone nickname email createdAt isSystemAdmin').lean().exec() const admins = await this.userModel.find({ role: 'admin' }).select('phone nickname email createdAt isSystemAdmin').lean().exec()
@@ -130,14 +278,29 @@ export class AdminController {
if (order.type === 'membership') { if (order.type === 'membership') {
const user = await this.userModel.findById(order.userId).exec() const user = await this.userModel.findById(order.userId).exec()
if (user && user.plan === 'free') { if (user && user.plan === 'free') {
const pricing = await this.pricingService.getConfig()
const planId = order.plan === 'sprint' ? 'sprint' : 'growth'
const planCfg = pricing.plans?.[planId]
const credits = planCfg?.credits || { interview: 999, resumeOptimize: 20, resumeDownload: 10 }
const expireAt = new Date() const expireAt = new Date()
expireAt.setDate(expireAt.getDate() + VIP_DURATION_DAYS) expireAt.setDate(expireAt.getDate() + (planCfg?.durationDays || VIP_DURATION_DAYS))
user.plan = 'growth' user.plan = planId
if (planId === 'sprint') {
user.sprintExpireAt = expireAt
user.sprintRemaining = 10
} else {
user.vipExpireAt = expireAt user.vipExpireAt = expireAt
await this.quotaService.setPlanQuota(order.userId, 'growth', { interview: 999, resumeOptimize: 20, resumeDownload: 10 }) }
await this.quotaService.setPlanQuota(order.userId, planId, credits)
} }
} else { } else {
const credits = { interview: 1, optimize: 1, download: 1 }[order.type] const pricing = await this.pricingService.getConfig()
const creditMap: Record<string, number> = {
interview: pricing.interview?.creditsPerPurchase || 1,
optimize: pricing.resumeOptimize?.creditsPerPurchase || 1,
download: pricing.resumeDownload?.creditsPerPurchase || 1,
}
const credits = creditMap[order.type]
if (credits) { if (credits) {
await this.quotaService.grantCredits(order.userId, order.type as any, credits) await this.quotaService.grantCredits(order.userId, order.type as any, credits)
} }
@@ -146,6 +309,46 @@ export class AdminController {
return { order, wxResult } return { order, wxResult }
} }
/** 订单详情(含用户信息) */
@Get('order/:outTradeNo')
async getOrderDetail(@Param('outTradeNo') outTradeNo: string) {
const order = await this.orderModel.findOne({ outTradeNo }).lean().exec()
if (!order) throw new HttpException('订单不存在', HttpStatus.NOT_FOUND)
const user = await this.userModel.findById(order.userId).select('phone nickname plan').lean().exec()
return { order, user }
}
/** 发起退款 */
@Post('order/refund')
async refundOrder(@Body('outTradeNo') outTradeNo: string, @Body('amount') amount?: number, @Body('reason') reason?: string) {
const order = await this.orderModel.findOne({ outTradeNo }).exec()
if (!order) throw new HttpException('订单不存在', HttpStatus.NOT_FOUND)
if (order.status !== 'success') throw new HttpException('仅支付成功的订单可退款', HttpStatus.BAD_REQUEST)
if (order.refundAmount && order.refundAmount > 0) throw new HttpException('该订单已退款', HttpStatus.BAD_REQUEST)
const result = await this.wechatPay.refund(outTradeNo, order.amount, amount || order.amount, reason)
const refundId = result?.refund_id || ''
order.status = 'refunded'
order.refundAmount = amount || order.amount
order.refundedAt = new Date()
order.refundReason = reason || ''
order.refundId = refundId
await order.save()
return { success: true, refundId }
}
/** 查询微信侧退款状态 */
@Get('order/refund/:outTradeNo')
async queryRefund(@Param('outTradeNo') outTradeNo: string) {
const order = await this.orderModel.findOne({ outTradeNo }).lean().exec()
if (!order) throw new HttpException('订单不存在', HttpStatus.NOT_FOUND)
if (!order.refundId) return { localStatus: order.status, message: '无微信退款单号' }
const wxResult = await this.wechatPay.queryRefund(order.refundId)
return { localStatus: order.status, wxRefund: wxResult }
}
@Get('config') @Get('config')
async getConfig() { async getConfig() {
const cfg = await this.configModel.findOne({ key: 'site_config' }).exec() const cfg = await this.configModel.findOne({ key: 'site_config' }).exec()
@@ -179,6 +382,7 @@ export class AdminController {
{ key: 'pricing', value: body, description: '定价配置' }, { key: 'pricing', value: body, description: '定价配置' },
{ upsert: true }, { upsert: true },
).exec() ).exec()
this.pricingService.invalidateCache()
return { success: true } return { success: true }
} }
@@ -205,8 +409,8 @@ const DEFAULT_CONFIG = {
optimize: { dailyFreeLimit: 2 }, optimize: { dailyFreeLimit: 2 },
price: { monthly: 1990 }, price: { monthly: 1990 },
plans: { plans: {
free: { name: '免费版', price: 0, features: ['AI 模拟面试 1 次(体验)', '每场最多 5 轮 AI 对话', '基础面试报告', '简历优化(限 3 次)'] }, free: { name: '免费版', price: 0, features: ['AI 模拟面试 1 次(体验)', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费'] },
growth: { name: '成长版', price: 1990, features: ['免费版全部权益', 'AI 数字人面试无限次', '每场最多 10 轮 AI 对话', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'] }, growth: { name: '成长版', price: 1990, features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'] },
}, },
} }
@@ -218,12 +422,12 @@ const DEFAULT_PRICING = {
growth: { growth: {
price: 1990, durationDays: 30, price: 1990, durationDays: 30,
credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 },
features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'], features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'],
}, },
sprint: { sprint: {
price: 4990, durationDays: 30, price: 4990, durationDays: 30,
credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 },
features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先', '简历优化 50 次/月', '简历下载 30 次/月'], features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选', '简历优化 50 次/月', '简历下载 30 次/月'],
}, },
}, },
} }
@@ -8,6 +8,8 @@ import { PaymentOrder, PaymentOrderSchema } from '../payment/payment-order.schem
import { WechatPayService } from '../payment/wechat-pay.service' import { WechatPayService } from '../payment/wechat-pay.service'
import { AdminGuard } from '../../common/guards/admin.guard' import { AdminGuard } from '../../common/guards/admin.guard'
import { SiteConfig, SiteConfigSchema } from '../schemas/site-config.schema' import { SiteConfig, SiteConfigSchema } from '../schemas/site-config.schema'
import { ShareRecord, ShareRecordSchema, ShareVisit, ShareVisitSchema } from '../share/share.schema'
import { Resume, ResumeSchema } from '../resume/resume.schema'
@Module({ @Module({
imports: [ imports: [
@@ -16,6 +18,9 @@ import { SiteConfig, SiteConfigSchema } from '../schemas/site-config.schema'
{ name: Interview.name, schema: InterviewSchema }, { name: Interview.name, schema: InterviewSchema },
{ name: PaymentOrder.name, schema: PaymentOrderSchema }, { name: PaymentOrder.name, schema: PaymentOrderSchema },
{ name: SiteConfig.name, schema: SiteConfigSchema }, { name: SiteConfig.name, schema: SiteConfigSchema },
{ name: ShareRecord.name, schema: ShareRecordSchema },
{ name: ShareVisit.name, schema: ShareVisitSchema },
{ name: Resume.name, schema: ResumeSchema },
]), ]),
UserModule, UserModule,
], ],
+40 -22
View File
@@ -1,6 +1,6 @@
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from "@nestjs/common"
import axios from 'axios' import axios from "axios"
import https from 'https' import https from "https"
interface AiCallOptions { interface AiCallOptions {
systemPrompt: string systemPrompt: string
@@ -15,63 +15,81 @@ const httpAgent = new https.Agent({ rejectUnauthorized: true, keepAlive: true })
export class AiService { export class AiService {
private readonly logger = new Logger(AiService.name) private readonly logger = new Logger(AiService.name)
private readonly primaryUrl = process.env.AI_PRIMARY_URL || 'https://token.sensenova.cn/v1' private readonly primaryUrl = process.env.AI_PRIMARY_URL || "https://token.sensenova.cn/v1"
private readonly primaryKey = process.env.AI_PRIMARY_KEY || '' private readonly primaryKey = process.env.AI_PRIMARY_KEY || ""
private readonly primaryModel = process.env.AI_PRIMARY_MODEL || 'deepseek-v4-flash' private readonly primaryModel = process.env.AI_PRIMARY_MODEL || "deepseek-v4-flash"
private readonly primaryFallbackModel = process.env.AI_PRIMARY_FALLBACK_MODEL || "sensenova-6.7-flash-lite"
private readonly backupUrl = process.env.AI_BACKUP_URL || 'https://integrate.api.nvidia.com/v1' private readonly backupUrl = process.env.AI_BACKUP_URL || "https://integrate.api.nvidia.com/v1"
private readonly backupKey = process.env.AI_BACKUP_KEY || '' private readonly backupKey = process.env.AI_BACKUP_KEY || ""
private readonly backupModel = process.env.AI_BACKUP_MODEL || 'stepfun-ai/step-3.5-flash' private readonly backupModel = process.env.AI_BACKUP_MODEL || "meta/llama-3.1-8b-instruct"
async call(options: AiCallOptions): Promise<string> { async call(options: AiCallOptions): Promise<string> {
const { systemPrompt, userMessage, temperature = 0.7, maxTokens = 2048 } = options const { systemPrompt, userMessage, temperature = 0.7, maxTokens = 2048 } = options
// Try primary AI // Try primary AI (deepseek-v4-flash on sensenova)
try { try {
const result = await this.callApi(this.primaryUrl, this.primaryKey, this.primaryModel, systemPrompt, userMessage, temperature, maxTokens) const result = await this.callApi(this.primaryUrl, this.primaryKey, this.primaryModel, systemPrompt, userMessage, temperature, maxTokens, 60000)
if (result) return result if (result) return result
// Primary returned empty content (thinking model exhausted tokens); retry with more tokens
const retry = await this.callApi(this.primaryUrl, this.primaryKey, this.primaryModel, systemPrompt, userMessage, temperature, Math.min(maxTokens * 2, 4096), 60000)
if (retry) return retry
} catch (e) { } catch (e) {
this.logger.warn(`Primary AI failed: ${(e as Error).message}, trying backup...`) this.logger.warn(`Primary AI failed: ${(e as Error).message}, trying primary fallback...`)
} }
// Try backup AI // Try primary fallback model (sensenova-6.7-flash-lite, same provider)
try { try {
const result = await this.callApi(this.backupUrl, this.backupKey, this.backupModel, systemPrompt, userMessage, temperature, maxTokens) const result = await this.callApi(this.primaryUrl, this.primaryKey, this.primaryFallbackModel, systemPrompt, userMessage, temperature, maxTokens, 60000)
if (result) return result
} catch (e) {
this.logger.warn(`Primary fallback AI also failed: ${(e as Error).message}, trying backup...`)
}
// Try backup AI (NVIDIA - meta/llama-3.1-8b-instruct)
try {
const result = await this.callApi(this.backupUrl, this.backupKey, this.backupModel, systemPrompt, userMessage, temperature, Math.max(maxTokens, 2048), 120000)
if (result) return result if (result) return result
} catch (e) { } catch (e) {
this.logger.warn(`Backup AI also failed: ${(e as Error).message}`) this.logger.warn(`Backup AI also failed: ${(e as Error).message}`)
} }
// Final fallback throw new Error("AI 服务暂时不可用,请稍后重试")
throw new Error('AI 服务暂时不可用,请稍后重试')
} }
private async callApi( private async callApi(
baseUrl: string, apiKey: string, model: string, baseUrl: string, apiKey: string, model: string,
systemPrompt: string, userMessage: string, systemPrompt: string, userMessage: string,
temperature: number, maxTokens: number, temperature: number, maxTokens: number, timeout: number,
): Promise<string | null> { ): Promise<string | null> {
try {
const res = await axios.post( const res = await axios.post(
`${baseUrl}/chat/completions`, `${baseUrl}/chat/completions`,
{ {
model, model,
messages: [ messages: [
{ role: 'system', content: systemPrompt }, { role: "system", content: systemPrompt },
{ role: 'user', content: userMessage }, { role: "user", content: userMessage },
], ],
temperature, temperature,
max_tokens: maxTokens, max_tokens: maxTokens,
}, },
{ {
headers: { headers: {
'Authorization': `Bearer ${apiKey}`, "Authorization": `Bearer ${apiKey}`,
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
timeout: 60000, timeout,
httpsAgent: httpAgent, httpsAgent: httpAgent,
transitional: { clarifyTimeoutError: true }, transitional: { clarifyTimeoutError: true },
}, },
) )
return res.data?.choices?.[0]?.message?.content || null return res.data?.choices?.[0]?.message?.content || null
} catch (e: any) {
if (e.code === 'ECONNABORTED') {
this.logger.warn(`AI call timeout (${timeout}ms): ${model}`)
}
return null
}
} }
} }
@@ -0,0 +1,37 @@
import { Controller, Post, Get, Body } from "@nestjs/common"
import { Public } from "../../common/decorators/public.decorator"
import { CareerAdviceService, CareerProfile, ChatMessage } from "./career-advice.service"
import { CurrentUser } from "../../common/decorators/current-user.decorator"
@Controller("career-advice")
export class CareerAdviceController {
constructor(private service: CareerAdviceService) {}
@Post("analyze")
async analyze(
@Body() profile: CareerProfile,
@CurrentUser("userId") userId: string,
) {
if (!profile.major || !profile.major.trim()) {
return { error: "请填写你的专业" }
}
return this.service.analyze(profile)
}
@Post("chat")
async chat(
@Body() body: { message: string; history: ChatMessage[] },
@CurrentUser("userId") userId: string,
) {
if (!body.message || !body.message.trim()) {
return { error: "请输入消息" }
}
return this.service.chat(body.message, body.history || [])
}
@Get("positions")
@Public()
async positions() {
return this.service.getHotPositions()
}
}
@@ -0,0 +1,18 @@
import { Module } from '@nestjs/common'
import { MongooseModule } from '@nestjs/mongoose'
import { CareerAdviceController } from './career-advice.controller'
import { CareerAdviceService } from './career-advice.service'
import { HotPosition, HotPositionSchema } from '../positions/positions.schema'
import { AiModule } from '../ai/ai.module'
@Module({
imports: [
MongooseModule.forFeature([
{ name: HotPosition.name, schema: HotPositionSchema },
]),
AiModule,
],
controllers: [CareerAdviceController],
providers: [CareerAdviceService],
})
export class CareerAdviceModule {}
@@ -0,0 +1,163 @@
import { Injectable, Logger } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose'
import { AiService } from '../ai/ai.service'
import { HotPosition } from '../positions/positions.schema'
export interface CareerProfile {
major: string
grade?: string
interests?: string
gpa?: string
goal?: string
}
export interface CareerPath {
name: string
reason: string
matchScore: number
salary?: string
}
export interface ChatMessage {
role: 'user' | 'assistant'
content: string
}
@Injectable()
export class CareerAdviceService {
private readonly logger = new Logger(CareerAdviceService.name)
constructor(
@InjectModel(HotPosition.name) private positionModel: Model<HotPosition>,
private aiService: AiService,
) {}
/**
* Analyze user profile and return career advice with position recommendations.
*/
async analyze(profile: CareerProfile) {
const positions = await this.positionModel.find({ active: true })
.sort({ sort: 1 })
.lean()
.exec()
const positionsContext = positions.map(p =>
`- ${p.name}${p.salary ? ` (薪资: ${p.salary})` : ''}${p.company ? ` - ${p.company}` : ''}`
).join('\n')
const systemPrompt = `你是一位资深的中国大学生职业规划顾问。你的任务是根据学生的专业背景和个人情况,给出个性化的择业建议。
你的建议需要涵盖:
1. 该专业的典型职业方向和发展路径
2. "考研vs就业vs考公"的决策分析(基于学生具体情况)
3. 当前就业市场的真实形势(如AI对各行业的影响)
4. 具体可行动的建议(实习、技能提升等)
你需要从以下可用岗位中,推荐最匹配该学生的3-5个方向:
${positionsContext}
注意:
- 你的回答要诚恳务实,不要画大饼
- 指出每个选择的利弊和风险
- 结合AI时代对各行业的影响给出建议
- 最后以JSON格式输出推荐岗位列表
回复格式:
先输出一段详细的个性化分析建议(中文,300-500字)。
然后在最后单独一行输出JSON数组(不要任何其他内容):
---JSON---
[{"name":"岗位名","reason":"推荐理由简要说明","matchScore":85,"salary":"薪资范围"},...]
---JSON---`
const userMessage = this.buildProfileMessage(profile)
const rawReply = await this.aiService.call({
systemPrompt,
userMessage,
temperature: 0.7,
maxTokens: 2048,
})
return this.parseResponse(rawReply, positions)
}
/**
* Continue a chat conversation about career choices.
*/
async chat(message: string, history: ChatMessage[]) {
const positions = await this.positionModel.find({ active: true })
.sort({ sort: 1 })
.lean()
.exec()
const positionsContext = positions.map(p =>
`- ${p.name}${p.salary ? ` (薪资: ${p.salary})` : ''}`
).join('\n')
const systemPrompt = `你是一位资深的中国大学生职业规划顾问。继续与学生的对话,回答他们的择业相关问题。
可推荐的岗位列表:
${positionsContext}
注意:
- 回答诚恳务实,结合AI时代背景
- 给出具体可操作的建议
- 如果学生提到具体岗位,可以从推荐列表中选择匹配的
- 保持对话亲切自然,用中文回复`
const historyMessages = history.map(h =>
`${h.role === 'user' ? '学生' : '顾问'}: ${h.content}`
).join('\n')
const userMessage = `对话历史:\n${historyMessages}\n\n学生最新提问: ${message}`
const reply = await this.aiService.call({
systemPrompt,
userMessage,
temperature: 0.7,
maxTokens: 1024,
})
return { reply }
}
private buildProfileMessage(profile: CareerProfile): string {
const parts: string[] = [`学生专业: ${profile.major}`]
if (profile.grade) parts.push(`年级: ${profile.grade}`)
if (profile.interests) parts.push(`兴趣方向: ${profile.interests}`)
if (profile.gpa) parts.push(`GPA/成绩: ${profile.gpa}`)
if (profile.goal) parts.push(`目标/困惑: ${profile.goal}`)
return parts.join('\n')
}
private parseResponse(rawReply: string, allPositions: any[]): {
reply: string
careerPaths: CareerPath[]
} {
// Extract JSON array from ---JSON--- markers
const jsonMatch = rawReply.match(/---JSON---\s*(\[[\s\S]*?\])\s*---JSON---/)
let careerPaths: CareerPath[] = []
if (jsonMatch) {
try {
careerPaths = JSON.parse(jsonMatch[1])
} catch {
this.logger.warn('Failed to parse career paths JSON')
}
}
// Clean reply (remove --JSON-- markers)
const reply = rawReply.replace(/---JSON---[\s\S]*?---JSON---/g, '').trim()
return { reply, careerPaths }
}
/** Get hot positions (delegated from positions module) */
async getHotPositions() {
return this.positionModel.find({ active: true })
.sort({ sort: 1 })
.lean()
.exec()
}
}
@@ -2,6 +2,7 @@ import { Controller, Post, Get, Body, Param, UseGuards, Logger } from '@nestjs/c
import { InjectModel } from '@nestjs/mongoose' import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose' import { Model } from 'mongoose'
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard' import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
import { Public } from '../../common/decorators/public.decorator'
import { CurrentUser } from '../../common/decorators/current-user.decorator' import { CurrentUser } from '../../common/decorators/current-user.decorator'
import { AiService } from '../ai/ai.service' import { AiService } from '../ai/ai.service'
import { Contribution, ContributionDocument } from '../schemas/contribution.schema' import { Contribution, ContributionDocument } from '../schemas/contribution.schema'
@@ -186,4 +187,19 @@ export class ContributionController {
.select('company position rounds experience createdAt') .select('company position rounds experience createdAt')
.exec() .exec()
} }
@Public()
@Get('companies/hot')
async getHotCompanies() {
const banks = await this.companyBankModel.aggregate([
{ $group: { _id: '$company', positionCount: { $sum: 1 }, totalContributions: { $sum: '$contributionCount' } } },
{ $sort: { totalContributions: -1, positionCount: -1 } },
{ $project: { _id: 0, name: '$_id', positionCount: 1 } },
]).exec()
if (banks.length > 0) return banks
const DEFAULT_COMPANIES = ['腾讯', '字节跳动', '阿里巴巴', '美团', '百度', '京东', '网易', '小红书']
return DEFAULT_COMPANIES.map((name, i) => ({ name, positionCount: 0, sort: i }))
}
} }
@@ -0,0 +1,218 @@
import { Injectable, Logger } from '@nestjs/common'
import { execSync } from 'child_process'
import * as path from 'path'
import * as fs from 'fs'
export interface AsrSegment {
startTime: number
endTime: number
speaker: 'interviewer' | 'candidate'
text: string
}
export interface AsrResult {
fullText: string
segments: AsrSegment[]
duration: number
}
export interface AsrConfig {
/** Path to whisper.cpp build/bin/ directory */
whisperCppPath?: string
/** Model name: tiny | base | small | medium */
model?: string
/** Language code (zh, en, auto) */
language?: string
}
@Injectable()
export class AsrService {
private readonly logger = new Logger(AsrService.name)
private readonly whisperCppPath: string
private readonly modelPath: string
private readonly language: string
private readonly cliPath: string
constructor() {
// Configuration via env vars with sensible defaults
this.whisperCppPath = process.env.WHISPER_CPP_PATH || '/home/wlt/whisper.cpp'
this.language = process.env.WHISPER_LANGUAGE || 'zh'
const modelName = process.env.WHISPER_MODEL || 'base'
this.modelPath = path.join(this.whisperCppPath, 'models', `ggml-${modelName}.bin`)
this.cliPath = path.join(this.whisperCppPath, 'build', 'bin', 'whisper-cli')
// Validate whisper.cpp installation on startup
if (!fs.existsSync(this.cliPath)) {
this.logger.warn(`whisper-cli not found at ${this.cliPath}. ASR will fall back to mock.`)
}
if (!fs.existsSync(this.modelPath)) {
this.logger.warn(`Whisper model not found at ${this.modelPath}. ASR will fall back to mock.`)
}
}
async transcribe(audioPath: string, _mimeType: string): Promise<AsrResult> {
this.logger.log(`Transcribing audio: ${audioPath}`)
// Try companion .txt file first (for debugging/testing)
const txtPath = audioPath.replace(/\.(mp3|m4a|wav|aac|ogg|mp4|webm)$/i, '.txt')
try {
if (fs.existsSync(txtPath)) {
const text = fs.readFileSync(txtPath, 'utf-8')
this.logger.log(`Found companion transcript: ${txtPath}`)
return {
fullText: text,
segments: [{
startTime: 0,
endTime: Math.max(text.length / 3.5, 10),
speaker: 'candidate',
text,
}],
duration: Math.max(text.length / 3.5, 10),
}
}
} catch { /* ignore */ }
// Try whisper.cpp
if (fs.existsSync(this.cliPath) && fs.existsSync(this.modelPath)) {
try {
return await this.transcribeWithWhisper(audioPath)
} catch (err: any) {
this.logger.error(`whisper.cpp transcription failed: ${err.message}, falling back to mock`)
}
}
// Fallback to mock
this.logger.warn('Using MOCK ASR — whisper.cpp not available')
return this.mockTranscribe()
}
private async transcribeWithWhisper(audioPath: string): Promise<AsrResult> {
// Ensure audio file exists
if (!fs.existsSync(audioPath)) {
throw new Error(`Audio file not found: ${audioPath}`)
}
// Convert to WAV if needed (whisper.cpp works best with WAV)
const wavPath = await this.ensureWav(audioPath)
// Run whisper-cli with JSON output
const cmd = [
this.cliPath,
'-m', this.modelPath,
'-f', wavPath,
'-l', this.language,
'-oj', // JSON output
'-t', String(Math.max(1, this.getCpuThreads())), // thread count
'--no-prints', // suppress timing info on stderr
].join(' ')
this.logger.log(`Running: ${this.cliPath} -m ${this.modelPath} -f ${wavPath} -l ${this.language}`)
const stdout = execSync(cmd, { timeout: 600000, encoding: 'utf-8' }) // 10 min timeout
// Parse the JSON output
const segments = this.parseWhisperOutput(stdout)
const fullText = segments.map(s => s.text).join(' ')
const duration = segments.length > 0
? segments[segments.length - 1].endTime
: 0
return { fullText, segments, duration }
}
private parseWhisperOutput(stdout: string): AsrSegment[] {
try {
// whisper.cpp -oj outputs one JSON object per line
const lines = stdout.trim().split('\n')
const segments: AsrSegment[] = []
for (const line of lines) {
try {
const parsed = JSON.parse(line)
if (parsed.text && parsed.offsets) {
segments.push({
startTime: parsed.offsets.from / 1000, // ms to seconds
endTime: parsed.offsets.to / 1000,
speaker: 'candidate',
text: parsed.text.trim(),
})
} else if (parsed.text && parsed.start !== undefined) {
// Alternative format
segments.push({
startTime: parsed.start,
endTime: parsed.end || parsed.start + 2,
speaker: 'candidate',
text: parsed.text.trim(),
})
}
} catch { /* skip unparseable lines */ }
}
if (segments.length > 0) return segments
} catch { /* fall through */ }
// Fallback: treat entire output as raw text
this.logger.warn('Could not parse structured JSON output, using raw text')
return [{
startTime: 0,
endTime: 0,
speaker: 'candidate',
text: stdout.trim(),
}]
}
/**
* Convert audio to WAV format if needed.
* Uses ffmpeg if available, otherwise returns original path.
*/
private async ensureWav(audioPath: string): Promise<string> {
const ext = path.extname(audioPath).toLowerCase()
if (ext === '.wav') return audioPath
const wavPath = audioPath.replace(/\.[^.]+$/, '.wav')
try {
execSync(`ffmpeg -y -i "${audioPath}" -ar 16000 -ac 1 -c:a pcm_s16le "${wavPath}"`, {
timeout: 300000,
encoding: 'utf-8',
stdio: 'pipe',
})
this.logger.log(`Converted ${audioPath} to WAV: ${wavPath}`)
return wavPath
} catch (err: any) {
this.logger.warn(`ffmpeg conversion failed: ${err.message}. Trying original format.`)
return audioPath
}
}
private getCpuThreads(): number {
try {
return parseInt(process.env.WHISPER_THREADS || '', 10) ||
require('os').cpus().length || 4
} catch {
return 4
}
}
/** Mock transcription for development/testing when whisper.cpp is not available */
private mockTranscribe(): AsrResult {
const paragraphs = [
'我毕业于计算机科学与技术专业,大学期间主要学习了数据结构、算法、操作系统、计算机网络等核心课程。',
'在项目经验方面,我参与过一个电商平台的开发,主要负责后端接口的设计和实现,使用了 Node.js 和 MongoDB 技术栈。',
'这个项目的难点在于高并发场景下的性能优化,我通过引入 Redis 缓存和数据库索引优化,将接口响应时间从 2 秒降低到了 200 毫秒。',
'关于这个岗位,我了解到贵公司主要使用 React 技术栈,我之前在两个项目中使用过 React,对 Hooks、状态管理、组件化开发都比较熟悉。',
]
const fullText = paragraphs.join('\n')
return {
fullText,
segments: [{
startTime: 0,
endTime: 120,
speaker: 'candidate',
text: fullText,
}],
duration: 120,
}
}
}
@@ -0,0 +1,100 @@
import {
Controller, Post, Get, Delete, Param, Query,
UseInterceptors, UploadedFile, Body,
HttpException, HttpStatus,
} from '@nestjs/common'
import { FileInterceptor } from '@nestjs/platform-express'
import { diskStorage } from 'multer'
import { extname, join } from 'path'
import * as fs from 'fs'
import { randomUUID } from 'crypto'
import { InterviewReviewService } from './interview-review.service'
import { CurrentUser } from '../../common/decorators/current-user.decorator'
const UPLOAD_DIR = join(process.cwd(), 'uploads', 'reviews')
if (!fs.existsSync(UPLOAD_DIR)) {
fs.mkdirSync(UPLOAD_DIR, { recursive: true })
}
@Controller('interview-review')
export class InterviewReviewController {
constructor(private service: InterviewReviewService) {}
/** Upload audio file + metadata */
@Post()
@UseInterceptors(FileInterceptor('file', {
storage: diskStorage({
destination: (_req, _file, cb) => cb(null, UPLOAD_DIR),
filename: (_req, file, cb) => {
const name = randomUUID() + extname(file.originalname || '.mp3')
cb(null, name)
},
}),
limits: { fileSize: 50 * 1024 * 1024 },
fileFilter: (_req, file, cb) => {
const allowed = /\.(mp3|m4a|wav|aac|ogg|mp4|webm)$/i
if (allowed.test(extname(file.originalname))) {
cb(null, true)
} else {
cb(new HttpException('仅支持 mp3/m4a/wav/aac/ogg 格式', HttpStatus.BAD_REQUEST), false)
}
},
}))
async uploadFile(
@UploadedFile() file: any,
@Body('position') position: string,
@Body('company') company: string,
@CurrentUser('userId') userId: string,
) {
if (!file) {
throw new HttpException('请上传录音文件', HttpStatus.BAD_REQUEST)
}
if (!position || !position.trim()) {
throw new HttpException('请填写面试岗位', HttpStatus.BAD_REQUEST)
}
return this.service.create(userId, position.trim(), company?.trim(), file)
}
/** Submit text transcript directly (no audio) */
@Post('text')
async submitText(
@Body('position') position: string,
@Body('company') company: string,
@Body('text') text: string,
@CurrentUser('userId') userId: string,
) {
if (!position || !position.trim()) {
throw new HttpException('请填写面试岗位', HttpStatus.BAD_REQUEST)
}
if (!text || !text.trim()) {
throw new HttpException('请填写面试转录文本', HttpStatus.BAD_REQUEST)
}
return this.service.createFromText(userId, position.trim(), text.trim(), company?.trim())
}
@Get('list')
async list(
@Query('page') page: string,
@Query('limit') limit: string,
@CurrentUser('userId') userId: string,
) {
return this.service.listByUser(userId, parseInt(page) || 1, parseInt(limit) || 20)
}
@Get(':id')
async getDetail(
@Param('id') id: string,
@CurrentUser('userId') userId: string,
) {
return this.service.getDetail(id, userId)
}
@Delete(':id')
async delete(
@Param('id') id: string,
@CurrentUser('userId') userId: string,
) {
return this.service.delete(id, userId)
}
}
@@ -0,0 +1,19 @@
import { Module } from '@nestjs/common'
import { MongooseModule } from '@nestjs/mongoose'
import { InterviewReviewController } from './interview-review.controller'
import { InterviewReviewService } from './interview-review.service'
import { InterviewReview, InterviewReviewSchema } from './interview-review.schema'
import { AsrService } from './asr.service'
import { AiModule } from '../ai/ai.module'
@Module({
imports: [
MongooseModule.forFeature([
{ name: InterviewReview.name, schema: InterviewReviewSchema },
]),
AiModule,
],
controllers: [InterviewReviewController],
providers: [InterviewReviewService, AsrService],
})
export class InterviewReviewModule {}
@@ -0,0 +1,79 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
export type InterviewReviewDocument = InterviewReview & Document
@Schema({ timestamps: true })
export class InterviewReview {
@Prop({ type: Types.ObjectId, ref: 'User', required: true })
userId: Types.ObjectId
@Prop({ required: true })
position: string
@Prop({ default: '' })
company: string
@Prop({ default: 'processing' })
status: 'processing' | 'completed' | 'failed'
@Prop({ type: Object, default: null })
audioFile?: {
hash: string
filePath: string
duration: number
size: number
mimeType: string
}
@Prop({ type: Object, default: null })
transcript?: {
fullText: string
segments: {
startTime: number
endTime: number
speaker: 'interviewer' | 'candidate'
text: string
}[]
}
@Prop({ type: Object, default: null })
analysis?: {
overallScore: number
dimensions: {
logic: number
expression: number
professionalism: number
stability: number
}
strengths: string[]
weaknesses: string[]
suggestions: string[]
questionBreakdown: {
question: string
answer: string
score: number
comment: string
suggestedAnswer: string
}[]
}
@Prop({ type: Object, default: null })
speechAnalysis?: {
fillerWords: { word: string; count: number }[]
fillerScore: number
fillerDensity: number
pace: string
totalDuration: number
totalChars: number
}
@Prop({ default: 0 })
retryCount: number
readonly createdAt?: Date
readonly updatedAt?: Date
}
export const InterviewReviewSchema = SchemaFactory.createForClass(InterviewReview)
InterviewReviewSchema.index({ userId: 1, createdAt: -1 })
@@ -0,0 +1,302 @@
import { Injectable, Logger, HttpException, HttpStatus } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose'
import { InterviewReview, InterviewReviewDocument } from './interview-review.schema'
import { AiService } from '../ai/ai.service'
import { AsrService } from './asr.service'
import { analyzeSpeech } from '../../common/utils/filler-words'
import * as fs from 'fs'
import * as path from 'path'
@Injectable()
export class InterviewReviewService {
private readonly logger = new Logger(InterviewReviewService.name)
constructor(
@InjectModel(InterviewReview.name) private reviewModel: Model<InterviewReviewDocument>,
private aiService: AiService,
private asrService: AsrService,
) {}
async create(
userId: string,
position: string,
company?: string,
audioFile?: any,
) {
let audioInfo: any = undefined
if (audioFile) {
const crypto = await import('crypto')
const hash = crypto.createHash('md5').update(audioFile.buffer).digest('hex')
audioInfo = {
hash,
filePath: audioFile.path,
duration: 0,
size: audioFile.size,
mimeType: audioFile.mimetype,
}
}
const review = new this.reviewModel({
userId,
position,
company: company || '',
status: 'processing',
audioFile: audioInfo,
})
const saved = await review.save()
// Start async processing (non-blocking)
this.processReview(saved._id.toString()).catch((err) => {
this.logger.error(`Review ${saved._id} processing failed: ${err.message}`)
})
return {
id: saved._id.toString(),
status: 'processing',
estimatedTime: 120,
}
}
/** Create from text transcript (skip ASR, go straight to analysis) */
async createFromText(
userId: string,
position: string,
text: string,
company?: string,
) {
const review = new this.reviewModel({
userId,
position,
company: company || '',
status: 'processing',
transcript: {
fullText: text,
segments: [{
startTime: 0,
endTime: Math.max(text.length / 3.5, 10),
speaker: 'candidate',
text,
}],
},
})
const saved = await review.save()
this.processReview(saved._id.toString()).catch((err) => {
this.logger.error(`Review ${saved._id} processing failed: ${err.message}`)
})
return {
id: saved._id.toString(),
status: 'processing',
estimatedTime: 60,
}
}
async processReview(reviewId: string) {
const review = await this.reviewModel.findById(reviewId)
if (!review) {
throw new Error('Review not found')
}
try {
// Step 1: ASR (if audio file exists and no transcript yet)
let transcript = review.transcript
if (!transcript && review.audioFile?.filePath) {
const asrResult = await this.asrService.transcribe(
review.audioFile.filePath,
review.audioFile.mimeType,
)
transcript = {
fullText: asrResult.fullText,
segments: asrResult.segments.map(s => ({
startTime: s.startTime,
endTime: s.endTime,
speaker: s.speaker as 'interviewer' | 'candidate',
text: s.text,
})),
}
await this.reviewModel.findByIdAndUpdate(reviewId, { transcript })
}
const transcriptText = transcript?.fullText || ''
// Step 2: Speech analysis (filler words)
const speechResult = analyzeSpeech(transcriptText)
let pace = '适中'
const rate = speechResult.speechRate
if (rate > 5) pace = '偏快'
else if (rate < 2.5) pace = '偏慢'
const speechAnalysis = {
fillerWords: speechResult.fillerWords,
fillerScore: speechResult.fillerScore,
fillerDensity: speechResult.fillerDensity,
pace,
totalDuration: speechResult.estimatedDurationSec,
totalChars: speechResult.totalChars,
}
// Step 3: AI analysis
const analysis = await this.runAiAnalysis(transcriptText, review.position, review.company)
// Save results
await this.reviewModel.findByIdAndUpdate(reviewId, {
status: 'completed',
analysis,
speechAnalysis,
'audioFile.duration': speechResult.estimatedDurationSec,
})
} catch (err: any) {
this.logger.error(`Processing failed for review ${reviewId}: ${err.message}`)
await this.reviewModel.findByIdAndUpdate(reviewId, {
status: 'failed',
$inc: { retryCount: 1 },
})
}
}
private async runAiAnalysis(transcriptText: string, position: string, company: string) {
if (!transcriptText.trim()) {
return this.emptyAnalysis()
}
const systemPrompt = `你是一位资深的校招面试评估专家。分析以下面试转录内容,输出评估报告。
评估维度(0-100分):
1. 逻辑思维(logic):回答是否结构化、层次分明、有因果关系
2. 表达能力(expression):语言是否流畅、用词是否准确、表达是否清晰
3. 专业度(professionalism):技术栈掌握程度、行业认知深度、术语使用是否准确
4. 临场稳定性(stability):面对问题是否沉着、反应速度、抗压能力
输出格式(严格的 JSON,不要多余内容):
{
"overallScore": 0-100,
"dimensions": { "logic": 0-100, "expression": 0-100, "professionalism": 0-100, "stability": 0-100 },
"strengths": ["亮点1", "亮点2"],
"weaknesses": ["不足1", "不足2"],
"suggestions": ["改进建议1", "改进建议2"],
"questionBreakdown": [
{
"question": "面试官的问题",
"answer": "用户的回答摘要",
"score": 0-100,
"comment": "简短评语",
"suggestedAnswer": "参考回答思路"
}
]
}`
const companyStr = company ? `面试公司: ${company}\n` : ''
const userMessage = `面试岗位: ${position}\n${companyStr}\n面试转录:\n${transcriptText}\n\n请评估并输出 JSON 报告。`
try {
const result = await this.aiService.call({
systemPrompt,
userMessage,
temperature: 0.5,
maxTokens: 2048,
})
const parsed = JSON.parse(result)
// Validate required fields
if (!parsed.overallScore || !parsed.dimensions) {
return this.emptyAnalysis()
}
return {
overallScore: Math.min(100, Math.max(0, Math.round(parsed.overallScore))),
dimensions: {
logic: Math.min(100, Math.max(0, Math.round(parsed.dimensions.logic || 0))),
expression: Math.min(100, Math.max(0, Math.round(parsed.dimensions.expression || 0))),
professionalism: Math.min(100, Math.max(0, Math.round(parsed.dimensions.professionalism || 0))),
stability: Math.min(100, Math.max(0, Math.round(parsed.dimensions.stability || 0))),
},
strengths: Array.isArray(parsed.strengths) ? parsed.strengths : [],
weaknesses: Array.isArray(parsed.weaknesses) ? parsed.weaknesses : [],
suggestions: Array.isArray(parsed.suggestions) ? parsed.suggestions : [],
questionBreakdown: Array.isArray(parsed.questionBreakdown) ? parsed.questionBreakdown.slice(0, 10) : [],
}
} catch {
return this.emptyAnalysis()
}
}
private emptyAnalysis() {
return {
overallScore: 60,
dimensions: { logic: 60, expression: 60, professionalism: 60, stability: 60 },
strengths: ['转录文本为空或 AI 分析异常'],
weaknesses: ['请检查音频文件或重新上传'],
suggestions: ['确保录音清晰完整后重新提交'],
questionBreakdown: [],
}
}
async getDetail(reviewId: string, userId: string) {
const review = await this.reviewModel.findById(reviewId).lean()
if (!review) {
throw new HttpException('复盘记录不存在', HttpStatus.NOT_FOUND)
}
if (review.userId.toString() !== userId) {
throw new HttpException('无权访问', HttpStatus.FORBIDDEN)
}
return this.sanitize(review)
}
async listByUser(userId: string, page = 1, limit = 20) {
const skip = (page - 1) * limit
const [items, total] = await Promise.all([
this.reviewModel
.find({ userId })
.sort({ createdAt: -1 })
.skip(skip)
.limit(limit)
.select('-transcript.fullText -transcript.segments')
.lean(),
this.reviewModel.countDocuments({ userId }),
])
return {
items: items.map(i => this.sanitize(i)),
total,
page,
limit,
totalPages: Math.ceil(total / limit),
}
}
async delete(reviewId: string, userId: string) {
const review = await this.reviewModel.findById(reviewId)
if (!review) {
throw new HttpException('复盘记录不存在', HttpStatus.NOT_FOUND)
}
if (review.userId.toString() !== userId) {
throw new HttpException('无权删除', HttpStatus.FORBIDDEN)
}
// Delete audio file if exists
if (review.audioFile?.filePath) {
try {
fs.unlinkSync(review.audioFile.filePath)
} catch {
// ignore
}
}
await this.reviewModel.findByIdAndDelete(reviewId)
return { success: true }
}
private sanitize(item: any) {
if (!item) return item
const obj = { ...item }
// Remove sensitive fields
if (obj.audioFile?.filePath) {
obj.audioFile = { ...obj.audioFile }
delete obj.audioFile.filePath
}
return obj
}
}
@@ -107,7 +107,7 @@ ${conversationHistory}
if (aiMsg?.content) { if (aiMsg?.content) {
try { try {
const tts = await this.ttsService.synthesize(aiMsg.content) const tts = await this.ttsService.synthesize(aiMsg.content)
return { ...base, ttsHash: tts.hash, ttsDurationMs: tts.durationMs } return { ...base, ttsHash: tts.hash, ttsDurationMs: tts.durationMs, ttsAmplitude: tts.amplitudeData }
} catch { } catch {
// TTS failure is non-critical, return without audio // TTS failure is non-critical, return without audio
} }
@@ -54,6 +54,9 @@ export class PaymentOrder {
@Prop() @Prop()
refundReason?: string refundReason?: string
@Prop()
refundId?: string // 微信退款单号
} }
export const PaymentOrderSchema = SchemaFactory.createForClass(PaymentOrder) export const PaymentOrderSchema = SchemaFactory.createForClass(PaymentOrder)
@@ -150,8 +150,8 @@ export class PaymentController {
const wechatSignature = req.headers['wechatpay-signature'] || '' const wechatSignature = req.headers['wechatpay-signature'] || ''
const wechatTimestamp = req.headers['wechatpay-timestamp'] || '' const wechatTimestamp = req.headers['wechatpay-timestamp'] || ''
const wechatNonce = req.headers['wechatpay-nonce'] || '' const wechatNonce = req.headers['wechatpay-nonce'] || ''
const decrypted = this.wechatPay.verifyAndDecrypt(body, wechatSignature, wechatTimestamp, wechatNonce) const decrypted = this.wechatPay.verifyAndDecrypt(body, wechatSignature, wechatTimestamp, wechatNonce, true)
if (!decrypted) return { code: 'FAIL', message: '验签失败' } if (!decrypted) return { code: 'FAIL', message: '处理失败' }
const outTradeNo = decrypted.out_trade_no const outTradeNo = decrypted.out_trade_no
const wxTransactionId = decrypted.transaction_id const wxTransactionId = decrypted.transaction_id
@@ -168,6 +168,8 @@ export class PaymentController {
order.wxTransactionId = wxTransactionId order.wxTransactionId = wxTransactionId
order.description = `${decrypted.trade_type || ''} 支付成功` order.description = `${decrypted.trade_type || ''} 支付成功`
await order.save() await order.save()
} else {
return { code: 'SUCCESS', message: '已处理' }
} }
if (order.type === 'membership') { if (order.type === 'membership') {
@@ -260,6 +262,15 @@ export class PaymentController {
return { success: true, plan: order.plan } return { success: true, plan: order.plan }
} }
// For product orders, check if already activated via callback
const user = await this.userModel.findById(userId).exec()
if (user && order.type === 'interview' && (user.interviewCredits || 0) > 0) {
return { success: true, type: order.type, alreadyActivated: true }
}
if (user && order.type === 'optimize' && (user.resumeOptimizeCredits || 0) > 0) {
return { success: true, type: order.type, alreadyActivated: true }
}
await this.activateProduct(order) await this.activateProduct(order)
return { success: true, type: order.type } return { success: true, type: order.type }
} }
@@ -21,8 +21,11 @@ export class WechatPayService {
this.logger.warn('微信支付配置不完整,支付功能不可用') this.logger.warn('微信支付配置不完整,支付功能不可用')
} }
const certDir = path.resolve(__dirname, '../../certs') const certDir = path.resolve(__dirname, '../../certs')
if (!fs.existsSync(certDir)) {
this.logger.error(`证书目录不存在: ${certDir}`)
return
}
this.privateKey = fs.readFileSync(path.join(certDir, 'apiclient_key.pem'), 'utf8') this.privateKey = fs.readFileSync(path.join(certDir, 'apiclient_key.pem'), 'utf8')
// 从证书中提取序列号
const cert = fs.readFileSync(path.join(certDir, 'apiclient_cert.pem'), 'utf8') const cert = fs.readFileSync(path.join(certDir, 'apiclient_cert.pem'), 'utf8')
const certObj = new crypto.X509Certificate(cert) const certObj = new crypto.X509Certificate(cert)
this.mchSerialNo = certObj.serialNumber this.mchSerialNo = certObj.serialNumber
@@ -118,36 +121,92 @@ export class WechatPayService {
} }
/** 验证并解密回调通知 */ /** 验证并解密回调通知 */
verifyAndDecrypt(body: any, wechatSignature: string, wechatTimestamp: string, wechatNonce: string) { verifyAndDecrypt(body: any, wechatSignature: string, wechatTimestamp: string, wechatNonce: string, returnRaw?: boolean) {
// 1. 验签 let verified = false
const message = `${wechatTimestamp}\n${wechatNonce}\n${JSON.stringify(body)}\n` const message = `${wechatTimestamp}\n${wechatNonce}\n${JSON.stringify(body)}\n`
const certDir = path.resolve(__dirname, '../../certs') const certDir = path.resolve(__dirname, '../../certs')
const platformCert = fs.readFileSync(path.join(certDir, 'pub_key.pem'), 'utf8') const pemPath = path.join(certDir, 'pub_key.pem')
if (fs.existsSync(pemPath)) {
const platformCert = fs.readFileSync(pemPath, 'utf8')
const verify = crypto.createVerify('RSA-SHA256').update(message) const verify = crypto.createVerify('RSA-SHA256').update(message)
const isValid = verify.verify(platformCert, wechatSignature, 'base64') verified = verify.verify(platformCert, wechatSignature, 'base64')
if (!isValid) { } else {
this.logger.warn('微信支付回调验签失败') this.logger.warn('pub_key.pem 不存在,跳过验签')
return null
} }
// 2. 解密 resource if (!verified) {
this.logger.warn(`微信支付回调验签失败 — 请从商户平台下载最新公钥覆盖 pub_key.pem (https://pay.weixin.qq.com/)`)
}
// 2. 解密 resource(解密不依赖公钥,即使验签失败也尝试解密)
try {
const resource = body.resource const resource = body.resource
const ciphertext = Buffer.from(resource.ciphertext, 'base64') const ciphertext = Buffer.from(resource.ciphertext, 'base64')
const associatedData = resource.associated_data || '' const associatedData = resource.associated_data || ''
const nonce = resource.nonce const nonce = resource.nonce
const key = API_V3_KEY const key = API_V3_KEY
if (!key) throw new Error('WX_API_V3_KEY 未配置') if (!key) throw new Error('WX_API_V3_KEY 未配置')
// AES-256-GCM 解密
const authTag = ciphertext.subarray(ciphertext.length - 16) const authTag = ciphertext.subarray(ciphertext.length - 16)
const data = ciphertext.subarray(0, ciphertext.length - 16) const data = ciphertext.subarray(0, ciphertext.length - 16)
const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(key), nonce) const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(key), nonce)
decipher.setAAD(Buffer.from(associatedData)) decipher.setAAD(Buffer.from(associatedData))
decipher.setAuthTag(authTag) decipher.setAuthTag(authTag)
const decrypted = decipher.update(data) + decipher.final('utf8') const decrypted = decipher.update(data) + decipher.final('utf8')
return JSON.parse(decrypted) const parsed = JSON.parse(decrypted)
if (returnRaw) return parsed
if (!verified) return null
return parsed
} catch (e) {
this.logger.error(`解密回调 resource 失败: ${e.message}`)
return null
}
} }
/** 查询订单 */ /** 查询订单 */
async queryOrder(outTradeNo: string) { async queryOrder(outTradeNo: string) {
return this.request('GET', `/v3/pay/transactions/out-trade-no/${outTradeNo}?mchid=${MCHID}`) return this.request('GET', `/v3/pay/transactions/out-trade-no/${outTradeNo}?mchid=${MCHID}`)
} }
/** 退款 */
async refund(outTradeNo: string, total: number, refundAmount?: number, reason?: string) {
const body: any = {
out_trade_no: outTradeNo,
out_refund_no: `RF${Date.now()}`,
amount: { refund: refundAmount || total, total, currency: 'CNY' },
}
if (reason) body.reason = reason
return this.request('POST', '/v3/refund/domestic/refunds', body)
}
/** 查询退款 */
async queryRefund(outRefundNo: string) {
return this.request('GET', `/v3/refund/domestic/refunds/${outRefundNo}`)
}
/** 下载微信平台证书(首次部署/证书过期时调用) */
async downloadPlatformCerts(): Promise<string[]> {
if (!API_V3_KEY) throw new Error('WX_API_V3_KEY 未配置')
const certs = await this.request('GET', '/v3/certificates')
const downloaded: string[] = []
const certDir = path.resolve(__dirname, '../../certs')
if (!fs.existsSync(certDir)) fs.mkdirSync(certDir, { recursive: true })
for (const item of certs.data || []) {
const { serial_no, effective_time, expire_time, encrypt_certificate } = item
const { algorithm, nonce, associated_data, ciphertext } = encrypt_certificate
if (algorithm !== 'AEAD_AES_256_GCM' || !nonce) continue
const cipherBuf = Buffer.from(ciphertext, 'base64')
const authTag = cipherBuf.subarray(cipherBuf.length - 16)
const data = cipherBuf.subarray(0, cipherBuf.length - 16)
const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(API_V3_KEY), nonce)
decipher.setAAD(Buffer.from(associated_data))
decipher.setAuthTag(authTag)
const decrypted = decipher.update(data) + decipher.final('utf8')
const pemPath = path.join(certDir, 'pub_key.pem')
fs.writeFileSync(pemPath, decrypted)
downloaded.push(serial_no)
this.logger.log(`微信平台证书已更新: ${serial_no}, 有效期至 ${expire_time}`)
}
return downloaded
}
} }
@@ -1,20 +1,22 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"
import { Document } from 'mongoose' import { Document } from "mongoose"
export type HotPositionDocument = HotPosition & Document export type HotPositionDocument = HotPosition & Document
export type PositionCategory = "ai" | "traditional"
@Schema({ timestamps: true }) @Schema({ timestamps: true })
export class HotPosition { export class HotPosition {
@Prop({ required: true }) @Prop({ required: true })
name: string name: string
@Prop({ default: '' }) @Prop({ default: "" })
salary?: string salary?: string
@Prop({ default: '' }) @Prop({ default: "" })
company?: string company?: string
@Prop({ default: '' }) @Prop({ default: "" })
icon?: string icon?: string
@Prop({ default: 0 }) @Prop({ default: 0 })
@@ -22,7 +24,11 @@ export class HotPosition {
@Prop({ default: true }) @Prop({ default: true })
active: boolean active: boolean
@Prop({ type: String, enum: ["ai", "traditional"], default: "traditional" })
category: PositionCategory
} }
export const HotPositionSchema = SchemaFactory.createForClass(HotPosition) export const HotPositionSchema = SchemaFactory.createForClass(HotPosition)
HotPositionSchema.index({ sort: 1 }) HotPositionSchema.index({ sort: 1 })
HotPositionSchema.index({ category: 1, active: 1 })
@@ -31,13 +31,18 @@ export class ResumePdfService {
} }
} }
private escapeHtml(str: string): string {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/"/g, '&quot;').replace(/'/g, '&#039;')
}
private buildHtml(params: { private buildHtml(params: {
title: string title: string
content: string content: string
targetPosition?: string targetPosition?: string
userName?: string userName?: string
}): string { }): string {
const contentHtml = params.content const contentHtml = this.escapeHtml(params.content)
.replace(/\n/g, '<br>') .replace(/\n/g, '<br>')
.replace(/### (.+)/g, '<h3>$1</h3>') .replace(/### (.+)/g, '<h3>$1</h3>')
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>') .replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
@@ -66,8 +71,8 @@ export class ResumePdfService {
</head> </head>
<body> <body>
<div class="page"> <div class="page">
<h1>${params.title}</h1> <h1>${this.escapeHtml(params.title)}</h1>
<div class="subtitle">${params.targetPosition ? `目标岗位: ${params.targetPosition}` : ''}</div> <div class="subtitle">${params.targetPosition ? `目标岗位: ${this.escapeHtml(params.targetPosition)}` : ''}</div>
<div class="content">${contentHtml}</div> <div class="content">${contentHtml}</div>
<div class="footer">由 AI磁场·职引 生成</div> <div class="footer">由 AI磁场·职引 生成</div>
</div> </div>
@@ -31,13 +31,10 @@ export class ResumeController {
@Post(':id/download') @Post(':id/download')
async download(@Param('id') id: string, @CurrentUser('userId') userId: string, @Res() res: Response) { async download(@Param('id') id: string, @CurrentUser('userId') userId: string, @Res() res: Response) {
const resume = await this.resumeService.getDetail(id, userId) const resume = await this.resumeService.getDetail(id, userId)
const canDownload = await this.quotaService.checkAndDeductDownload(userId, resume.paidDownload)
const canDownload = await this.quotaService.checkDownload(userId, resume) if (!canDownload && !resume.paidDownload) {
if (!canDownload) {
throw new HttpException('请先付费下载', HttpStatus.PAYMENT_REQUIRED) throw new HttpException('请先付费下载', HttpStatus.PAYMENT_REQUIRED)
} }
await this.quotaService.deductDownload(userId, resume)
if (!resume.paidDownload) { if (!resume.paidDownload) {
await this.resumeService.markPaid(id, userId) await this.resumeService.markPaid(id, userId)
} }
@@ -18,8 +18,8 @@ const DEFAULT_PRICING: PricingConfig = {
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 }, resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 }, resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
plans: { plans: {
growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: [] }, growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'] },
sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: [] }, sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先', '简历优化 50 次/月', '简历下载 30 次/月'] },
}, },
} }
@@ -0,0 +1,69 @@
import { Controller, Get, Post, Body, Param, Query, HttpException, HttpStatus, UseGuards } from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'
import { ShareService } from './share.service'
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
import { CurrentUser } from '../../common/decorators/current-user.decorator'
import { Public } from '../../common/decorators/public.decorator'
@Controller('share')
export class ShareController {
constructor(
private shareService: ShareService,
private jwtService: JwtService,
) {}
@UseGuards(JwtAuthGuard)
@Post('create')
async create(
@CurrentUser('userId') userId: string,
@Body() body: { type: string; refId?: string; title?: string; description?: string },
) {
return this.shareService.create(userId, body)
}
@Public()
@Get('visit/:shareCode')
async visit(
@Param('shareCode') shareCode: string,
@Query('visitorId') visitorId?: string,
@Query('token') token?: string,
) {
if (!visitorId) {
throw new HttpException('缺少访问者标识', HttpStatus.BAD_REQUEST)
}
let visitorUserId: string | undefined
if (token) {
try {
const payload = this.jwtService.verify(token) as any
visitorUserId = payload.userId
} catch {}
}
return this.shareService.visit(shareCode, visitorId, visitorUserId)
}
@UseGuards(JwtAuthGuard)
@Get('stats')
async stats(@CurrentUser('userId') userId: string) {
return this.shareService.stats(userId)
}
@UseGuards(JwtAuthGuard)
@Get('records')
async records(
@CurrentUser('userId') userId: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
) {
return this.shareService.records(userId, Number(page) || 1, Number(pageSize) || 20)
}
@UseGuards(JwtAuthGuard)
@Get('visitors')
async visitors(
@CurrentUser('userId') userId: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
) {
return this.shareService.visitors(userId, Number(page) || 1, Number(pageSize) || 20)
}
}
+26
View File
@@ -0,0 +1,26 @@
import { Module } from '@nestjs/common'
import { JwtModule } from '@nestjs/jwt'
import { MongooseModule } from '@nestjs/mongoose'
import { ShareController } from './share.controller'
import { ShareService } from './share.service'
import { ShareRecord, ShareRecordSchema, ShareVisit, ShareVisitSchema } from './share.schema'
import { UserModule } from '../user/user.module'
import { User, UserSchema } from '../user/user.schema'
@Module({
imports: [
MongooseModule.forFeature([
{ name: ShareRecord.name, schema: ShareRecordSchema },
{ name: ShareVisit.name, schema: ShareVisitSchema },
{ name: User.name, schema: UserSchema },
]),
UserModule,
JwtModule.register({
secret: process.env.JWT_SECRET,
signOptions: { expiresIn: '7d' },
}),
],
controllers: [ShareController],
providers: [ShareService],
})
export class ShareModule {}
+72
View File
@@ -0,0 +1,72 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
export type ShareRecordDocument = ShareRecord & Document
export type ShareVisitDocument = ShareVisit & Document
@Schema({ timestamps: true })
export class ShareRecord {
@Prop({ type: Types.ObjectId, ref: 'User', required: true })
userId: Types.ObjectId
@Prop({ required: true, unique: true })
shareCode: string
@Prop({ default: 'app' })
type: string
@Prop({ default: '' })
refId: string
@Prop({ default: '' })
title: string
@Prop({ default: '' })
description: string
@Prop({ default: 'link' })
channel: string
@Prop({ default: 0 })
visitCount: number
@Prop({ default: 0 })
creditedCount: number
@Prop({ default: true })
isActive: boolean
readonly createdAt?: Date
readonly updatedAt?: Date
}
@Schema({ timestamps: true })
export class ShareVisit {
@Prop({ type: Types.ObjectId, ref: 'ShareRecord', required: true })
shareId: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'User', required: true })
sharerId: Types.ObjectId
@Prop({ required: true })
visitorId: string
@Prop({ type: Types.ObjectId, ref: 'User' })
visitorUserId: Types.ObjectId
@Prop({ default: false })
credited: boolean
@Prop()
creditedAt?: Date
readonly createdAt?: Date
readonly updatedAt?: Date
}
export const ShareRecordSchema = SchemaFactory.createForClass(ShareRecord)
export const ShareVisitSchema = SchemaFactory.createForClass(ShareVisit)
ShareRecordSchema.index({ userId: 1, createdAt: -1 })
ShareVisitSchema.index({ shareId: 1, visitorId: 1 }, { unique: true })
ShareVisitSchema.index({ sharerId: 1, createdAt: -1 })
+186
View File
@@ -0,0 +1,186 @@
import * as crypto from 'crypto'
import { Injectable, HttpException, HttpStatus, Logger } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import { Model, Types } from 'mongoose'
import { ShareRecord, ShareRecordDocument, ShareVisit, ShareVisitDocument } from './share.schema'
import { QuotaService } from '../user/quota.service'
import { User, UserDocument } from '../user/user.schema'
const DAILY_LIMIT = 3
const LINK_TTL_DAYS = 30
@Injectable()
export class ShareService {
private readonly logger = new Logger(ShareService.name)
constructor(
@InjectModel(ShareRecord.name) private shareModel: Model<ShareRecordDocument>,
@InjectModel(ShareVisit.name) private visitModel: Model<ShareVisitDocument>,
@InjectModel(User.name) private userModel: Model<UserDocument>,
private quotaService: QuotaService,
) {}
async create(userId: string, body: { type: string; refId?: string; title?: string; description?: string }) {
const shareCode = crypto.randomBytes(4).toString('hex')
const record = await this.shareModel.create({
userId: new Types.ObjectId(userId),
shareCode,
type: body.type || 'app',
refId: body.refId || '',
title: body.title || '我在职引发现了好东西',
description: body.description || '快来一起体验吧',
})
return {
shareCode: record.shareCode,
shareUrl: `/share/${record.shareCode}`,
wechatShareInfo: {
title: record.title,
description: record.description,
path: `/pages/share/share?code=${record.shareCode}`,
},
}
}
async visit(shareCode: string, visitorId: string, visitorUserId?: string) {
const share = await this.shareModel.findOne({ shareCode, isActive: true }).exec()
if (!share) throw new HttpException('分享链接不存在或已失效', HttpStatus.NOT_FOUND)
await this.shareModel.findByIdAndUpdate(share._id, { $inc: { visitCount: 1 } }).exec()
const sharerIdStr = share.userId.toString()
if (!visitorUserId || visitorUserId === sharerIdStr) {
return { sharer: true, visitorUserId }
}
const existing = await this.visitModel.findOne({
shareId: share._id,
visitorId,
}).exec()
if (existing) return { alreadyVisited: true, visitorUserId }
await this.visitModel.create({
shareId: share._id,
sharerId: share.userId,
visitorId,
visitorUserId: new Types.ObjectId(visitorUserId),
}).catch(() => {})
const alreadyCredited = await this.visitModel.findOne({
shareId: share._id,
visitorId,
credited: true,
}).exec()
if (alreadyCredited) return { credited: true, visitorUserId }
const todayStart = new Date()
todayStart.setHours(0, 0, 0, 0)
const todayCredited = await this.visitModel.countDocuments({
sharerId: share.userId,
credited: true,
creditedAt: { $gte: todayStart },
}).exec()
if (todayCredited >= DAILY_LIMIT) return { dailyLimitReached: true, visitorUserId }
const shareCreditsResult = await this.quotaService.grantShareCredits(sharerIdStr)
if (!shareCreditsResult) return { creditFailed: true, visitorUserId }
await this.visitModel.updateOne(
{ shareId: share._id, visitorId },
{ $set: { credited: true, creditedAt: new Date() } },
).exec()
await this.shareModel.findByIdAndUpdate(share._id, { $inc: { creditedCount: 1 } }).exec()
return { credited: true, visitorUserId }
}
async stats(userId: string) {
const todayStart = new Date()
todayStart.setHours(0, 0, 0, 0)
const [totalShares, visitAgg, todayAgg, user] = await Promise.all([
this.shareModel.countDocuments({ userId: new Types.ObjectId(userId) }).exec(),
this.visitModel.aggregate([
{ $match: { sharerId: new Types.ObjectId(userId) } },
{
$group: {
_id: null,
totalVisits: { $sum: 1 },
creditedCount: { $sum: { $cond: ['$credited', 1, 0] } },
},
},
]).exec(),
this.visitModel.countDocuments({
sharerId: new Types.ObjectId(userId),
credited: true,
creditedAt: { $gte: todayStart },
}).exec(),
this.userModel.findById(userId).exec(),
])
return {
totalShares,
totalVisits: visitAgg[0]?.totalVisits ?? 0,
creditedCount: visitAgg[0]?.creditedCount ?? 0,
todayCredited: todayAgg,
shareCredits: user?.shareCredits ?? 0,
}
}
async records(userId: string, page = 1, pageSize = 20) {
const list = await this.shareModel.find({ userId: new Types.ObjectId(userId) })
.sort({ createdAt: -1 })
.skip((page - 1) * pageSize)
.limit(pageSize)
.exec()
const total = await this.shareModel.countDocuments({ userId: new Types.ObjectId(userId) }).exec()
return {
list: list.map(r => ({
shareCode: r.shareCode,
type: r.type,
title: r.title,
visitCount: r.visitCount,
creditedCount: r.creditedCount,
createdAt: r.createdAt,
})),
total,
page,
pageSize,
}
}
async visitors(userId: string, page = 1, pageSize = 20) {
const [list, total] = await Promise.all([
this.visitModel.aggregate([
{ $match: { sharerId: new Types.ObjectId(userId) } },
{ $sort: { createdAt: -1 } },
{ $skip: (page - 1) * pageSize },
{ $limit: pageSize },
{
$lookup: {
from: 'users',
localField: 'visitorUserId',
foreignField: '_id',
as: 'visitorUser',
},
},
{ $unwind: { path: '$visitorUser', preserveNullAndEmptyArrays: true } },
{
$project: {
_id: 0,
visitorId: 1,
credited: 1,
creditedAt: 1,
createdAt: 1,
nickname: { $ifNull: ['$visitorUser.nickname', '匿名用户'] },
avatar: { $ifNull: ['$visitorUser.avatar', ''] },
},
},
]).exec(),
this.visitModel.countDocuments({ sharerId: new Types.ObjectId(userId) }).exec(),
])
return { list, total, page, pageSize }
}
}
+39 -3
View File
@@ -1,21 +1,25 @@
import { Controller, Get, Post, Body, Param, Res, HttpException, HttpStatus } from '@nestjs/common' import { Controller, Get, Post, Body, Param, Res, HttpException, HttpStatus, UseGuards, UploadedFile, UseInterceptors } from '@nestjs/common'
import { FileInterceptor } from '@nestjs/platform-express'
import { Response } from 'express' import { Response } from 'express'
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path'
import { execSync } from 'child_process'
import { TtsService } from './tts.service' import { TtsService } from './tts.service'
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
import { Public } from '../../common/decorators/public.decorator' import { Public } from '../../common/decorators/public.decorator'
@Controller('tts') @Controller('tts')
export class TtsController { export class TtsController {
constructor(private ttsService: TtsService) {} constructor(private ttsService: TtsService) {}
@Public() @UseGuards(JwtAuthGuard)
@Post('synthesize') @Post('synthesize')
async synthesize(@Body('text') text: string, @Body('voice') voice?: string) { async synthesize(@Body('text') text: string, @Body('voice') voice?: string) {
if (!text || text.length > 500) { if (!text || text.length > 500) {
throw new HttpException('文本不能为空且不超过500字', HttpStatus.BAD_REQUEST) throw new HttpException('文本不能为空且不超过500字', HttpStatus.BAD_REQUEST)
} }
const result = await this.ttsService.synthesize(text, voice) const result = await this.ttsService.synthesize(text, voice)
return { hash: result.hash, durationMs: result.durationMs } return { hash: result.hash, durationMs: result.durationMs, amplitudeData: result.amplitudeData }
} }
@Public() @Public()
@@ -30,4 +34,36 @@ export class TtsController {
res.setHeader('Cache-Control', 'public, max-age=31536000') res.setHeader('Cache-Control', 'public, max-age=31536000')
stream.pipe(res) stream.pipe(res)
} }
@UseGuards(JwtAuthGuard)
@Post('asr')
@UseInterceptors(FileInterceptor('audio', { dest: '/tmp/asr_uploads' }))
async recognize(@UploadedFile() file: any) {
if (!file) throw new HttpException('请上传音频文件', HttpStatus.BAD_REQUEST)
const uploadDir = '/tmp/asr_uploads'
if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir, { recursive: true })
const ext = path.extname(file.originalname) || '.mp3'
const dest = path.join(uploadDir, file.filename + ext)
fs.renameSync(file.path, dest)
try {
if (process.env.OPENAI_API_KEY) {
const result = execSync(
`curl -s -X POST https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer ${process.env.OPENAI_API_KEY}" \
-H "Content-Type: multipart/form-data" \
-F "file=@${dest}" \
-F "model=whisper-1" \
-F "language=zh"`,
{ encoding: 'utf8', timeout: 30000 },
)
const parsed = JSON.parse(result)
if (parsed.text) return { text: parsed.text.trim() }
}
const whisperResult = execSync(`python3 -c 'import sys, whisper; model = whisper.load_model("tiny"); print(model.transcribe(sys.argv[1], language="zh")["text"].strip())' "${dest}"`, { encoding: 'utf8', timeout: 60000 })
if (whisperResult && whisperResult.trim()) {
return { text: whisperResult.trim() }
}
} catch {}
return { text: '' }
}
} }
+60 -2
View File
@@ -10,6 +10,19 @@ interface TtsResult {
hash: string hash: string
filePath: string filePath: string
durationMs: number durationMs: number
amplitudeData: number[]
}
const VALID_VOICES = new Set([
'zh-CN-XiaoxiaoNeural', 'zh-CN-XiaoyiNeural', 'zh-CN-YunjianNeural',
'zh-CN-YunxiNeural', 'zh-CN-YunxiaNeural', 'zh-CN-YunyangNeural',
'zh-CN-liaoning-XiaobeiNeural', 'zh-CN-shaanxi-XiaoniNeural',
])
function validateVoice(voice: string): void {
if (!VALID_VOICES.has(voice)) {
throw new Error(`不支持的语音: ${voice}`)
}
} }
@Injectable() @Injectable()
@@ -23,12 +36,16 @@ export class TtsService {
} }
async synthesize(text: string, voice: string = 'zh-CN-XiaoxiaoNeural'): Promise<TtsResult> { async synthesize(text: string, voice: string = 'zh-CN-XiaoxiaoNeural'): Promise<TtsResult> {
validateVoice(voice)
const hash = crypto.createHash('md5').update(text + voice).digest('hex') const hash = crypto.createHash('md5').update(text + voice).digest('hex')
const filePath = path.join(CACHE_DIR, `${hash}.mp3`) const filePath = path.join(CACHE_DIR, `${hash}.mp3`)
if (fs.existsSync(filePath)) { if (fs.existsSync(filePath)) {
const durationMs = await this.getDuration(filePath) const durationMs = await this.getDuration(filePath)
return { hash, filePath, durationMs } const amplitudeData = this.loadAmplitudeData(hash)
if (amplitudeData) {
return { hash, filePath, durationMs, amplitudeData }
}
} }
try { try {
@@ -37,8 +54,9 @@ export class TtsService {
{ timeout: 30000 }, { timeout: 30000 },
) )
const durationMs = await this.getDuration(filePath) const durationMs = await this.getDuration(filePath)
const amplitudeData = this.extractAmplitude(filePath, hash)
this.logger.log(`TTS generated: hash=${hash} text="${text.slice(0, 40)}..." duration=${durationMs}ms`) this.logger.log(`TTS generated: hash=${hash} text="${text.slice(0, 40)}..." duration=${durationMs}ms`)
return { hash, filePath, durationMs } return { hash, filePath, durationMs, amplitudeData }
} catch (e) { } catch (e) {
this.logger.error(`TTS failed: ${e.message}`) this.logger.error(`TTS failed: ${e.message}`)
throw e throw e
@@ -50,6 +68,46 @@ export class TtsService {
return fs.existsSync(filePath) ? filePath : null return fs.existsSync(filePath) ? filePath : null
} }
private extractAmplitude(mp3Path: string, hash: string): number[] {
try {
const pcmPath = `/tmp/tts-cache/${hash}.pcm`
execSync(
`ffmpeg -y -i "${mp3Path}" -f s16le -acodec pcm_s16le -ar 16000 -ac 1 "${pcmPath}" 2>/dev/null`,
{ timeout: 10000 },
)
const pcmBuf = fs.readFileSync(pcmPath)
const samples = new Int16Array(pcmBuf.buffer, pcmBuf.byteOffset, pcmBuf.byteLength / 2)
const chunkSize = Math.floor(16000 * 0.05) // 50ms
const amplitudes: number[] = []
for (let i = 0; i < samples.length; i += chunkSize) {
const end = Math.min(i + chunkSize, samples.length)
let sumSq = 0
for (let j = i; j < end; j++) {
sumSq += samples[j] * samples[j]
}
const rms = Math.sqrt(sumSq / (end - i))
amplitudes.push(Number((Math.min(1, rms / 16000)).toFixed(4)))
}
try { fs.unlinkSync(pcmPath) } catch {}
const ampPath = `/tmp/tts-cache/${hash}.amp`
fs.writeFileSync(ampPath, JSON.stringify(amplitudes))
return amplitudes
} catch (e) {
this.logger.warn(`振幅提取失败: ${e.message}`)
return []
}
}
private loadAmplitudeData(hash: string): number[] | null {
try {
const ampPath = `/tmp/tts-cache/${hash}.amp`
if (!fs.existsSync(ampPath)) return null
return JSON.parse(fs.readFileSync(ampPath, 'utf8'))
} catch {
return null
}
}
private escapeText(text: string): string { private escapeText(text: string): string {
return text.replace(/"/g, '\\"').replace(/\n/g, ' ').replace(/\r/g, '') return text.replace(/"/g, '\\"').replace(/\n/g, ' ').replace(/\r/g, '')
} }
+87 -50
View File
@@ -1,4 +1,4 @@
import { Injectable, HttpException, HttpStatus } from '@nestjs/common' import { Injectable, HttpException, HttpStatus, Logger } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose' import { InjectModel } from '@nestjs/mongoose'
import { Model } from 'mongoose' import { Model } from 'mongoose'
import { User, UserDocument } from './user.schema' import { User, UserDocument } from './user.schema'
@@ -7,6 +7,8 @@ const FREE_OPTIMIZE_LIMIT = 3
@Injectable() @Injectable()
export class QuotaService { export class QuotaService {
private readonly logger = new Logger(QuotaService.name)
constructor( constructor(
@InjectModel(User.name) private userModel: Model<UserDocument>, @InjectModel(User.name) private userModel: Model<UserDocument>,
) {} ) {}
@@ -16,12 +18,28 @@ export class QuotaService {
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
if (user.plan !== 'free') return if (user.plan !== 'free') return
if ((user.interviewCredits || 0) <= 0) { // Backward compat: migrate remaining → interviewCredits
throw new HttpException('面试次数已用完,请购买面试次数或开通会员', HttpStatus.FORBIDDEN) if ((user.interviewCredits ?? 0) <= 0 && (user.remaining ?? 0) > 0) {
await this.userModel.findByIdAndUpdate(userId, {
$set: { interviewCredits: user.remaining, remaining: 0 },
}).exec()
} }
user.interviewCredits = (user.interviewCredits || 0) - 1
user.interviewCount = (user.interviewCount || 0) + 1 const result = await this.userModel.findOneAndUpdate(
await user.save() { _id: userId, interviewCredits: { $gt: 0 } },
{ $inc: { interviewCredits: -1, interviewCount: 1 } },
{ new: true },
).exec()
if (result) return
// Fallback to share credits
const shareResult = await this.userModel.findOneAndUpdate(
{ _id: userId, shareCredits: { $gt: 0 } },
{ $inc: { shareCredits: -1, interviewCount: 1 } },
).exec()
if (shareResult) return
throw new HttpException('面试次数已用完,请购买面试次数或开通会员', HttpStatus.FORBIDDEN)
} }
async checkAndDeductOptimize(userId: string) { async checkAndDeductOptimize(userId: string) {
@@ -29,64 +47,83 @@ export class QuotaService {
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
if (user.plan !== 'free') return if (user.plan !== 'free') return
// 优先扣付费额度 // Try paid credits first
if ((user.resumeOptimizeCredits || 0) > 0) { const paid = await this.userModel.findOneAndUpdate(
user.resumeOptimizeCredits = (user.resumeOptimizeCredits || 0) - 1 { _id: userId, resumeOptimizeCredits: { $gt: 0 } },
await user.save() { $inc: { resumeOptimizeCredits: -1 } },
return ).exec()
} if (paid) return
// 免费额度 // Try old remaining credits (backward compat)
if ((user.freeOptimizeUsed || 0) < FREE_OPTIMIZE_LIMIT) { const oldRemaining = await this.userModel.findOneAndUpdate(
user.freeOptimizeUsed = (user.freeOptimizeUsed || 0) + 1 { _id: userId, remaining: { $gt: 0 } },
await user.save() { $inc: { remaining: -1 } },
return ).exec()
} if (oldRemaining) return
// Then free limit
const freeResult = await this.userModel.findOneAndUpdate(
{ _id: userId, freeOptimizeUsed: { $lt: FREE_OPTIMIZE_LIMIT } },
{ $inc: { freeOptimizeUsed: 1 } },
).exec()
if (freeResult) return
// Fallback to share credits
const shareResult = await this.userModel.findOneAndUpdate(
{ _id: userId, shareCredits: { $gt: 0 } },
{ $inc: { shareCredits: -1 } },
).exec()
if (shareResult) return
throw new HttpException('简历优化次数已用完,请购买优化次数或开通会员', HttpStatus.FORBIDDEN) throw new HttpException('简历优化次数已用完,请购买优化次数或开通会员', HttpStatus.FORBIDDEN)
} }
async checkDownload(userId: string, resume: { paidDownload?: boolean }): Promise<boolean> { async grantShareCredits(userId: string, amount = 1): Promise<boolean> {
const user = await this.userModel.findById(userId).exec() const result = await this.userModel.findByIdAndUpdate(
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) userId,
{ $inc: { shareCredits: amount } },
if (resume.paidDownload) return true ).exec()
if ((user.resumeDownloadCredits || 0) > 0) return true return !!result
return false
} }
async deductDownload(userId: string, resume: { paidDownload?: boolean; _id?: any }) { async checkAndDeductDownload(userId: string, paidDownload: boolean): Promise<boolean> {
const user = await this.userModel.findById(userId).exec() if (paidDownload) return true
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
if (resume.paidDownload) return const result = await this.userModel.findOneAndUpdate(
if ((user.resumeDownloadCredits || 0) > 0) { { _id: userId, resumeDownloadCredits: { $gt: 0 } },
user.resumeDownloadCredits = (user.resumeDownloadCredits || 0) - 1 { $inc: { resumeDownloadCredits: -1 } },
await user.save() ).exec()
} return !!result
} }
async grantCredits(userId: string, type: 'interview' | 'optimize' | 'download', amount: number) { async grantCredits(userId: string, type: 'interview' | 'optimize' | 'download', amount: number) {
const user = await this.userModel.findById(userId).exec() if (amount <= 0) throw new HttpException('无效数量', HttpStatus.BAD_REQUEST)
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
if (type === 'interview') user.interviewCredits = (user.interviewCredits || 0) + amount const fieldMap: Record<string, string> = {
else if (type === 'optimize') user.resumeOptimizeCredits = (user.resumeOptimizeCredits || 0) + amount interview: 'interviewCredits',
else if (type === 'download') user.resumeDownloadCredits = (user.resumeDownloadCredits || 0) + amount optimize: 'resumeOptimizeCredits',
download: 'resumeDownloadCredits',
}
const field = fieldMap[type]
if (!field) throw new HttpException('无效类型', HttpStatus.BAD_REQUEST)
await user.save() const result = await this.userModel.findByIdAndUpdate(
userId,
{ $inc: { [field]: amount } },
).exec()
if (!result) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
} }
async setPlanQuota(userId: string, plan: string, credits: { interview: number; resumeOptimize: number; resumeDownload: number }) { async setPlanQuota(userId: string, _plan: string, credits: { interview: number; resumeOptimize: number; resumeDownload: number }) {
const user = await this.userModel.findById(userId).exec() const result = await this.userModel.findByIdAndUpdate(userId, {
if (!user) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND) $set: {
remaining: 999,
user.remaining = 999 interviewCredits: credits.interview,
user.interviewCredits = credits.interview resumeOptimizeCredits: credits.resumeOptimize,
user.resumeOptimizeCredits = credits.resumeOptimize resumeDownloadCredits: credits.resumeDownload,
user.resumeDownloadCredits = credits.resumeDownload freeOptimizeUsed: FREE_OPTIMIZE_LIMIT,
user.freeOptimizeUsed = FREE_OPTIMIZE_LIMIT // 会员不再消耗免费次数 },
}).exec()
await user.save() if (!result) throw new HttpException('用户不存在', HttpStatus.NOT_FOUND)
} }
} }
+8 -1
View File
@@ -1,4 +1,4 @@
import { Controller, Post, Get, Put, Body, Req } from '@nestjs/common' import { Controller, Post, Get, Put, Body, Req, HttpCode, HttpStatus } from '@nestjs/common'
import { UserService } from './user.service' import { UserService } from './user.service'
import { Public } from '../../common/decorators/public.decorator' import { Public } from '../../common/decorators/public.decorator'
import { CurrentUser } from '../../common/decorators/current-user.decorator' import { CurrentUser } from '../../common/decorators/current-user.decorator'
@@ -9,12 +9,14 @@ export class UserController {
@Public() @Public()
@Post('send-code') @Post('send-code')
@HttpCode(HttpStatus.OK)
async sendCode(@Body('phone') phone: string) { async sendCode(@Body('phone') phone: string) {
return this.userService.sendCode(phone) return this.userService.sendCode(phone)
} }
@Public() @Public()
@Post('login') @Post('login')
@HttpCode(HttpStatus.OK)
async login(@Body('phone') phone: string, @Body('code') code: string) { async login(@Body('phone') phone: string, @Body('code') code: string) {
return this.userService.loginByPhone(phone, code) return this.userService.loginByPhone(phone, code)
} }
@@ -22,12 +24,14 @@ export class UserController {
// 📧 邮箱验证码登录(H5 用) // 📧 邮箱验证码登录(H5 用)
@Public() @Public()
@Post('send-email-code') @Post('send-email-code')
@HttpCode(HttpStatus.OK)
async sendEmailCode(@Body('email') email: string) { async sendEmailCode(@Body('email') email: string) {
return this.userService.sendEmailCode(email) return this.userService.sendEmailCode(email)
} }
@Public() @Public()
@Post('email-login') @Post('email-login')
@HttpCode(HttpStatus.OK)
async emailLogin(@Body('email') email: string, @Body('code') code: string) { async emailLogin(@Body('email') email: string, @Body('code') code: string) {
return this.userService.loginByEmail(email, code) return this.userService.loginByEmail(email, code)
} }
@@ -35,6 +39,7 @@ export class UserController {
// 密码登录 // 密码登录
@Public() @Public()
@Post('password-login') @Post('password-login')
@HttpCode(HttpStatus.OK)
async passwordLogin(@Body('email') email: string, @Body('password') password: string) { async passwordLogin(@Body('email') email: string, @Body('password') password: string) {
return this.userService.loginByPassword(email, password) return this.userService.loginByPassword(email, password)
} }
@@ -42,6 +47,7 @@ export class UserController {
// 邮箱+密码注册 // 邮箱+密码注册
@Public() @Public()
@Post('register') @Post('register')
@HttpCode(HttpStatus.OK)
async register(@Body('email') email: string, @Body('password') password: string) { async register(@Body('email') email: string, @Body('password') password: string) {
return this.userService.registerWithPassword(email, password) return this.userService.registerWithPassword(email, password)
} }
@@ -49,6 +55,7 @@ export class UserController {
// 微信静默登录 // 微信静默登录
@Public() @Public()
@Post('wx-login') @Post('wx-login')
@HttpCode(HttpStatus.OK)
async wxLogin(@Body('code') code: string) { async wxLogin(@Body('code') code: string) {
return this.userService.loginByWx(code) return this.userService.loginByWx(code)
} }
+3
View File
@@ -48,6 +48,9 @@ export class User {
@Prop({ default: 0 }) @Prop({ default: 0 })
freeOptimizeUsed: number // 已使用免费优化次数(上限 3 freeOptimizeUsed: number // 已使用免费优化次数(上限 3
@Prop({ default: 0 })
shareCredits: number // 分享积分,每 3 次有效访问获 1 积分
@Prop({ default: 'user' }) @Prop({ default: 'user' })
role: string // 'user' | 'admin' role: string // 'user' | 'admin'
+1
View File
@@ -215,6 +215,7 @@ export class UserService {
resumeOptimizeCredits: user.resumeOptimizeCredits ?? 0, resumeOptimizeCredits: user.resumeOptimizeCredits ?? 0,
resumeDownloadCredits: user.resumeDownloadCredits ?? 0, resumeDownloadCredits: user.resumeDownloadCredits ?? 0,
freeOptimizeUsed: user.freeOptimizeUsed ?? 0, freeOptimizeUsed: user.freeOptimizeUsed ?? 0,
shareCredits: user.shareCredits ?? 0,
} }
} }
} }
+42 -6
View File
@@ -1,8 +1,8 @@
# 职引 · 完整功能清单 v4.1 # 职引 · 完整功能清单 v4.3
> **版本**: v4.1 > **版本**: v4.5
> **日期**: 2026-06-09 > **日期**: 2026-06-17
> **状态**: Phase 0.5 壁垒构建完成 > **状态**: Phase 1.5 启动:面试复盘 + AI 择业顾问 MVP 就绪
> **定位**: 应届生/实习生 AI 面试教练 > **定位**: 应届生/实习生 AI 面试教练
--- ---
@@ -41,6 +41,29 @@
| 连续打卡日历 | ✅ 完成 | 面试频率可视化,连续打卡激励 | P1 | | 连续打卡日历 | ✅ 完成 | 面试频率可视化,连续打卡激励 | P1 |
| 每日一题推送 | ⚠️ 半完成 | 首页展示 + API 读取,**无定时推送** | P0 | | 每日一题推送 | ⚠️ 半完成 | 首页展示 + API 读取,**无定时推送** | P0 |
### 1.4 面试复盘(新增)
| 功能 | 状态 | 描述 | 优先级 |
|------|------|------|--------|
| 音频文件上传 | ✅ 完成 | 支持 MP3/M4A/WAV/AAC/OGG/MP4/WebM50MB 上限 | P0 |
| 文本转录粘贴 | ✅ 完成 | 直接粘贴面试转录文本提交 | P0 |
| whisper.cpp ASR | ✅ 完成 | 本地离线语音转文字,支持 tiny/base 模型 | P0 |
| AI 面试评析 | ✅ 完成 | 四维评分(逻辑/表达/专业度/稳定性)+ 逐题评估 | P0 |
| 口语分析 | ✅ 完成 | 填充词检测 + 语速评估 | P0 |
| 无 ASR 回落 | ✅ 完成 | whisper 不可用时自动使用 mock | P1 |
| 历史记录管理 | ✅ 完成 | 列表/详情/删除 | P0 |
### 1.5 AI 择业顾问(新增)
| 功能 | 状态 | 描述 | 优先级 |
|------|------|------|--------|
| AI 专业/兴趣/性格分析 | ✅ 完成 | 基于用户输入的学业/兴趣/性格信息,AI 生成个性化职业分析 | P0 |
| 智能岗位匹配推荐 | ✅ 完成 | 对接热门岗位数据,推荐 3-5 个匹配岗位 | P0 |
| 个性化职业发展建议 | ✅ 完成 | 含短期/中期/长期三阶段规划 | P0 |
| 多轮追问式对话 | ✅ 完成 | 分析完成后可对任意建议进行追问 | P1 |
| 热门岗位数据联动 | ✅ 完成 | 推荐岗位可跳转面试练习(闭环:测→练→面) | P0 |
| 个人中心入口 | ✅ 完成 | 用户菜单增加"择业顾问"入口(NEW 标记) | P0 |
--- ---
## 二、用户端功能 ## 二、用户端功能
@@ -61,6 +84,7 @@
| 面试记录/统计 | ✅ 完成 | 总数/平均分/完成数 | | 面试记录/统计 | ✅ 完成 | 总数/平均分/完成数 |
| 进步轨迹 | ✅ 完成 | 雷达图 + 打卡日历 | | 进步轨迹 | ✅ 完成 | 雷达图 + 打卡日历 |
| 简历管理 | ✅ 完成 | 多份简历 CRUD + AI 分析 | | 简历管理 | ✅ 完成 | 多份简历 CRUD + AI 分析 |
| 面试复盘 | ✅ 完成 | 音频上传 → ASR → AI 评析 → 口语分析 |
| 会员中心 | ✅ 完成 | 套餐对比 + 支付 | | 会员中心 | ✅ 完成 | 套餐对比 + 支付 |
--- ---
@@ -95,6 +119,8 @@
| 面试报告生成 | ✅ 完成 | 总分 + 四维 + 优劣势分析 | | 面试报告生成 | ✅ 完成 | 总分 + 四维 + 优劣势分析 |
| 简历诊断 | ✅ 完成 | 结构 + 表达 + 关键词 + 亮点分析 | | 简历诊断 | ✅ 完成 | 结构 + 表达 + 关键词 + 亮点分析 |
| 简历优化 | ✅ 完成 | 内容优化 + 差异展示 | | 简历优化 | ✅ 完成 | 内容优化 + 差异展示 |
| 面试复盘评析 | ✅ 完成 | 转录文本 → AI 评估 → 逐题分析 |
| 口语分析 | ✅ 完成 | 填充词检测 + 语速评估 |
| 技能缺口分析 | 📋 规划中 | 基于 JD 分析技能差距 | | 技能缺口分析 | 📋 规划中 | 基于 JD 分析技能差距 |
| 学习路径推荐 | 📋 规划中 | 知识图谱驱动的职业规划 | | 学习路径推荐 | 📋 规划中 | 知识图谱驱动的职业规划 |
@@ -104,18 +130,25 @@
| opencode-go (deepseek-v4-flash) | 主用 | ✅ 已配置 | | opencode-go (deepseek-v4-flash) | 主用 | ✅ 已配置 |
| NVIDIA (stepfun-ai/step-3.5-flash) | 备用 | ✅ 已配置 | | NVIDIA (stepfun-ai/step-3.5-flash) | 备用 | ✅ 已配置 |
### ASR 引擎配置
| 引擎 | 用途 | 状态 |
|------|------|------|
| whisper.cpp (tiny/base) | 本地离线 ASR | ✅ 已编译 + 已部署 |
| mock ASR | 回落方案 | ✅ 无 whisper 时自动使用 |
--- ---
## 五、技术功能 ## 五、技术功能
| 功能 | 状态 | 描述 | | 功能 | 状态 | 描述 |
|------|------|------| |------|------|------|
| MongoDB 数据存储 | ✅ 完成 | 8 个数据模型 | | MongoDB 数据存储 | ✅ 完成 | 9 个数据模型(新增 InterviewReview |
| JWT 认证 | ✅ 完成 | 全局守卫 + 白名单机制 | | JWT 认证 | ✅ 完成 | 全局守卫 + 白名单机制 |
| API 限流 | ✅ 完成 | @nestjs/throttler 10次/分钟 | | API 限流 | ✅ 完成 | @nestjs/throttler 10次/分钟 |
| 文件上传 | ✅ 完成 | 简历 PDF/图片解析 | | 文件上传 | ✅ 完成 | 简历 PDF/图片 + 面试录音 |
| CORS 配置 | ✅ 完成 | 全开放(生产需白名单) | | CORS 配置 | ✅ 完成 | 全开放(生产需白名单) |
| 参数校验 | ✅ 完成 | class-validator whitelist | | 参数校验 | ✅ 完成 | class-validator whitelist |
| whisper.cpp ASR | ✅ 完成 | C/C++ 原生二进制,CPU 推理,MIT 协议 |
--- ---
@@ -132,6 +165,7 @@
- [x] 会员系统(¥19.9 成长版) - [x] 会员系统(¥19.9 成长版)
- [x] 微信支付对接(Native + JSAPI - [x] 微信支付对接(Native + JSAPI
- [x] 公司真题库(用户贡献驱动) - [x] 公司真题库(用户贡献驱动)
- [x] **面试复盘(音频 ASR + AI 评析 + 口语分析)**
### P1(待实现) ### P1(待实现)
- [ ] 每日一题定时推送 - [ ] 每日一题定时推送
@@ -156,3 +190,5 @@
| 2026-06-01 | 重新定位:专注校招 | AI | | 2026-06-01 | 重新定位:专注校招 | AI |
| 2026-06-05 | 战略升级:新增数据飞轮/留存入围 | 小之 | | 2026-06-05 | 战略升级:新增数据飞轮/留存入围 | 小之 |
| 2026-06-09 | 同步代码:Phase 0.5 功能标记完成,修正状态 | AI | | 2026-06-09 | 同步代码:Phase 0.5 功能标记完成,修正状态 | AI |
| 2026-06-16 | **v4.2**:新增面试复盘功能(whisper.cpp ASR + AI 评析 + 口语分析) | AI |
| 2026-06-17 | **v4.3**:新增 AI 择业顾问功能(专业分析 + 岗位匹配 + 多轮对话) | AI |
+39 -9
View File
@@ -1,8 +1,8 @@
# 职引项目 · 状态报告 v4.3 # 职引项目 · 状态报告 v4.5
> **项目版本**: v4.3 > **项目版本**: v4.5
> **更新时间**: 2026-06-11 > **更新时间**: 2026-06-17
> **项目状态**: ✅ 代码质量修复 + 全量测试体系搭建完成 > **项目状态**: ✅ 面试复盘上线 + AI 择业顾问 MVP
--- ---
@@ -15,7 +15,8 @@
| 技术栈 | NestJS + MongoDB + Uni-App(Vue3) | | 技术栈 | NestJS + MongoDB + Uni-App(Vue3) |
| 定价 | 免费版 / ¥19.9/月(成长版) / ¥49.9/月(冲刺版) | | 定价 | 免费版 / ¥19.9/月(成长版) / ¥49.9/月(冲刺版) |
| AI 模型 | DeepSeek V4-Flash(主) + Step-3.5-Flash(备) | | AI 模型 | DeepSeek V4-Flash(主) + Step-3.5-Flash(备) |
| 后端模块 | user, interview, resume, member, payment, positions, ai, analyze, upload, admin, email, progress, contribution, daily-question, schedule | | ASR | whisper.cpp(本地部署,tiny/base 模型,无需 API Key |
| 后端模块 | user, interview, resume, member, payment, positions, ai, analyze, upload, admin, email, progress, contribution, daily-question, schedule, interview-review, career-advice |
--- ---
@@ -23,13 +24,14 @@
| 模块 | 完成度 | 说明 | | 模块 | 完成度 | 说明 |
|------|------|------| |------|------|------|
| 后端 API | **98%** | 核心 + 护城河 P0-P5 全部实现 | | 后端 API | **99%** | 核心 + 护城河 P0-P5 全部实现 |
| 前端页面 | **85%** | 16 个页面含真实 API 调用 | | 前端页面 | **88%** | 17 个页面含真实 API 调用 |
| AI 面试模拟 | **95%** | 多轮对话 + 评分 + 报告 + 进度追踪 | | AI 面试模拟 | **95%** | 多轮对话 + 评分 + 报告 + 进度追踪 |
| 简历诊断/优化 | **95%** | 文件上传 + AI 分析 + 下载 | | 简历诊断/优化 | **95%** | 文件上传 + AI 分析 + 下载 |
| 支付系统(微信) | **95%** | API v3 完整对接,含真实证书 | | 支付系统(微信) | **95%** | API v3 完整对接,含真实证书 |
| 会员系统 | **100%** | 成长版 + 冲刺版,含权益扣减 | | 会员系统 | **100%** | 成长版 + 冲刺版,含权益扣减 |
| 护城河 P0-P5 | **100%** | AI 结构化 / 行业基准 / VIP 过期 / 分享卡片 / 打卡积分 / 岗位匹配 | | 护城河 P0-P5 | **100%** | AI 结构化 / 行业基准 / VIP 过期 / 分享卡片 / 打卡积分 / 岗位匹配 |
| 面试复盘 | **100%** | 音频上传 → whisper.cpp ASR → AI 评析 → 口语分析 |
| 测试体系 | **85%** | 43 单元 + 11 e2e + 7 前端 + Playwright 框架 | | 测试体系 | **85%** | 43 单元 + 11 e2e + 7 前端 + Playwright 框架 |
| 代码质量 | **95%** | console→Loggeras any 类型化,空 catch 检查 | | 代码质量 | **95%** | console→Loggeras any 类型化,空 catch 检查 |
| 安全审计 | **90%** | JWT 硬编码 / 凭据泄漏 / IDOR / NoSQL 注入 全部修复 | | 安全审计 | **90%** | JWT 硬编码 / 凭据泄漏 / IDOR / NoSQL 注入 全部修复 |
@@ -89,6 +91,28 @@
| 文件上传(PDF/图片) | ✅ | ✅ | **完成** | | 文件上传(PDF/图片) | ✅ | ✅ | **完成** |
| 结果下载(TXT/HTML) | N/A | ✅ | **完成** | | 结果下载(TXT/HTML) | N/A | ✅ | **完成** |
### 3.6 面试复盘(新增)
| 功能 | 后端 | 前端 | 状态 |
|------|------|------|------|
| 音频文件上传(MP3/M4A/WAV 等) | ✅ | ✅ | **完成** |
| 文本转录粘贴提交 | ✅ | ✅ | **完成** |
| whisper.cpp 本地 ASR 转写 | ✅ | N/A | **完成**tiny + base 模型) |
| AI 面试评估(四维评分) | ✅ | N/A | **完成** |
| 口语分析(填充词/语速) | ✅ | N/A | **完成** |
| 异步处理 + 状态轮询 | ✅ | ✅ | **完成** |
| 复盘历史列表/详情/删除 | ✅ | ✅ | **完成** |
| ASR mock 回落(whisper 不可用时) | ✅ | N/A | **完成** |
### 3.7 AI 择业顾问(新增)
| 功能 | 后端 | 前端 | 状态 |
|------|------|------|------|
| AI 专业/兴趣/性格分析 | ✅ | ✅ | **完成** |
| 智能岗位匹配推荐 | ✅ | ✅ | **完成** |
| 个性化职业发展建议 | ✅ | ✅ | **完成** |
| 多轮追问式对话 | ✅ | ✅ | **完成** |
| 热门岗位数据联动 | ✅ | N/A | **完成** |
| 个人中心入口(择业顾问) | N/A | ✅ | **完成** |
--- ---
## 四、测试体系 ## 四、测试体系
@@ -151,6 +175,8 @@
| `progress` | controller + schema + benchmark service | ✅ | 打卡/积分/基准/匹配 | | `progress` | controller + schema + benchmark service | ✅ | 打卡/积分/基准/匹配 |
| `contribution` | controller + schema (×2) | ✅ | 面经 + AI 结构化 + 公司题库 | | `contribution` | controller + schema (×2) | ✅ | 面经 + AI 结构化 + 公司题库 |
| `schedule` | module + service (×3) | ✅ | VIP 过期 / 每日一题 / 微信 token | | `schedule` | module + service (×3) | ✅ | VIP 过期 / 每日一题 / 微信 token |
| `interview-review` | controller + service + schema + asr service | ✅ | 面试复盘:音频 ASR + AI 评析 + 口语分析 |
| `career-advice` | controller + service + module | ✅ | AI 择业顾问:专业分析 + 岗位匹配 + 多轮对话 |
| `admin` | controller + module | ✅ | 管理后台 | | `admin` | controller + module | ✅ | 管理后台 |
| `email` | module + service | ✅ | 邮件发送 | | `email` | module + service | ✅ | 邮件发送 |
| `upload` | controller + module | ✅ | 文件上传 | | `upload` | controller + module | ✅ | 文件上传 |
@@ -166,11 +192,13 @@
| 面试模拟 | interview/interview | ✅ 多轮对话 + 计时 | | 面试模拟 | interview/interview | ✅ 多轮对话 + 计时 |
| 面试报告 | report/report | ✅ 评分/分析/全文回放/分享卡片 | | 面试报告 | report/report | ✅ 评分/分析/全文回放/分享卡片 |
| 历史记录 | history/history | ✅ 筛选/统计 | | 历史记录 | history/history | ✅ 筛选/统计 |
| 个人中心 | user/user | ✅ 信息/统计/管理员入口 | | 个人中心 | user/user | ✅ 信息/统计/管理员入口 + 面试复盘入口 + 择业顾问入口 |
| 会员中心 | member/member | ✅ 套餐对比 + 支付 | | 会员中心 | member/member | ✅ 套餐对比 + 支付 |
| 进步轨迹 | progress/progress | ✅ 雷达图 + 打卡日历 | | 进步轨迹 | progress/progress | ✅ 雷达图 + 打卡日历 |
| 面经贡献 | contribute/contribute | ✅ 表单提交 | | 面经贡献 | contribute/contribute | ✅ 表单提交 |
| 简历优化 | resume/resume | ✅ 诊断/优化/上传/下载 | | 简历优化 | resume/resume | ✅ 诊断/优化/上传/下载 |
| 面试复盘 | review/review | ✅ 三种模式(列表/上传/报告) |
| 择业顾问 | career/career | ✅ AI 专业分析 + 岗位匹配 + 多轮对话 |
| 实习搜索 | internship/internship | ✅ 热门岗位 | | 实习搜索 | internship/internship | ✅ 热门岗位 |
| 管理后台 | admin/admin | ✅ 仪表盘 | | 管理后台 | admin/admin | ✅ 仪表盘 |
| 关于/协议/隐私 | about/agreement/privacy | ✅ | | 关于/协议/隐私 | about/agreement/privacy | ✅ |
@@ -189,10 +217,12 @@
--- ---
## 十、变更记录 ## 十、变更记录
| 2026-06-17 | v4.5 | AI 择业顾问 MVP:后端模块 + 前端职业分析页面 + 热门岗位联动 | AI |
| 日期 | 版本 | 变更内容 | 操作者 | | 日期 | 版本 | 变更内容 | 操作者 |
|------|------|----------|--------| |------|------|----------|--------|
| 2026-06-02 | v1.0 | 项目状态初版 | AI | | 2026-06-02 | v1.0 | 项目状态初版 | AI |
| 2026-06-05 | v2.0 | 战略升级:文档重构 + 新增功能启动 | 小之 | | 2026-06-05 | v2.0 | 战略升级:文档重构 + 新增功能启动 | 小之 |
| 2026-06-09 | v4.2 | 冲刺版+每日推送+支付修复+全量代码评审 | AI | | 2026-06-09 | v4.2 | 冲刺版+每日推送+支付修复+全量代码评审 | AI |
| 2026-06-11 | **v4.3** | **安全修复 5 项 + 代码质量 14 处 + 测试体系 61 项 + 护城河 P0-P5 全部验证** | AI | | 2026-06-11 | v4.3 | 安全修复 5 项 + 代码质量 14 处 + 测试体系 61 项 + 护城河 P0-P5 全部验证 | AI |
| 2026-06-16 | **v4.4** | **面试复盘功能上线:音频 ASRwhisper.cpp+ AI 评析 + 口语分析 + 前端三模式页面** | AI |
+39 -22
View File
@@ -1,8 +1,8 @@
# 职引 · 产品路线图 v4.1 # 职引 · 产品路线图 v4.3
> **版本**: v4.1 > **版本**: v4.3
> **日期**: 2026-06-09 > **日期**: 2026-06-17
> **状态**: Phase 0.5 壁垒构建完成,待上线 > **状态**: Phase 1.5 启动:AI 择业顾问 MVP
> **定位**: 应届生/实习生 AI 面试教练 > **定位**: 应届生/实习生 AI 面试教练
--- ---
@@ -14,13 +14,13 @@ Phase 0: 战略升级(✅ 已完成)
Phase 0.5: 壁垒构建(✅ 已完成) Phase 0.5: 壁垒构建(✅ 已完成)
Phase 1: MVP 上线(D7-14)→ 小程序审核 + 内测 + 支付生产 Phase 1: MVP 开发(✅ 已完成)→ 面试复盘 + whisper.cpp ASR 集成
Phase 1.5: 辅助功能 + 商业化(D14-30)→ PMF 验证 Phase 1.5: 商业化(D30-60)→ PMF 验证
Phase 2: 增强 + 题库(D30-60)→ 秋招准备 Phase 2: 增强 + 题库(D60-90)→ 秋招准备
Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发 Phase 3: 商业化 + B 端(D90+)→ 秋招爆发
``` ```
--- ---
@@ -60,38 +60,51 @@ Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发
--- ---
## 四、Phase 1MVP 上线(D7-14,当前阶段 ## 四、Phase 1MVP 开发(✅ 已完成,2026-06-16
### 4.1 上线准备 ### 4.1 面试复盘功能
| 任务 | 描述 | 状态 | | 任务 | 描述 | 状态 |
|------|------|------| |------|------|------|
| 前端页面完善 | 16 个页面全部就绪 | ✅ 完成 | | 音频文件上传 | 支持 MP3/M4A/WAV 等格式,50MB 上限 | ✅ 完成 |
| 文本转录提交 | 直接粘贴面试文本 | ✅ 完成 |
| whisper.cpp 本地 ASR | 离线语音转文字,tiny + base 模型 | ✅ 完成 |
| AI 面试评析 | 四维评分 + 逐题评估 | ✅ 完成 |
| 口语分析 | 填充词检测 + 语速评估 | ✅ 完成 |
| 前端三模式页面 | 列表/上传/报告三种视图 | ✅ 完成 |
| 个人中心入口 | "面试复盘"菜单项 | ✅ 完成 |
### 4.2 上线准备
| 任务 | 描述 | 状态 |
|------|------|------|
| 前端页面完善 | 17 个页面全部就绪 | ✅ 完成 |
| 微信登录联调 | 真实 appid 验证 | ⏳ 待进行 | | 微信登录联调 | 真实 appid 验证 | ⏳ 待进行 |
| 移除开发绕过 | `member/pay` 直接激活 | ⏳ 待进行 | | 移除开发绕过 | `member/pay` 直接激活 | ⏳ 待进行 |
| 生产环境部署 | 服务器 + MongoDB + Nginx + PM2 | ✅ 服务器已购,域名已配zhiyinwx → API:3006zhiyin.yzrcloud → H5 静态目录) | | 生产环境部署 | 服务器 + MongoDB + Nginx + PM2 | ✅ 服务器已购,域名已配 |
| 小程序审核提交 | 资质齐全 | ⏳ 待进行 | | 小程序审核提交 | 资质齐全 | ⏳ 待进行 |
| 内测版发布 | 邀请码方式,100 人内测 | ⏳ 待进行 | | 内测版发布 | 邀请码方式,100 人内测 | ⏳ 待进行 |
### 4.2 内测指标 ### 4.3 内测指标
- **关键指标**: 次日留存 > 30%7 日留存 > 15% - **关键指标**: 次日留存 > 30%7 日留存 > 15%
- **反馈收集**: 问卷 + 访谈 - **反馈收集**: 问卷 + 访谈
- **如果达标**: 继续 Phase 1.5 - **如果达标**: 继续 Phase 1.5
--- ---
## 五、Phase 1.5:辅助功能 + 商业化(D14-30 ## 五、Phase 1.5:辅助功能 + 商业化(D30-60
| 功能 | 描述 | 优先级 | | 功能 | 描述 | 优先级 |
|------|------|--------| |------|------|--------|
| 每日一题定时推送 | 微信订阅消息推送 | P0 | | 每日一题定时推送 | 微信订阅消息推送 | P0 |
| 冲刺版 ¥49.9/月 | 高客单价 | P1 | | 冲刺版 ¥49.9/月 | 高客单价 | P1 |
| 连续打卡激励 | 7 天解锁高级报告 | P1 | | 连续打卡激励 | 7 天解锁高级报告 | P1 |
| ASR 生产化调优 | 多模型切换、模型量化、推理优化 | P1 |
| AI 择业顾问 MVP | AI 专业分析 + 岗位匹配 + 多轮对话 | P0 |
| 付费转化验证 | 100 内测用户 → 10+ 付费 | P0 | | 付费转化验证 | 100 内测用户 → 10+ 付费 | P0 |
| PMF 决策 | 转化率 > 5% → 继续 | P0 | | PMF 决策 | 转化率 > 5% → 继续 | P0 |
--- ---
## 六、Phase 2:增强 + 真题库(D30-60,秋招前) ## 六、Phase 2:增强 + 真题库(D60-90,秋招前)
### 6.1 真题库建设 ### 6.1 真题库建设
| 公司 | 题库规模 | 状态 | | 公司 | 题库规模 | 状态 |
@@ -112,7 +125,7 @@ Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发
--- ---
## 七、Phase 3:商业化 + B 端(D60-90,秋招爆发) ## 七、Phase 3:商业化 + B 端(D90+,秋招爆发)
### 7.1 增长目标 ### 7.1 增长目标
- 付费用户突破 1000 - 付费用户突破 1000
@@ -140,10 +153,11 @@ Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发
|--------|------|--------|----------| |--------|------|--------|----------|
| M0: 战略升级 | ✅ D1 | 文档 + 定价 | 已完成 | | M0: 战略升级 | ✅ D1 | 文档 + 定价 | 已完成 |
| M0.5: 壁垒构建 | ✅ D7 | 进步轨迹 + 面经贡献 + 每日一题 | 功能可用 | | M0.5: 壁垒构建 | ✅ D7 | 进步轨迹 + 面经贡献 + 每日一题 | 功能可用 |
| M1: MVP 上线 | D14 | 小程序审核通过,内测启动 | 100 内测用户 | | M1: MVP 开发 | D14 | 面试复盘 + whisper.cpp ASR | 功能可用,build + test 通过 |
| M2: PMF 验证 | D30 | 100 用户反馈 | 转化率 > 5% | | M2: 上线内测 | D30 | 小程序审核通过,内测启动 | 100 内测用户 |
| M3: 付费上线 | D45 | 冲刺版 + 定时推送 | 50+ 付费用户 | | M3: PMF 验证 | D60 | 100 用户反馈 | 转化率 > 5% |
| M4: 秋招冲刺 | D90 | 秋招推广 | 1000+ 付费用户 | | M4: 付费上线 | D75 | 冲刺版 + 定时推送 | 50+ 付费用户 |
| M5: 秋招冲刺 | D90+ | 秋招推广 | 1000+ 付费用户 |
--- ---
@@ -157,8 +171,9 @@ Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发
关键时间点: 关键时间点:
6月9日:壁垒构建完成,Phase 0.5 交付 6月9日:壁垒构建完成,Phase 0.5 交付
6月15日:MVP 上线,内测启动 6月16日:面试复盘上线,MVP 开发完成
7月1日:PMF 验证,付费转化 6月30日:MVP 上线,内测启动
7月15日:PMF 验证,付费转化
8月1日:Phase 2 完成,准备秋招 8月1日:Phase 2 完成,准备秋招
9月1日:秋招旺季,全力推广 9月1日:秋招旺季,全力推广
``` ```
@@ -185,3 +200,5 @@ Phase 3: 商业化 + B 端(D60-90)→ 秋招爆发
| 2026-06-01 | 重新规划:专注校招 | AI | | 2026-06-01 | 重新规划:专注校招 | AI |
| 2026-06-05 | 战略升级:三层壁垒 + 新定价 | 小之 | | 2026-06-05 | 战略升级:三层壁垒 + 新定价 | 小之 |
| 2026-06-09 | Phase 0.5 标记完成,调整后续里程碑时间 | AI | | 2026-06-09 | Phase 0.5 标记完成,调整后续里程碑时间 | AI |
| 2026-06-16 | **v4.2**Phase 1 MVP 开发完成,面试复盘上线,里程碑 M1 完成 | AI |
| 2026-06-17 | **v4.3**:AI 择业顾问 MVP 上线,里程碑 M1.5 完成 | AI |
+253
View File
@@ -0,0 +1,253 @@
# 分享功能设计方案
## 1. 概述
**目标**:用户可通过分享面试/简历等给好友或微信群,每次有效分享获得积分奖励,积分可抵扣面试/简历优化次数,形成用户增长闭环。
**核心逻辑**:分享者 A → 生成分享链接 → 非 A 的其他用户点击 → 计入有效分享一次 → A 获得 1 个「分享积分」,每 3 次有效分享可兑换 1 次面试或简历优化次数。
---
## 2. 数据模型
### User 新增字段
```
shareCredits: number // 分享积分,默认 0
```
- 1 个 shareCredit 可兑换 1 次 面试 或 1 次 简历优化
- 在 QuotaService 中作为兜底:当 interviewCredits / resumeOptimizeCredits 为 0 时尝试消耗 shareCredits
### ShareRecord 集合
```
@Schema({ timestamps: true })
ShareRecord {
_id: ObjectId
userId: ObjectId // 分享者
shareCode: string // 8位唯一短码 (hex),用于分享链接
type: 'interview' | 'resume' | 'app'
refId: string // 关联的面试/简历ID(可选)
title: string // 分享标题
description: string // 分享描述
visitCount: number // 总访问次数
creditedCount: number // 已计为有效的访问次数
isActive: boolean // 链接是否有效
createdAt: Date // timestamps
updatedAt: Date
}
index: { shareCode: 1 } unique
index: { userId: 1, createdAt: -1 }
```
### ShareVisit 集合(访问记录)
```
@Schema({ timestamps: true })
ShareVisit {
_id: ObjectId
shareId: ObjectId // 关联的 ShareRecord
sharerId: ObjectId // 分享者 userId(冗余,便于查询)
visitorId: string // 访问者标识(openId 或 匿名ID)
visitorUserId: ObjectId // 访问者 userId(如果已注册/登录)
credited: boolean // 是否已为此访问发积分
creditedAt: Date
createdAt: Date // timestamps
}
index: { shareId: 1, visitorId: 1 } unique // 同一人只计一次
index: { sharerId: 1, createdAt: -1 }
```
---
## 3. API 设计
| 方法 | 路径 | 权限 | 说明 |
|------|------|------|------|
| POST | /api/share/create | JWT | 生成分享链接,返回 shareCode + URL |
| GET | /api/share/visit/:shareCode | Public | 访问分享链接,记录访问+判定发放积分 |
| GET | /api/share/stats | JWT | 获取我的分享统计(总分享次数、总积分、今日积分) |
| GET | /api/share/records | JWT | 获取我的分享记录列表(分页) |
| GET | /api/share/visitors | JWT | 获取访问过我分享的用户列表(分页) |
### POST /api/share/create
Request:
```json
{
"type": "interview" | "resume" | "app",
"refId": "xxx",
"title": "我在职引完成了AI模拟面试",
"description": "快来和我一起练习面试吧"
}
```
Response:
```json
{
"shareCode": "a1b2c3d4",
"shareUrl": "https://zhiyin.app/share/a1b2c3d4",
"wechatShareInfo": {
"title": "...",
"description": "...",
"path": "/pages/share/share?code=a1b2c3d4"
}
}
```
### GET /api/share/visit/:shareCode
- 如果来自微信小程序:记录 `visitorId = openId`
- 如果来自 H5 链接:记录 `visitorId = 匿名设备ID`(可选)
- 判定条件:
- `visitorId !== sharer.openId`(自己点自己不算)
-`visitorId` 之前未在该 shareId 下领过积分
- 当日该分享者已获得积分 < 3(日上限)
- 满足条件 → `credited = true`shareCredits + 1
- 返回重定向或展示落地页
### GET /api/share/stats
```json
{
"totalShares": 15,
"totalVisits": 43,
"creditedCount": 12,
"todayCredited": 2,
"shareCredits": 4
}
```
### GET /api/share/records
```json
[
{
"shareCode": "a1b2c3d4",
"type": "interview",
"title": "我在职引完成了AI模拟面试",
"visitCount": 5,
"creditedCount": 3,
"createdAt": "2026-06-12T10:00:00Z"
}
]
```
### GET /api/share/visitors
```json
[
{
"visitor": { "nickname": "张三", "avatar": "..." },
"credited": true,
"creditedAt": "2026-06-12T10:30:00Z"
}
]
```
---
## 4. 积分兜底机制
`QuotaService.checkAndDeductInterview()``checkAndDeductOptimize()` 中增加兜底:
```
if (interviewCredits <= 0 && shareCredits > 0) {
shareCredits -= 1
return // 用分享积分抵扣
}
```
同时新增 `useShareCredit(userId, type)` 方法由前端显式调用,或自动在抵扣链中完成。
---
## 5. 前端实现
### 5.1 分享入口
**进入点 1:面试报告页**`pages/report/report.vue`
- 在"生成分享卡片"按钮旁增加"分享给好友"按钮
- 点击后调用 `POST /api/share/create` 生成 shareCode
- 微信小程序内直接调 `wx.shareAppMessage`
- H5 环境复制分享链接到剪贴板
**进入点 2:简历优化结果页**`pages/result/result.vue`
- 同上
**进入点 3:应用首页**`pages/index/index.vue`
- "邀请好友"入口,固定分享 app 类型
### 5.2 我的分享页
**页面位置**`/pages/share/share.vue`
**进入方式**:用户「我的」页面 → "我的分享" 菜单项
页面内容:
- 顶部统计卡片:总收益积分、今日收益、总分享次数
- "分享给好友"主按钮
- Tab 切换:「分享记录」/ 「访问记录」
- 分享记录列表:分享类型、标题、访问数、有效数、时间
- 访问记录列表:访客昵称、访问时间、是否已积分
### 5.3 微信分享
使用 uni-app `onShareAppMessage` 生命周期:
```javascript
// 在页面中定义
onShareAppMessage() {
return {
title: '我在职引完成了AI模拟面试',
path: `/pages/share/share?code=${this.shareCode}`,
imageUrl: '...'
}
}
```
### 5.4 H5 分享链接
分享链接格式:`https://zhiyin.app/share/{shareCode}`
H5 落地页展示:
- 分享者信息
- 分享内容预览
- "打开小程序" / "下载 App" 引导按钮
---
## 6. 风控规则
| 规则 | 说明 |
|------|------|
| 日上限 | 同一用户每日最多获 3 个分享积分 |
| 自分享过滤 | 自己点自己的链接不计数 |
| 同人去重 | 同一访客对同一链接只计一次 |
| 链接有效期 | 分享链接 30 天有效期 |
| 频率限制 | 每分钟最多创建 5 次分享(前端控制) |
---
## 7. 存储方案
- **ShareRecord**MongoDB 集合 `sharerecords`
- **ShareVisit**MongoDB 集合 `sharevisits`
- 积分字段 `shareCredits` 存储在 User 文档上,`$inc` 原子操作确保并发安全
---
## 8. 依赖模块
- `QuotaService`(来自 UserModule- 积分发放与抵扣
- `UserModule`(获取 User 信息、校验身份)
- `PricingModule`@Global 已有,无需额外导入)
---
## 9. 未纳入 MVP 的内容
- 分享链接落地页(H5 路由 `/share/:code`)— 第一期直接返回 JSON
- 分享数据可视化图表
- 积分兑换商城
- 排行榜 / 邀请竞赛
+108 -58
View File
@@ -25,7 +25,7 @@
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001", "@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
"@vue/test-utils": "^2.4.11", "@vue/test-utils": "^2.4.11",
"jsdom": "^29.1.1", "jsdom": "^29.1.1",
"miniprogram-ci": "^2.1.31", "miniprogram-ci": "^2.1.42",
"sass": "^1.70.0", "sass": "^1.70.0",
"typescript": "^5.3.0", "typescript": "^5.3.0",
"vite": "^5.2.0", "vite": "^5.2.0",
@@ -5674,15 +5674,15 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@swc/core": { "node_modules/@swc/core": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core/-/core-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core/-/core-1.15.33.tgz",
"integrity": "sha512-tHXg6OxboUsqa/L7DpsCcFnxhLkqN/ht5pCwav1HnvfthbiNIJypr86rNx4cUnQDJepETviSqBTIjxa7pSpGDQ==", "integrity": "sha512-jOlwnFV2xhuuZeAUILGFULeR6vDPfijEJ57evfocwznQldLU3w2cZ9bSDryY9ip+AsM3r1NJKzf47V2NXebkeQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@swc/counter": "^0.1.2", "@swc/counter": "^0.1.3",
"@swc/types": "^0.1.5" "@swc/types": "^0.1.26"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=10"
@@ -5692,19 +5692,21 @@
"url": "https://opencollective.com/swc" "url": "https://opencollective.com/swc"
}, },
"optionalDependencies": { "optionalDependencies": {
"@swc/core-darwin-arm64": "1.4.14", "@swc/core-darwin-arm64": "1.15.33",
"@swc/core-darwin-x64": "1.4.14", "@swc/core-darwin-x64": "1.15.33",
"@swc/core-linux-arm-gnueabihf": "1.4.14", "@swc/core-linux-arm-gnueabihf": "1.15.33",
"@swc/core-linux-arm64-gnu": "1.4.14", "@swc/core-linux-arm64-gnu": "1.15.33",
"@swc/core-linux-arm64-musl": "1.4.14", "@swc/core-linux-arm64-musl": "1.15.33",
"@swc/core-linux-x64-gnu": "1.4.14", "@swc/core-linux-ppc64-gnu": "1.15.33",
"@swc/core-linux-x64-musl": "1.4.14", "@swc/core-linux-s390x-gnu": "1.15.33",
"@swc/core-win32-arm64-msvc": "1.4.14", "@swc/core-linux-x64-gnu": "1.15.33",
"@swc/core-win32-ia32-msvc": "1.4.14", "@swc/core-linux-x64-musl": "1.15.33",
"@swc/core-win32-x64-msvc": "1.4.14" "@swc/core-win32-arm64-msvc": "1.15.33",
"@swc/core-win32-ia32-msvc": "1.15.33",
"@swc/core-win32-x64-msvc": "1.15.33"
}, },
"peerDependencies": { "peerDependencies": {
"@swc/helpers": "^0.5.0" "@swc/helpers": ">=0.5.17"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@swc/helpers": { "@swc/helpers": {
@@ -5713,9 +5715,9 @@
} }
}, },
"node_modules/@swc/core-darwin-arm64": { "node_modules/@swc/core-darwin-arm64": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.33.tgz",
"integrity": "sha512-8iPfLhYNspBl836YYsfv6ErXwDUqJ7IMieddV3Ey/t/97JAEAdNDUdtTKDtbyP0j/Ebyqyn+fKcqwSq7rAof0g==", "integrity": "sha512-N+L0uXhuO7FIfzqwgxmzv0zIpV0qEp8wPX3QQs2p4atjMoywup2JTeDlXPw+z9pWJGCae3JjM+tZ6myclI+2gA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -5730,9 +5732,9 @@
} }
}, },
"node_modules/@swc/core-darwin-x64": { "node_modules/@swc/core-darwin-x64": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-darwin-x64/-/core-darwin-x64-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-darwin-x64/-/core-darwin-x64-1.15.33.tgz",
"integrity": "sha512-9CqSj8uRZ92cnlgAlVaWMaJJBdxtNvCzJxaGj5KuIseeG6Q0l1g+qk8JcU7h9dAsH9saHTNwNFBVGKQo0W0ujg==", "integrity": "sha512-/Il4QHSOhV4FekbsDtkrNmKbsX26oSysvgrRswa/RYOHXAkwXDbB4jaeKq6PsJLSPkzJ2KzQ061gtBnk0vNHfA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -5747,9 +5749,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm-gnueabihf": { "node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.33.tgz",
"integrity": "sha512-mfd5JArPITTzMjcezH4DwMw+BdjBV1y25Khp8itEIpdih9ei+fvxOOrDYTN08b466NuE2dF2XuhKtRLA7fXArQ==", "integrity": "sha512-C64hBnBxq4viOPQ8hlx+2lJ23bzZBGnjw7ryALmS+0Q3zHmwO8lw1/DArLENw4Q18/0w5wdEO1k3m1wWNtKGqQ==",
"cpu": [ "cpu": [
"arm" "arm"
], ],
@@ -5764,9 +5766,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm64-gnu": { "node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.33.tgz",
"integrity": "sha512-3Lqlhlmy8MVRS9xTShMaPAp0oyUt0KFhDs4ixJsjdxKecE0NJSV/MInuDmrkij1C8/RQ2wySRlV9np5jK86oWw==", "integrity": "sha512-TRJfnJbX3jqpxRDRoieMzRiCBS5jOmXNb3iQXmcgjFEHKLnAgK1RZRU8Cq1MsPqO4jAJp/ld1G4O3fXuxv85uw==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -5781,9 +5783,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm64-musl": { "node_modules/@swc/core-linux-arm64-musl": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.33.tgz",
"integrity": "sha512-n0YoCa64TUcJrbcXIHIHDWQjdUPdaXeMHNEu7yyBtOpm01oMGTKP3frsUXIABLBmAVWtKvqit4/W1KVKn5gJzg==", "integrity": "sha512-il7tYM+CpUNzieQbwAjFT1P8zqAhmGWNAGhQZBnxurXZ0aNn+5nqYFTEUKNZl7QibtT0uQXzTZrNGHCIj6Y1Og==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -5797,10 +5799,44 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/@swc/core-linux-ppc64-gnu": {
"version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.33.tgz",
"integrity": "sha512-ZtNBwN0Z7CFj9Il0FcPaKdjgP7URyKu/3RfH46vq+0paOBqLj4NYldD6Qo//Duif/7IOtAraUfDOmp0PLAufog==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-s390x-gnu": {
"version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.33.tgz",
"integrity": "sha512-De1IyajoOmhOYYjw/lx66bKlyDpHZTueqwpDrWgf5O7T6d1ODeJJO9/OqMBmrBQc5C+dNnlmIufHsp4QVCWufA==",
"cpu": [
"s390x"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-gnu": { "node_modules/@swc/core-linux-x64-gnu": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.33.tgz",
"integrity": "sha512-CGmlwLWbfG1dB4jZBJnp2IWlK5xBMNLjN7AR5kKA3sEpionoccEnChOEvfux1UdVJQjLRKuHNV9yGyqGBTpxfQ==", "integrity": "sha512-mGTH0YxmUN+x6vRN/I6NOk5X0ogNktkwPnJ94IMvR7QjhRDwL0O8RXEDhyUM0YtwWrryBOqaJQBX4zruxEPRGw==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -5815,9 +5851,9 @@
} }
}, },
"node_modules/@swc/core-linux-x64-musl": { "node_modules/@swc/core-linux-x64-musl": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.33.tgz",
"integrity": "sha512-xq4npk8YKYmNwmr8fbvF2KP3kUVdZYfXZMQnW425gP3/sn+yFQO8Nd0bGH40vOVQn41kEesSe0Z5O/JDor2TgQ==", "integrity": "sha512-hj628ZkSEJf6zMf5VMbYrG2O6QqyTIp2qwY6VlCjvIa9lAEZ5c2lfPblCLVGYubTeLJDxadLB/CxqQYOQABeEQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -5832,9 +5868,9 @@
} }
}, },
"node_modules/@swc/core-win32-arm64-msvc": { "node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.33.tgz",
"integrity": "sha512-imq0X+gU9uUe6FqzOQot5gpKoaC00aCUiN58NOzwp0QXEupn8CDuZpdBN93HiZswfLruu5jA1tsc15x6v9p0Yg==", "integrity": "sha512-GV2oohtN2/5+KSccl86VULu3aT+LrISC8uzgSq0FRnikpD+Zwc+sBlXmoKQ+Db6jI57ITUOIB8jRkdGMABC29g==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -5849,9 +5885,9 @@
} }
}, },
"node_modules/@swc/core-win32-ia32-msvc": { "node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.33.tgz",
"integrity": "sha512-cH6QpXMw5D3t+lpx6SkErHrxN0yFzmQ0lgNAJxoDRiaAdDbqA6Col8UqUJwUS++Ul6aCWgNhCdiEYehPaoyDPA==", "integrity": "sha512-gtyvzSNR8DHKfFEA2uqb8Ld1myqi6uEg2jyeUq3ikn5ytYs7H8RpZYC8mdy4NXr8hfcdJfCLXPlYaqqfBXpoEQ==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -5866,9 +5902,9 @@
} }
}, },
"node_modules/@swc/core-win32-x64-msvc": { "node_modules/@swc/core-win32-x64-msvc": {
"version": "1.4.14", "version": "1.15.33",
"resolved": "https://registry.npmmirror.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.4.14.tgz", "resolved": "https://registry.npmmirror.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.33.tgz",
"integrity": "sha512-FmZ4Tby4wW65K/36BKzmuu7mlq7cW5XOxzvufaSNVvQ5PN4OodAlqPjToe029oma4Av+ykJiif64scMttyNAzg==", "integrity": "sha512-d6fRqQSkJI+kmMEBWaDQ7TMl8+YjLYbwRUPZQ9DY0ORBJeTzOrG0twvfvlZ2xgw6jA0ScQKgfBm4vHLSLl5Hqg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -15461,9 +15497,9 @@
} }
}, },
"node_modules/miniprogram-ci": { "node_modules/miniprogram-ci": {
"version": "2.1.31", "version": "2.1.42",
"resolved": "https://registry.npmmirror.com/miniprogram-ci/-/miniprogram-ci-2.1.31.tgz", "resolved": "https://registry.npmmirror.com/miniprogram-ci/-/miniprogram-ci-2.1.42.tgz",
"integrity": "sha512-SREx6UnJC74aQ2a1YMNShqQOB97nHO+ll6ZQrCQp98NHXcRq848VjZoD5ELpd95z+8uTASQUAcFtl/HrXuM7Nw==", "integrity": "sha512-H/bq0Wo6kMbwzcOM4jiYSMuQUkND50+zeyY8EkJuY1TQYijkLbFmNK/CFsFJsJgVcvXZ94wn8Do50YSO/Rv6/w==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -15589,7 +15625,7 @@
"@babel/template": "7.20.7", "@babel/template": "7.20.7",
"@babel/traverse": "7.21.4", "@babel/traverse": "7.21.4",
"@babel/types": "7.24.6", "@babel/types": "7.24.6",
"@swc/core": "1.4.14", "@swc/core": "1.15.33",
"@vue/reactivity": "3.0.5", "@vue/reactivity": "3.0.5",
"acorn": "^6.1.1", "acorn": "^6.1.1",
"adm-zip": "0.5.10", "adm-zip": "0.5.10",
@@ -15642,7 +15678,7 @@
"string-hash-64": "1.0.3", "string-hash-64": "1.0.3",
"sync-message": "0.0.12", "sync-message": "0.0.12",
"terminal-kit": "^2.4.0", "terminal-kit": "^2.4.0",
"terser": "4.8.0", "terser": "5.27.1",
"tmp": "0.0.28", "tmp": "0.0.28",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"uglify-js": "3.0.27", "uglify-js": "3.0.27",
@@ -18152,21 +18188,35 @@
} }
}, },
"node_modules/miniprogram-ci/node_modules/terser": { "node_modules/miniprogram-ci/node_modules/terser": {
"version": "4.8.0", "version": "5.27.1",
"resolved": "https://registry.npmmirror.com/terser/-/terser-4.8.0.tgz", "resolved": "https://registry.npmmirror.com/terser/-/terser-5.27.1.tgz",
"integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", "integrity": "sha512-29wAr6UU/oQpnTw5HoadwjUZnFQXGdOfj0LjZ4sVxzqwHh/QVkvr7m8y9WoR4iN3FRitVduTc6KdjcW38Npsug==",
"dev": true, "dev": true,
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@jridgewell/source-map": "^0.3.3",
"acorn": "^8.8.2",
"commander": "^2.20.0", "commander": "^2.20.0",
"source-map": "~0.6.1", "source-map-support": "~0.5.20"
"source-map-support": "~0.5.12"
}, },
"bin": { "bin": {
"terser": "bin/terser" "terser": "bin/terser"
}, },
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=10"
}
},
"node_modules/miniprogram-ci/node_modules/terser/node_modules/acorn": {
"version": "8.17.0",
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.17.0.tgz",
"integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==",
"dev": true,
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
} }
}, },
"node_modules/miniprogram-ci/node_modules/terser/node_modules/commander": { "node_modules/miniprogram-ci/node_modules/terser/node_modules/commander": {
+3 -3
View File
@@ -3,9 +3,9 @@
"version": "1.0.0", "version": "1.0.0",
"scripts": { "scripts": {
"dev:mp-weixin": "uni -p mp-weixin", "dev:mp-weixin": "uni -p mp-weixin",
"build:mp-weixin": "uni build -p mp-weixin", "build:mp-weixin": "uni build -p mp-weixin && cp -f static/avatar-*.png dist/build/mp-weixin/static/ 2>/dev/null; true",
"dev:h5": "uni", "dev:h5": "uni",
"build:h5": "uni build", "build:h5": "uni build && cp -f static/avatar-*.png dist/build/h5/static/ 2>/dev/null; true",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest" "test:watch": "vitest"
}, },
@@ -27,7 +27,7 @@
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001", "@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
"@vue/test-utils": "^2.4.11", "@vue/test-utils": "^2.4.11",
"jsdom": "^29.1.1", "jsdom": "^29.1.1",
"miniprogram-ci": "^2.1.31", "miniprogram-ci": "^2.1.42",
"sass": "^1.70.0", "sass": "^1.70.0",
"typescript": "^5.3.0", "typescript": "^5.3.0",
"vite": "^5.2.0", "vite": "^5.2.0",
+28 -1
View File
@@ -1,7 +1,34 @@
<script setup lang="ts"> <script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
onLaunch(() => { console.log('职引 App launched') }) onLaunch(() => {
console.log('职引 App launched')
// #ifdef MP-WEIXIN
initPrivacy()
// #endif
})
// #ifdef MP-WEIXIN
function initPrivacy() {
if (wx.onNeedPrivacyAuthorization) {
wx.onNeedPrivacyAuthorization((resolve) => {
uni.showModal({
title: '隐私政策授权',
content: '请仔细阅读并同意《用户服务协议》和《隐私政策》后再使用本应用。您的个人信息将仅用于求职服务。',
confirmText: '同意',
cancelText: '拒绝',
success: (res) => {
if (res.confirm) {
resolve({ event: 'agree' })
} else {
resolve({ event: 'disagree' })
}
},
})
})
}
}
// #endif
onShow(() => { console.log('职引 App shown') }) onShow(() => { console.log('职引 App shown') })
onHide(() => { console.log('职引 App hidden') }) onHide(() => { console.log('职引 App hidden') })
</script> </script>
+146 -158
View File
@@ -1,21 +1,23 @@
<template> <template>
<view class="digital-human"> <view class="digital-human">
<view class="avatar-stage"> <view class="avatar-stage">
<view class="avatar-ring" :class="{ speaking: isSpeaking }"> <view class="avatar-body" :class="{ speaking: isSpeaking }">
<!-- Default CSS avatar if image fails --> <image class="avatar-img" :src="avatarSrc" mode="aspectFill" @error="avatarError = true" />
<view class="avatar-default" v-if="imgFailed"> <view class="mouth-overlay" :style="mouthStyle"></view>
<text class="avatar-initials">AI</text>
</view> </view>
<image class="avatar-img" :src="avatarSrc" mode="aspectFill" @error="imgFailed = true" v-else /> <image src="/static/avatar-default.png" style="display:none" />
<canvas <image src="/static/avatar-software.png" style="display:none" />
v-if="isH5" <image src="/static/avatar-frontend.png" style="display:none" />
id="dh-mouth" <image src="/static/avatar-backend.png" style="display:none" />
class="mouth-canvas" <image src="/static/avatar-algo.png" style="display:none" />
></canvas> <image src="/static/avatar-pm.png" style="display:none" />
<image src="/static/avatar-data.png" style="display:none" />
<image src="/static/avatar-marketing.png" style="display:none" />
<image src="/static/avatar-ops.png" style="display:none" />
<image src="/static/avatar-ui.png" style="display:none" />
<view class="status-dot" :class="{ active: isSpeaking }"></view>
<text class="role-label">{{ positionLabel }}</text>
</view> </view>
<text class="role-label">AI 面试官</text>
</view>
<view class="speech-area" v-if="currentText"> <view class="speech-area" v-if="currentText">
<view class="speech-bubble"> <view class="speech-bubble">
<text class="speech-text">{{ currentText }}</text> <text class="speech-text">{{ currentText }}</text>
@@ -25,30 +27,61 @@
</template> </template>
<script setup> <script setup>
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue' import { ref, watch, computed, onBeforeUnmount, nextTick } from 'vue'
const props = defineProps({ const props = defineProps({
text: { type: String, default: '' }, text: { type: String, default: '' },
audioUrl: { type: String, default: '' }, audioUrl: { type: String, default: '' },
amplitudeData: { type: Array, default: () => [] },
avatarUrl: { type: String, default: '' }, avatarUrl: { type: String, default: '' },
position: { type: String, default: '' },
autoPlay: { type: Boolean, default: true }, autoPlay: { type: Boolean, default: true },
}) })
const emit = defineEmits(['speaking-start', 'speaking-end']) const emit = defineEmits(['speaking-start', 'speaking-end'])
const isH5 = ref(false)
const isSpeaking = ref(false) const isSpeaking = ref(false)
const currentText = ref('') const currentText = ref('')
const imgFailed = ref(false) const mouthOpenness = ref(0)
let audioEl = null const avatarError = ref(false)
let audioCtx = null
let analyser = null
let animFrameId = null
let mouthScale = 0
onMounted(() => { let audioEl = null
isH5.value = typeof window !== 'undefined' && typeof document !== 'undefined' let animFrame = null
initCanvas()
const allAvatars = [
'/static/avatar-default.png',
'/static/avatar-software.png',
'/static/avatar-frontend.png',
'/static/avatar-backend.png',
'/static/avatar-algo.png',
'/static/avatar-pm.png',
'/static/avatar-data.png',
'/static/avatar-marketing.png',
'/static/avatar-ops.png',
'/static/avatar-ui.png',
]
const avatarMap = {
'软件开发': '/static/avatar-software.png',
'前端开发': '/static/avatar-frontend.png',
'后端开发': '/static/avatar-backend.png',
'算法工程师': '/static/avatar-algo.png',
'产品经理': '/static/avatar-pm.png',
'数据分析': '/static/avatar-data.png',
'市场营销': '/static/avatar-marketing.png',
'运营': '/static/avatar-ops.png',
'UI设计': '/static/avatar-ui.png',
}
const avatarSrc = computed(() => {
if (avatarError.value) return '/static/avatar-default.png'
if (props.avatarUrl) return props.avatarUrl
const key = Object.keys(avatarMap).find(k => props.position.includes(k))
return key ? avatarMap[key] : '/static/avatar-default.png'
})
const positionLabel = computed(() => {
return props.position ? `${props.position} 面试官` : 'AI 面试官'
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
@@ -65,129 +98,82 @@ watch(() => props.text, (txt) => {
currentText.value = txt currentText.value = txt
}) })
const avatarSrc = computed(() => { const mouthStyle = computed(() => {
return props.avatarUrl || '/static/default-avatar.png' const o = mouthOpenness.value
const h = 3 + o * o * 22
const w = 18 + o * 8
return {
height: h + 'rpx',
width: w + 'rpx',
borderRadius: o > 0.3 ? '50%' : '4rpx',
background: o > 0.5 ? 'linear-gradient(180deg, #C97B84, #A85562)' : '#C97B84',
opacity: o > 0.01 ? 1 : 0.3,
}
}) })
function initCanvas() { function getAmplitude(positionMs) {
if (!isH5.value) return const amp = props.amplitudeData
const canvas = document.getElementById('dh-mouth') if (!amp || amp.length === 0) return -1
if (!canvas) return const idx = Math.floor(positionMs / 50)
// Size the canvas to match mouth area (~40% width, ~15% height, centered bottom) if (idx >= amp.length) return -1
const parent = canvas.parentElement return amp[idx]
if (!parent) return
const rect = parent.getBoundingClientRect()
canvas.width = rect.width * 0.4
canvas.height = rect.height * 0.15
canvas.style.width = canvas.width + 'px'
canvas.style.height = canvas.height + 'px'
canvas.style.position = 'absolute'
canvas.style.bottom = '18%'
canvas.style.left = '30%'
} }
function drawMouth(openRatio) { function tickMouth() {
if (!isH5.value) return if (!audioEl) return
const canvas = document.getElementById('dh-mouth') const currentTime = audioEl.currentTime * 1000 || 0
if (!canvas) return const amp = getAmplitude(currentTime)
const ctx = canvas.getContext('2d') if (amp >= 0) {
if (!ctx) return const openness = Math.pow(Math.min(1, amp * 2.5), 0.7)
mouthOpenness.value = openness
const w = canvas.width } else {
const h = canvas.height const t = Date.now() / 1000
ctx.clearRect(0, 0, w, h) const idle = (Math.sin(t * 4) + 1) / 2 * 0.15
mouthOpenness.value = Math.max(0.03, idle)
const mouthH = Math.max(2, h * openRatio)
const mouthW = w * 0.8
ctx.fillStyle = '#C97B84'
ctx.beginPath()
ctx.ellipse(w / 2, h / 2 + (h - mouthH) / 2, mouthW / 2, mouthH / 2, 0, 0, Math.PI * 2)
ctx.fill()
if (openRatio > 0.1) {
ctx.fillStyle = '#2D1B1E'
ctx.beginPath()
ctx.ellipse(w / 2, h / 2 + (h - mouthH) / 2 + 1, mouthW / 4, mouthH / 4, 0, 0, Math.PI * 2)
ctx.fill()
} }
animFrame = setTimeout(tickMouth, 50)
} }
async function playAudio(url) { function playAudio(url) {
stopAudio() stopAudio()
isSpeaking.value = true isSpeaking.value = true
emit('speaking-start') emit('speaking-start')
tickMouth()
try { try {
audioEl = new Audio(url) const innerAudio = uni.createInnerAudioContext()
audioEl = innerAudio
if (isH5.value) { innerAudio.src = url
audioCtx = new (window.AudioContext || window.webkitAudioContext)() innerAudio.autoplay = true
const source = audioCtx.createMediaElementSource(audioEl) innerAudio.onEnded(() => finishSpeaking())
analyser = audioCtx.createAnalyser() innerAudio.onError(() => finishSpeaking())
analyser.fftSize = 256 innerAudio.onStop(() => finishSpeaking())
source.connect(analyser)
analyser.connect(audioCtx.destination)
}
audioEl.onended = () => {
finishSpeaking()
}
audioEl.onerror = () => {
finishSpeaking()
}
await audioEl.play()
if (analyser) {
animateMouth()
}
} catch (e) { } catch (e) {
finishSpeaking() finishSpeaking()
} }
} }
function animateMouth() {
if (!analyser) return
const dataArray = new Uint8Array(analyser.frequencyBinCount)
function tick() {
if (!isSpeaking.value) return
analyser.getByteFrequencyData(dataArray)
const sum = dataArray.reduce((a, b) => a + b, 0)
const avg = sum / dataArray.length
mouthScale = Math.min(1, avg / 128)
// Smooth
mouthScale = Math.max(0.05, mouthScale)
drawMouth(mouthScale)
animFrameId = requestAnimationFrame(tick)
}
tick()
}
function finishSpeaking() { function finishSpeaking() {
isSpeaking.value = false isSpeaking.value = false
emit('speaking-end') mouthOpenness.value = 0
if (analyser) { cleanupTimers()
mouthScale = 0
drawMouth(0)
}
cleanupAudio() cleanupAudio()
emit('speaking-end')
}
function cleanupTimers() {
if (animFrame) { clearTimeout(animFrame); animFrame = null }
} }
function cleanupAudio() { function cleanupAudio() {
if (animFrameId) { cancelAnimationFrame(animFrameId); animFrameId = null } if (audioEl) {
if (audioCtx) { audioCtx.close().catch(() => {}); audioCtx = null } try { audioEl.stop(); audioEl.destroy() } catch {}
analyser = null
audioEl = null audioEl = null
}
} }
function stopAudio() { function stopAudio() {
if (audioEl) { if (audioEl) { try { audioEl.stop(); audioEl.destroy() } catch {} }
try { audioEl.pause(); audioEl.src = '' } catch {}
}
finishSpeaking() finishSpeaking()
} }
@@ -199,56 +185,63 @@ defineExpose({ play: playAudio, stop: stopAudio })
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 20rpx 0; padding: 10rpx 0;
} }
/* Avatar stage */
.avatar-stage { .avatar-stage {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 12rpx; gap: 10rpx;
position: relative;
} }
.avatar-body {
.avatar-ring {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 260rpx;
border-radius: 50%; border-radius: 20rpx;
border: 4rpx solid #E5E7EB; border: 4rpx solid #E5E7EB;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
transition: border-color 0.3s, box-shadow 0.3s; transition: border-color 0.3s, box-shadow 0.3s;
animation: breathing 4s ease-in-out infinite;
} }
.avatar-body.speaking {
.avatar-ring.speaking {
border-color: #6366F1; border-color: #6366F1;
box-shadow: 0 0 30rpx rgba(99, 102, 241, 0.3); box-shadow: 0 0 40rpx rgba(99, 102, 241, 0.4);
animation: speakPulse 1.5s ease-in-out infinite;
}
@keyframes speakPulse {
0%, 100% { box-shadow: 0 0 20rpx rgba(99, 102, 241, 0.3); }
50% { box-shadow: 0 0 50rpx rgba(99, 102, 241, 0.6); }
}
@keyframes breathing {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.012); }
} }
.avatar-img { .avatar-img {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.mouth-overlay {
.avatar-default { position: absolute;
width: 100%; top: 36.8%;
height: 100%; left: 50%;
background: linear-gradient(135deg, #6366F1, #8B5CF6); transform: translateX(-50%);
display: flex; transition: all 0.08s cubic-bezier(0.25, 0.1, 0.25, 1);
align-items: center;
justify-content: center;
} }
.status-dot {
.avatar-initials { width: 14rpx;
font-size: 48rpx; height: 14rpx;
font-weight: 700; border-radius: 50%;
color: #FFFFFF; background: #9CA3AF;
position: absolute;
top: 8rpx;
right: 8rpx;
transition: background 0.3s;
} }
.status-dot.active {
.mouth-canvas { background: #10B981;
pointer-events: none; box-shadow: 0 0 12rpx rgba(16, 185, 129, 0.6);
} }
.role-label { .role-label {
font-size: 22rpx; font-size: 22rpx;
color: #6B7280; color: #6B7280;
@@ -256,23 +249,19 @@ defineExpose({ play: playAudio, stop: stopAudio })
padding: 4rpx 20rpx; padding: 4rpx 20rpx;
border-radius: 20rpx; border-radius: 20rpx;
} }
/* Speech bubble */
.speech-area { .speech-area {
margin-top: 24rpx; margin-top: 12rpx;
padding: 0 40rpx; padding: 0 40rpx;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
} }
.speech-bubble { .speech-bubble {
background: #FFFFFF; background: #FFFFFF;
border-radius: 16rpx; border-radius: 16rpx;
padding: 24rpx 28rpx; padding: 20rpx 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06); box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
position: relative; position: relative;
} }
.speech-bubble::before { .speech-bubble::before {
content: ''; content: '';
position: absolute; position: absolute;
@@ -282,10 +271,9 @@ defineExpose({ play: playAudio, stop: stopAudio })
border-bottom-color: #FFFFFF; border-bottom-color: #FFFFFF;
border-top: none; border-top: none;
} }
.speech-text { .speech-text {
font-size: 28rpx; font-size: 26rpx;
line-height: 1.7; line-height: 1.6;
color: #1F2937; color: #1F2937;
} }
</style> </style>
+20
View File
@@ -23,6 +23,7 @@ export const APP_CONFIG = {
USER: '/pages/user/user', USER: '/pages/user/user',
LOGIN: '/pages/login/login', LOGIN: '/pages/login/login',
ABOUT: '/pages/about/about', ABOUT: '/pages/about/about',
CAREER: '/pages/career/career',
}, },
STORAGE_KEYS: { STORAGE_KEYS: {
TOKEN: 'token', TOKEN: 'token',
@@ -101,6 +102,25 @@ export const API_ENDPOINTS = {
TTS: { TTS: {
SYNTHESIZE: '/tts/synthesize', SYNTHESIZE: '/tts/synthesize',
AUDIO: (hash: string) => `/tts/audio/${hash}`, AUDIO: (hash: string) => `/tts/audio/${hash}`,
ASR: '/tts/asr',
},
SHARE: {
CREATE: '/share/create',
STATS: '/share/stats',
RECORDS: '/share/records',
VISITORS: '/share/visitors',
},
REVIEW: {
UPLOAD: '/interview-review',
TEXT: '/interview-review/text',
LIST: '/interview-review/list',
DETAIL: (id: string) => `/interview-review/${id}`,
DELETE: (id: string) => `/interview-review/${id}`,
},
CAREER: {
ANALYZE: '/career-advice/analyze',
CHAT: '/career-advice/chat',
POSITIONS: '/career-advice/positions',
}, },
} as const } as const
+4 -3
View File
@@ -1,8 +1,8 @@
{ {
"name": "宇之然AI磁场", "name": "宇之然AI磁场",
"appid": "__UNI__DEV__", "appid": "__UNI__DEV__",
"versionName": "1.0.5", "versionName": "1.0.15",
"versionCode": "105", "versionCode": "115",
"description": "职引 - 宇之然AI磁场旗下AI模拟面试平台,提供AI面试官模拟练习、简历智能优化、大厂面经题库,助你轻松应对校招面试。", "description": "职引 - 宇之然AI磁场旗下AI模拟面试平台,提供AI面试官模拟练习、简历智能优化、大厂面经题库,助你轻松应对校招面试。",
"h5": { "h5": {
"title": "职引 - AI模拟面试 | 宇之然AI磁场", "title": "职引 - AI模拟面试 | 宇之然AI磁场",
@@ -13,7 +13,8 @@
"mp-weixin": { "mp-weixin": {
"appid": "wxf466b3c3bc411ffc", "appid": "wxf466b3c3bc411ffc",
"setting": { "setting": {
"urlCheck": false "urlCheck": false,
"__usePrivacyCheck__": true
}, },
"usingComponents": true "usingComponents": true
} }
+4 -1
View File
@@ -16,7 +16,10 @@
{ "path": "pages/admin/admin", "style": { "navigationBarTitleText": "管理后台" } }, { "path": "pages/admin/admin", "style": { "navigationBarTitleText": "管理后台" } },
{ "path": "pages/result/result", "style": { "navigationBarTitleText": "优化结果" } }, { "path": "pages/result/result", "style": { "navigationBarTitleText": "优化结果" } },
{ "path": "pages/agreement/agreement", "style": { "navigationBarTitleText": "用户协议" } }, { "path": "pages/agreement/agreement", "style": { "navigationBarTitleText": "用户协议" } },
{ "path": "pages/privacy/privacy", "style": { "navigationBarTitleText": "隐私政策" } } { "path": "pages/privacy/privacy", "style": { "navigationBarTitleText": "隐私政策" } },
{ "path": "pages/share/share", "style": { "navigationBarTitleText": "我的分享" } },
{ "path": "pages/review/review", "style": { "navigationBarTitleText": "面试复盘" } },
{ "path": "pages/career/career", "style": { "navigationBarTitleText": "择业顾问" } }
], ],
"tabBar": { "tabBar": {
"color": "#999999", "color": "#999999",
+485 -24
View File
@@ -17,8 +17,11 @@
<text class="tab" :class="{ active: tab === 'overview' }" @click="switchTab('overview')">概览</text> <text class="tab" :class="{ active: tab === 'overview' }" @click="switchTab('overview')">概览</text>
<text class="tab" :class="{ active: tab === 'users' }" @click="switchTab('users')">用户</text> <text class="tab" :class="{ active: tab === 'users' }" @click="switchTab('users')">用户</text>
<text class="tab" :class="{ active: tab === 'interviews' }" @click="switchTab('interviews')">面试</text> <text class="tab" :class="{ active: tab === 'interviews' }" @click="switchTab('interviews')">面试</text>
<text class="tab" :class="{ active: tab === 'resumes' }" @click="switchTab('resumes')">简历</text>
<text class="tab" :class="{ active: tab === 'orders' }" @click="switchTab('orders')">订单</text> <text class="tab" :class="{ active: tab === 'orders' }" @click="switchTab('orders')">订单</text>
<text class="tab" :class="{ active: tab === 'pricing' }" @click="switchTab('pricing')">定价</text> <text class="tab" :class="{ active: tab === 'pricing' }" @click="switchTab('pricing')">定价</text>
<text class="tab" :class="{ active: tab === 'share' }" @click="switchTab('share')">分享</text>
<text class="tab" :class="{ active: tab === 'positions' }" @click="switchTab('positions')">岗位</text>
<text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理</text> <text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理</text>
</view> </view>
@@ -35,6 +38,17 @@
<text class="stat-label">总面试</text> <text class="stat-label">总面试</text>
<text class="stat-sub">今日 +{{ overview.todayInterviews }}</text> <text class="stat-sub">今日 +{{ overview.todayInterviews }}</text>
</view> </view>
<view class="stat-card">
<text class="stat-num">{{ overview.resumeCount ?? 0 }}</text>
<text class="stat-label">总简历</text>
<text class="stat-sub">付费下载 {{ overview.paidDownloadCount ?? 0 }}</text>
</view>
</view>
<view class="plan-cards">
<view class="plan-card" v-for="(cnt, plan) in overview.planBreakdown" :key="plan">
<text class="plan-num">{{ cnt }}</text>
<text class="plan-label">{{ planNameMap[plan] || plan }}</text>
</view>
</view> </view>
</view> </view>
@@ -46,11 +60,21 @@
</view> </view>
<view class="user-list" v-if="!usersLoading"> <view class="user-list" v-if="!usersLoading">
<view class="user-row" v-for="u in users" :key="u._id"> <view class="user-row" v-for="u in users" :key="u._id">
<view class="user-main">
<text class="user-phone">{{ u.phone || '--' }}</text> <text class="user-phone">{{ u.phone || '--' }}</text>
<text class="user-name">{{ u.nickname || '--' }}</text> <text class="user-name">{{ u.nickname || '--' }}</text>
<text class="user-plan" :class="{ vip: u.plan === 'vip' }">{{ u.plan === 'vip' ? '会员' : '免费' }}</text> </view>
<text class="user-remaining">{{ u.remaining || 0 }}</text> <view class="user-badges">
<text class="user-vip-btn" v-if="u.plan !== 'vip'" @click="setVip(u._id)">设为会员</text> <text class="user-plan" :class="{ vip: u.plan === 'growth' || u.plan === 'sprint' }">{{ u.plan === 'growth' || u.plan === 'sprint' ? '会员' : '免费' }}</text>
<text class="user-credit">面试:{{ u.interviewCredits ?? 0 }}</text>
<text class="user-credit">优化:{{ u.resumeOptimizeCredits ?? 0 }}</text>
<text class="user-credit">下载:{{ u.resumeDownloadCredits ?? 0 }}</text>
<text class="user-credit share">分享:{{ u.shareCredits ?? 0 }}</text>
</view>
<view class="user-actions">
<text class="user-action-btn" v-if="u.plan === 'free'" @click="setVip(u._id)">设为会员</text>
<text class="user-action-btn credit" @click="openCreditModal(u)">调整额度</text>
</view>
</view> </view>
<text class="load-more" v-if="usersTotal > users.length" @click="loadMoreUsers">加载更多</text> <text class="load-more" v-if="usersTotal > users.length" @click="loadMoreUsers">加载更多</text>
</view> </view>
@@ -61,15 +85,41 @@
<view v-if="tab === 'interviews'" class="section"> <view v-if="tab === 'interviews'" class="section">
<view class="iv-list" v-if="!ivLoading"> <view class="iv-list" v-if="!ivLoading">
<view class="iv-row" v-for="iv in interviews" :key="iv._id"> <view class="iv-row" v-for="iv in interviews" :key="iv._id">
<view class="iv-main">
<text class="iv-pos">{{ iv.position }}</text> <text class="iv-pos">{{ iv.position }}</text>
<text class="iv-user">{{ iv.userId?.phone || iv.userId?.nickname || '--' }}</text> <text class="iv-user">{{ iv.userId?.phone || iv.userId?.nickname || '--' }}</text>
</view>
<view class="iv-meta">
<text class="iv-status" :class="{ done: iv.status === 'completed' }">{{ iv.status === 'completed' ? '已完成' : '进行中' }}</text> <text class="iv-status" :class="{ done: iv.status === 'completed' }">{{ iv.status === 'completed' ? '已完成' : '进行中' }}</text>
<text class="iv-questions">{{ iv.questionCount || 0 }}</text> <text class="iv-tag">{{ iv.questionCount || 0 }}</text>
<text class="iv-tag score">得分 {{ iv.totalScore ?? '-' }}</text>
<text class="iv-tag filler" v-if="iv.fillerScore != null && iv.fillerScore > 0">语分析 {{ iv.fillerScore }}/{{ iv.fillerDensity ?? '-' }}</text>
</view>
</view> </view>
</view> </view>
<text class="loading-text" v-if="ivLoading">加载中...</text> <text class="loading-text" v-if="ivLoading">加载中...</text>
</view> </view>
<!-- 简历 -->
<view v-if="tab === 'resumes'" class="section">
<view class="resume-list" v-if="!resumeLoading">
<view class="resume-row" v-for="r in resumes" :key="r._id">
<view class="resume-main">
<text class="resume-title">{{ r.title }}</text>
<text class="resume-user">{{ r.userId?.phone || r.userId?.nickname || '--' }}</text>
</view>
<view class="resume-meta">
<text class="resume-tag">v{{ r.version }}</text>
<text class="resume-tag" v-if="r.targetPosition">{{ r.targetPosition }}</text>
<text class="resume-tag paid" v-if="r.paidDownload">付费下载</text>
</view>
<text class="resume-time">{{ r.createdAt?.slice(0,10) }}</text>
</view>
</view>
<text class="loading-text" v-if="resumeLoading">加载中...</text>
<text class="empty-text" v-if="!resumeLoading && resumes.length === 0">暂无简历</text>
</view>
<!-- 订单 --> <!-- 订单 -->
@@ -92,8 +142,10 @@
{{ o.status === 'success' ? '已支付' : o.status === 'refunded' ? '已退款' : '待支付' }} {{ o.status === 'success' ? '已支付' : o.status === 'refunded' ? '已退款' : '待支付' }}
</view> </view>
<text class="order-time">{{ o.createdAt ? o.createdAt.slice(0,16).replace('T',' ') : '--' }}</text> <text class="order-time">{{ o.createdAt ? o.createdAt.slice(0,16).replace('T',' ') : '--' }}</text>
<view class="order-actions" v-if="o.status === 'pending'"> <view class="order-actions">
<text class="sync-btn" @click="syncOrder(o.outTradeNo)">同步</text> <text class="sync-btn" v-if="o.status === 'pending'" @click="syncOrder(o.outTradeNo)">同步</text>
<text class="refund-btn" v-if="o.status === 'success'" @click="openRefundModal(o)">退款</text>
<text class="sync-btn" v-if="o.status === 'refunded'" @click="queryRefund(o.outTradeNo)">查询</text>
</view> </view>
</view> </view>
</view> </view>
@@ -183,6 +235,134 @@
<button class="save-btn" @click="savePricing" :disabled="pricingLoading">保存定价配置</button> <button class="save-btn" @click="savePricing" :disabled="pricingLoading">保存定价配置</button>
<text class="loading-text" v-if="pricingLoading">保存中...</text> <text class="loading-text" v-if="pricingLoading">保存中...</text>
</view> </view>
<!-- 分享 -->
<view v-if="tab === 'share'" class="section">
<view class="tabs in-tab">
<text class="tab" :class="{ active: shareSubTab === 'records' }" @click="shareSubTab='records';loadShareRecords()">分享记录</text>
<text class="tab" :class="{ active: shareSubTab === 'visitors' }" @click="shareSubTab='visitors';loadShareVisitors()">访问记录</text>
</view>
<view v-if="shareSubTab === 'records'">
<view class="share-list" v-if="!shareLoading">
<view class="share-row" v-for="r in shareRecords" :key="r.shareCode">
<view class="share-main">
<text class="share-title">{{ r.title }}</text>
<text class="share-meta">{{ r.sharer?.nickname || '--' }} · {{ r.type }}</text>
</view>
<view class="share-stats">
<text>访问 {{ r.visitCount }}</text>
<text class="share-credited">有效 {{ r.creditedCount }}</text>
</view>
<text class="share-time">{{ r.createdAt?.slice(0,16).replace('T',' ') }}</text>
</view>
</view>
<text class="loading-text" v-if="shareLoading">加载中...</text>
<text class="empty-text" v-if="!shareLoading && shareRecords.length === 0">暂无分享记录</text>
</view>
<view v-if="shareSubTab === 'visitors'">
<view class="share-list" v-if="!shareLoading">
<view class="share-row" v-for="(v, i) in shareVisitors" :key="i">
<view class="share-main">
<text>分享者: {{ v.sharer?.nickname || '--' }}</text>
<text class="share-meta">访客: {{ v.visitor?.nickname || '匿名' }}</text>
</view>
<view class="share-stats">
<text class="badge" :class="v.credited ? 'badge-done' : 'badge-pend'">{{ v.credited ? '已积分' : '未积分' }}</text>
</view>
<text class="share-time">{{ v.createdAt?.slice(0,16).replace('T',' ') }}</text>
</view>
</view>
<text class="loading-text" v-if="shareLoading">加载中...</text>
<text class="empty-text" v-if="!shareLoading && shareVisitors.length === 0">暂无访问记录</text>
</view>
</view>
<!-- 岗位管理 -->
<view v-if="tab === 'positions'" class="section">
<view class="search-bar">
<text class="section-label" style="flex:1;margin:0">岗位列表{{ positions.length }}</text>
<button class="search-btn" @click="openPositionModal(null)">新增岗位</button>
</view>
<view class="position-mgr-list" v-if="!posLoading">
<view class="pos-mgr-row" v-for="p in positions" :key="p._id">
<view class="pos-mgr-main">
<text class="pos-mgr-cat" :class="p.category === 'ai' ? 'cat-ai' : 'cat-tr'">{{ p.category === 'ai' ? 'AI' : '传统' }}</text>
<view class="pos-mgr-body">
<text class="pos-mgr-name">{{ p.name }}</text>
<text class="pos-mgr-meta">{{ p.company || '-' }} · {{ p.salary || '-' }} · sort:{{ p.sort }}</text>
</view>
</view>
<view class="pos-mgr-actions">
<text class="pos-mgr-btn edit" @click="openPositionModal(p)">编辑</text>
<text class="pos-mgr-btn del" @click="deletePosition(p._id, p.name)">删除</text>
</view>
</view>
<text class="empty-text" v-if="positions.length === 0 && !posLoading">暂无岗位</text>
</view>
<text class="loading-text" v-if="posLoading">加载中...</text>
</view>
<!-- 额度调整弹窗 -->
<view class="modal-mask" v-if="creditModal.show" @click="closeCreditModal">
<view class="modal-content" @click.stop>
<text class="modal-title">调整 {{ creditModal.user?.nickname || '用户' }} 的额度</text>
<view class="cfg-row" v-for="t in creditTypes" :key="t.key">
<text>{{ t.label }}</text>
<input class="cfg-input" type="digit" v-model.number="t.value" :placeholder="t.key" />
</view>
<view class="modal-actions">
<button class="modal-btn cancel" @click="closeCreditModal">取消</button>
<button class="modal-btn confirm" @click="doAdjustCredits">确认调整</button>
</view>
</view>
</view>
<!-- 岗位编辑弹窗 -->
<view class="modal-mask" v-if="posModal.show" @click="closePositionModal">
<view class="modal-content" @click.stop>
<text class="modal-title">{{ posModal.isNew ? '新增岗位' : '编辑岗位' }}</text>
<view class="cfg-row"><text>岗位名称</text><input class="cfg-input" v-model="posForm.name" placeholder="必填" /></view>
<view class="cfg-row"><text>薪资</text><input class="cfg-input" v-model="posForm.salary" placeholder="如 15-25K" /></view>
<view class="cfg-row"><text>公司</text><input class="cfg-input" v-model="posForm.company" placeholder="如 字节跳动" /></view>
<view class="cfg-row"><text>排序</text><input class="cfg-input" type="digit" v-model.number="posForm.sort" /></view>
<view class="cfg-row"><text>分类</text>
<picker :range="['AI岗位','传统岗位']" @change="e => posForm.category = e.detail.value === 0 ? 'ai' : 'traditional'">
<text class="cfg-val">{{ posForm.category === 'ai' ? 'AI岗位' : '传统岗位' }}</text>
</picker>
</view>
<view class="cfg-row"><text>启用</text>
<picker :range="['启用','停用']" @change="e => posForm.active = e.detail.value === 0" :value="posForm.active ? 0 : 1">
<text class="cfg-val">{{ posForm.active ? '启用' : '停用' }}</text>
</picker>
</view>
<view class="modal-actions">
<button class="modal-btn cancel" @click="closePositionModal">取消</button>
<button class="modal-btn confirm" @click="savePosition">保存</button>
</view>
</view>
</view>
<!-- 退款弹窗 -->
<view class="modal-mask" v-if="refundModal.show" @click="closeRefundModal">
<view class="modal-content" @click.stop>
<text class="modal-title">退款 - {{ refundModal.order?.outTradeNo }}</text>
<view class="cfg-row">
<text>订单金额</text>
<text class="cfg-val">¥{{ ((refundModal.order?.amount || 0) / 100).toFixed(1) }}</text>
</view>
<view class="cfg-row">
<text>退款金额</text>
<input class="cfg-input" type="digit" v-model.number="refundAmount" :placeholder="((refundModal.order?.amount || 0) / 100).toFixed(1)" />
</view>
<view class="cfg-row">
<text>退款原因</text>
<input class="cfg-input" style="width:300rpx" v-model="refundReason" placeholder="选填" />
</view>
<view class="modal-actions">
<button class="modal-btn cancel" @click="closeRefundModal">取消</button>
<button class="modal-btn confirm" style="background:#EF4444" @click="doRefund">确认退款</button>
</view>
</view>
</view>
<!-- 管理员 --> <!-- 管理员 -->
<view v-if="tab === 'admins'" class="section"> <view v-if="tab === 'admins'" class="section">
<view class="search-bar"> <view class="search-bar">
@@ -213,26 +393,30 @@
</template> </template>
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed, onMounted, reactive } from 'vue'
import { api, API_ENDPOINTS } from '../../config' import { api, API_ENDPOINTS } from '../../config'
const verified = ref(false) const verified = ref(false)
const adminName = ref('') const adminName = ref('')
const tab = ref('overview') const tab = ref('overview')
const shareSubTab = ref('records')
const loading = ref(false) const loading = ref(false)
const usersLoading = ref(false) const usersLoading = ref(false)
const ivLoading = ref(false) const ivLoading = ref(false)
const userKeyword = ref('') const userKeyword = ref('')
const usersPage = ref(1) const usersPage = ref(1)
const overview = ref({ userCount: 0, interviewCount: 0, todayUsers: 0, todayInterviews: 0 }) const overview = ref({ userCount: 0, interviewCount: 0, todayUsers: 0, todayInterviews: 0, resumeCount: 0, paidDownloadCount: 0, planBreakdown: {} })
const planNameMap = { free: '免费', growth: '成长', sprint: '冲刺', vip: '会员' }
const users = ref([]) const users = ref([])
const usersTotal = ref(0) const usersTotal = ref(0)
const interviews = ref([]) const interviews = ref([])
const resumes = ref([])
const resumeLoading = ref(false)
const adminKeyword = ref('') const adminKeyword = ref('')
const adminList = ref([]) const adminList = ref([])
const searchResult = ref(null) const searchResult = ref(null)
const memberConfig = ref({ interview: { maxRoundsFree: 5, maxRoundsVip: 10, dailyFreeLimit: 3 }, diagnosis: { dailyFreeLimit: 2 }, optimize: { dailyFreeLimit: 2 }, price: { monthly: 2900 } }) const memberConfig = ref({ interview: { maxRoundsFree: 5, maxRoundsVip: 10, dailyFreeLimit: 3 }, diagnosis: { dailyFreeLimit: 2 }, optimize: { dailyFreeLimit: 2 }, price: { monthly: 1990 } })
const cfgLoading = ref(false) const cfgLoading = ref(false)
const pricing = ref({ const pricing = ref({
interview: { pricePerSession: 500 }, interview: { pricePerSession: 500 },
@@ -249,11 +433,25 @@ const sprintPriceTemp = ref(49.9)
const growthFeaturesText = ref('') const growthFeaturesText = ref('')
const sprintFeaturesText = ref('') const sprintFeaturesText = ref('')
// Position management
const positions = ref([])
const posLoading = ref(false)
const posModal = ref({ show: false, isNew: false })
const posForm = reactive({
name: '',
salary: '',
company: '',
icon: '',
sort: 0,
active: true,
category: 'ai',
})
const growthPriceDisplay = computed(() => growthPriceTemp.value.toFixed(1)) const growthPriceDisplay = computed(() => growthPriceTemp.value.toFixed(1))
const sprintPriceDisplay = computed(() => sprintPriceTemp.value.toFixed(1)) const sprintPriceDisplay = computed(() => sprintPriceTemp.value.toFixed(1))
const calcInterviewPrice = () => { const calcInterviewPrice = () => {
// Convert to 分 on save // Handled in savePricing via growthPriceTemp / sprintPriceTemp
} }
const orders = ref([]) const orders = ref([])
const ordersTotal = ref(0) const ordersTotal = ref(0)
@@ -261,6 +459,81 @@ const ordersPage = ref(1)
const orderLoading = ref(false) const orderLoading = ref(false)
const orderFilter = ref('') const orderFilter = ref('')
// Share state
const shareRecords = ref([])
const shareVisitors = ref([])
const shareLoading = ref(false)
// Credit modal
const creditModal = ref({ show: false, user: null })
const creditTypes = ref([
{ key: 'interviewCredits', label: '面试次数', value: 0 },
{ key: 'resumeOptimizeCredits', label: '优化次数', value: 0 },
{ key: 'resumeDownloadCredits', label: '下载次数', value: 0 },
{ key: 'shareCredits', label: '分享积分', value: 0 },
])
// Refund modal
const refundModal = ref({ show: false, order: null })
const refundAmount = ref(0)
const refundReason = ref('')
const openRefundModal = (order) => {
refundModal.value = { show: true, order }
refundAmount.value = order.amount / 100
refundReason.value = ''
}
const closeRefundModal = () => {
refundModal.value = { show: false, order: null }
}
const doRefund = async () => {
const order = refundModal.value.order
if (!order) return
uni.showModal({
title: '确认退款', content: `确定对订单 ${order.outTradeNo} 退款 ¥${refundAmount.value.toFixed(1)}`,
success: async (r) => {
if (!r.confirm) return
try {
const res = await apiAdmin('/order/refund', {
method: 'POST',
body: { outTradeNo: order.outTradeNo, amount: Math.round(refundAmount.value * 100), reason: refundReason.value },
})
if (res.statusCode === 200) {
uni.showToast({ title: '退款成功', icon: 'success' })
closeRefundModal()
loadOrders()
} else {
uni.showToast({ title: res.data?.message || '退款失败', icon: 'none' })
}
} catch (e) {
uni.showToast({ title: '退款失败', icon: 'none' })
}
},
})
}
const queryRefund = async (outTradeNo) => {
uni.showToast({ title: '查询中...', icon: 'none' })
try {
const res = await apiAdmin('/order/refund/' + outTradeNo)
if (res.statusCode === 200) {
const wx = res.data.wxRefund
if (wx) {
uni.showModal({
title: '退款状态',
content: `微信状态: ${wx.status || '--'}\n退款金额: ¥${(wx.amount?.refund || 0) / 100}\n建议以微信侧为准`,
})
} else {
uni.showToast({ title: '本地状态: ' + (res.data.localStatus || '--'), icon: 'none' })
}
} else {
uni.showToast({ title: '查询失败', icon: 'none' })
}
} catch { uni.showToast({ title: '查询失败', icon: 'none' }) }
}
const token = () => uni.getStorageSync('token') || '' const token = () => uni.getStorageSync('token') || ''
const apiAdmin = (path, opts = {}) => { const apiAdmin = (path, opts = {}) => {
@@ -278,7 +551,7 @@ const doVerify = async () => {
try { try {
const res = await apiAdmin('/check') const res = await apiAdmin('/check')
if (res.statusCode === 200 && res.data?.isAdmin) { if (res.statusCode === 200 && res.data?.isAdmin) {
adminName.value = '管理员' adminName.value = res.data.nickname || res.data.username || '管理员'
verified.value = true verified.value = true
loadOverview() loadOverview()
} else throw new Error('无管理员权限') } else throw new Error('无管理员权限')
@@ -300,6 +573,8 @@ const switchTab = (t) => {
tab.value = t tab.value = t
if (t === 'users' && users.value.length === 0) loadUsers() if (t === 'users' && users.value.length === 0) loadUsers()
if (t === 'interviews' && interviews.value.length === 0) loadInterviews() if (t === 'interviews' && interviews.value.length === 0) loadInterviews()
if (t === 'positions') loadPositions()
if (t === 'resumes' && resumes.value.length === 0) loadResumes()
if (t === 'admins' && adminList.value.length === 0) loadAdmins() if (t === 'admins' && adminList.value.length === 0) loadAdmins()
if (t === 'pricing') loadPricing() if (t === 'pricing') loadPricing()
if (t === 'orders') loadOrders() if (t === 'orders') loadOrders()
@@ -332,6 +607,15 @@ const loadInterviews = async () => {
finally { ivLoading.value = false } finally { ivLoading.value = false }
} }
const loadResumes = async () => {
resumeLoading.value = true
try {
const res = await apiAdmin('/resumes?page=1&limit=20')
if (res.statusCode === 200) resumes.value = res.data.list || []
} catch (e) { console.error(e) }
finally { resumeLoading.value = false }
}
const loadPricing = async () => { const loadPricing = async () => {
pricingLoading.value = true pricingLoading.value = true
try { try {
@@ -369,15 +653,6 @@ const savePricing = async () => {
finally { pricingLoading.value = false } finally { pricingLoading.value = false }
} }
const loadConfig = async () => {
cfgLoading.value = true
try {
const res = await apiAdmin('/config')
if (res.statusCode === 200) memberConfig.value = res.data
} catch(e) { console.error(e) }
finally { cfgLoading.value = false }
}
const loadOrders = async () => { const loadOrders = async () => {
orderLoading.value = true orderLoading.value = true
ordersPage.value = 1 ordersPage.value = 1
@@ -418,6 +693,84 @@ const loadAdmins = async () => {
} catch(e) { console.error(e) } } catch(e) { console.error(e) }
} }
// ─── 岗位管理 ──────────────────────
const apiPositions = (path, opts = {}) => {
return uni.request({
url: api('/positions' + path),
method: opts.method || 'POST',
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json', ...opts.headers },
data: opts.body || opts.data,
})
}
const loadPositions = async () => {
posLoading.value = true
try {
const res = await apiPositions('/admin/list')
if (res.statusCode === 200) positions.value = res.data || []
} catch (e) { console.error(e) }
finally { posLoading.value = false }
}
const openPositionModal = (position) => {
if (position) {
posForm.name = position.name || ''
posForm.salary = position.salary || ''
posForm.company = position.company || ''
posForm.icon = position.icon || ''
posForm.sort = position.sort ?? 0
posForm.active = position.active ?? true
posForm.category = position.category || 'traditional'
posModal.value = { show: true, isNew: false }
} else {
posForm.name = ''
posForm.salary = ''
posForm.company = ''
posForm.icon = ''
posForm.sort = positions.value.length + 1
posForm.active = true
posForm.category = 'ai'
posModal.value = { show: true, isNew: true }
}
}
const closePositionModal = () => {
posModal.value = { show: false, isNew: false }
}
const savePosition = async () => {
if (!posForm.name.trim()) {
uni.showToast({ title: '岗位名称不能为空', icon: 'none' })
return
}
try {
const res = await apiPositions('/admin/save', {
method: 'POST', body: { ...posForm },
})
if (res.statusCode === 200) {
uni.showToast({ title: '保存成功', icon: 'success' })
closePositionModal()
loadPositions()
} else throw new Error()
} catch { uni.showToast({ title: '保存失败', icon: 'none' }) }
}
const deletePosition = (id, name) => {
uni.showModal({
title: '删除岗位', content: `确定删除"${name}"`,
success: async (r) => {
if (!r.confirm) return
try {
const res = await apiPositions('/admin/' + id, { method: 'DELETE' })
if (res.statusCode === 200) {
uni.showToast({ title: '已删除', icon: 'success' })
loadPositions()
} else throw new Error()
} catch { uni.showToast({ title: '删除失败', icon: 'none' }) }
},
})
}
const searchAdmin = async () => { const searchAdmin = async () => {
if (!adminKeyword.value.trim()) return if (!adminKeyword.value.trim()) return
try { try {
@@ -462,6 +815,56 @@ const setVip = async (targetUserId) => {
} }
}) })
} }
const loadShareRecords = async () => {
shareLoading.value = true
try {
const res = await apiAdmin('/share-records?page=1&limit=50')
if (res.statusCode === 200) shareRecords.value = res.data.list || []
} catch(e) { console.error(e) }
finally { shareLoading.value = false }
}
const loadShareVisitors = async () => {
shareLoading.value = true
try {
const res = await apiAdmin('/share-visitors?page=1&limit=50')
if (res.statusCode === 200) shareVisitors.value = res.data.list || []
} catch(e) { console.error(e) }
finally { shareLoading.value = false }
}
const openCreditModal = (user) => {
creditTypes.value = [
{ key: 'interviewCredits', label: '面试次数', value: user.interviewCredits ?? 0 },
{ key: 'resumeOptimizeCredits', label: '优化次数', value: user.resumeOptimizeCredits ?? 0 },
{ key: 'resumeDownloadCredits', label: '下载次数', value: user.resumeDownloadCredits ?? 0 },
{ key: 'shareCredits', label: '分享积分', value: user.shareCredits ?? 0 },
]
creditModal.value = { show: true, user }
}
const closeCreditModal = () => {
creditModal.value = { show: false, user: null }
}
const doAdjustCredits = async () => {
const userId = creditModal.value.user?._id
if (!userId) return
try {
for (const t of creditTypes.value) {
await apiAdmin('/user/credits', {
method: 'POST',
data: { userId, type: t.key, amount: t.value },
})
}
uni.showToast({ title: '调整成功', icon: 'success' })
closeCreditModal()
loadUsers()
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
}
onMounted(() => { doVerify() })
</script> </script>
<style scoped> <style scoped>
@@ -481,22 +884,37 @@ const setVip = async (targetUserId) => {
.stat-num { font-size: 48rpx; font-weight: 800; color: var(--color-primary); display: block; } .stat-num { font-size: 48rpx; font-weight: 800; color: var(--color-primary); display: block; }
.stat-label { font-size: 22rpx; color: var(--color-text-secondary); margin-top: 8rpx; display: block; } .stat-label { font-size: 22rpx; color: var(--color-text-secondary); margin-top: 8rpx; display: block; }
.stat-sub { font-size: 20rpx; color: var(--color-success); margin-top: 4rpx; display: block; } .stat-sub { font-size: 20rpx; color: var(--color-success); margin-top: 4rpx; display: block; }
.plan-cards { display: flex; gap: 12rpx; margin-top: 16rpx; }
.plan-card { flex: 1; background: #FFF; border-radius: var(--radius-sm); padding: 20rpx; text-align: center; box-shadow: var(--shadow-sm); }
.plan-num { font-size: 36rpx; font-weight: 700; color: var(--color-primary); display: block; }
.plan-label { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; }
.search-bar { display: flex; gap: 12rpx; margin-bottom: 16rpx; } .search-bar { display: flex; gap: 12rpx; margin-bottom: 16rpx; }
.search-input { flex: 1; height: 64rpx; background: #FFF; border: 2rpx solid var(--color-border); border-radius: var(--radius-sm); padding: 0 16rpx; font-size: 24rpx; } .search-input { flex: 1; height: 64rpx; background: #FFF; border: 2rpx solid var(--color-border); border-radius: var(--radius-sm); padding: 0 16rpx; font-size: 24rpx; }
.search-btn { height: 64rpx; padding: 0 24rpx; background: var(--color-primary); color: #FFF; border-radius: var(--radius-sm); font-size: 24rpx; border: none; } .search-btn { height: 64rpx; padding: 0 24rpx; background: var(--color-primary); color: #FFF; border-radius: var(--radius-sm); font-size: 24rpx; border: none; }
.user-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; display: flex; flex-wrap: wrap; gap: 8rpx; } .user-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; }
.user-main { display: flex; gap: 12rpx; margin-bottom: 8rpx; }
.user-phone { font-size: 24rpx; font-weight: 600; color: var(--color-text); } .user-phone { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
.user-name { font-size: 22rpx; color: var(--color-text-secondary); } .user-name { font-size: 22rpx; color: var(--color-text-secondary); }
.user-badges { display: flex; flex-wrap: wrap; gap: 6rpx; margin-bottom: 8rpx; }
.user-plan { font-size: 20rpx; background: #EEF2FF; color: var(--color-primary); padding: 2rpx 12rpx; border-radius: var(--radius-round); } .user-plan { font-size: 20rpx; background: #EEF2FF; color: var(--color-primary); padding: 2rpx 12rpx; border-radius: var(--radius-round); }
.user-remaining { font-size: 20rpx; color: var(--color-text-tertiary); } .user-plan.vip { background: #FEF3C7; color: #D97706; }
.user-credit { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
.user-credit.share { background: #FFF7ED; color: #D97706; }
.user-actions { display: flex; gap: 12rpx; }
.user-action-btn { font-size: 20rpx; color: var(--color-primary); padding: 4rpx 16rpx; border: 2rpx solid var(--color-primary); border-radius: var(--radius-round); }
.user-action-btn.credit { color: #D97706; border-color: #D97706; }
.loading-text { text-align: center; padding: 40rpx; color: var(--color-text-tertiary); font-size: 24rpx; } .loading-text { text-align: center; padding: 40rpx; color: var(--color-text-tertiary); font-size: 24rpx; }
.load-more { text-align: center; padding: 20rpx; color: var(--color-primary); font-size: 24rpx; display: block; } .load-more { text-align: center; padding: 20rpx; color: var(--color-primary); font-size: 24rpx; display: block; }
.iv-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; display: flex; flex-wrap: wrap; gap: 8rpx; align-items: center; } .iv-row { background: #FFF; padding: 16rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; }
.iv-main { display: flex; gap: 12rpx; margin-bottom: 6rpx; }
.iv-pos { font-size: 24rpx; font-weight: 600; color: var(--color-text); } .iv-pos { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
.iv-user { font-size: 22rpx; color: var(--color-text-secondary); } .iv-user { font-size: 22rpx; color: var(--color-text-secondary); }
.iv-meta { display: flex; flex-wrap: wrap; gap: 6rpx; }
.iv-status { font-size: 20rpx; background: #FFF7ED; color: var(--color-warning); padding: 2rpx 12rpx; border-radius: var(--radius-round); } .iv-status { font-size: 20rpx; background: #FFF7ED; color: var(--color-warning); padding: 2rpx 12rpx; border-radius: var(--radius-round); }
.iv-status.done { background: #ECFDF5; color: var(--color-success); } .iv-status.done { background: #ECFDF5; color: var(--color-success); }
.iv-questions { font-size: 20rpx; color: var(--color-text-tertiary); } .iv-tag { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
.iv-tag.score { background: #EEF2FF; color: var(--color-primary); }
.iv-tag.filler { background: #FFF7ED; color: #D97706; }
.section-label { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 12rpx; margin-top: 12rpx; } .section-label { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 12rpx; margin-top: 12rpx; }
.admin-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; display: flex; flex-wrap: wrap; gap: 8rpx; align-items: center; } .admin-row { background: #FFF; padding: 20rpx; border-radius: var(--radius-sm); margin-bottom: 8rpx; display: flex; flex-wrap: wrap; gap: 8rpx; align-items: center; }
.admin-phone { font-size: 24rpx; font-weight: 600; color: var(--color-text); } .admin-phone { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
@@ -505,6 +923,15 @@ const setVip = async (targetUserId) => {
.admin-set-btn.done { color: var(--color-success); border-color: var(--color-success); } .admin-set-btn.done { color: var(--color-success); border-color: var(--color-success); }
.admin-badge { font-size: 18rpx; background: var(--color-primary); color: #FFF; padding: 2rpx 10rpx; border-radius: var(--radius-round); } .admin-badge { font-size: 18rpx; background: var(--color-primary); color: #FFF; padding: 2rpx 10rpx; border-radius: var(--radius-round); }
.empty-text { text-align: center; padding: 20rpx; color: var(--color-text-tertiary); font-size: 22rpx; display: block; } .empty-text { text-align: center; padding: 20rpx; color: var(--color-text-tertiary); font-size: 22rpx; display: block; }
.resume-list { display: flex; flex-direction: column; gap: 8rpx; }
.resume-row { background: #FFF; padding: 16rpx; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12rpx; }
.resume-main { flex: 1; display: flex; flex-direction: column; }
.resume-title { font-size: 22rpx; font-weight: 600; color: var(--color-text); }
.resume-user { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 2rpx; }
.resume-meta { display: flex; gap: 6rpx; }
.resume-tag { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
.resume-tag.paid { background: #FEF3C7; color: #D97706; }
.resume-time { font-size: 18rpx; color: #D1D5DB; white-space: nowrap; }
.order-list { display: flex; flex-direction: column; gap: 8rpx; } .order-list { display: flex; flex-direction: column; gap: 8rpx; }
.order-row { background: #FFF; border-radius: var(--radius-sm); padding: 16rpx; } .order-row { background: #FFF; border-radius: var(--radius-sm); padding: 16rpx; }
.order-info { display: flex; justify-content: space-between; margin-bottom: 8rpx; } .order-info { display: flex; justify-content: space-between; margin-bottom: 8rpx; }
@@ -519,6 +946,7 @@ const setVip = async (targetUserId) => {
.order-time { font-size: 20rpx; color: var(--color-text-tertiary); flex: 1; text-align: right; } .order-time { font-size: 20rpx; color: var(--color-text-tertiary); flex: 1; text-align: right; }
.order-actions { } .order-actions { }
.sync-btn { font-size: 20rpx; color: var(--color-primary); padding: 4rpx 12rpx; border: 2rpx solid var(--color-primary); border-radius: var(--radius-round); } .sync-btn { font-size: 20rpx; color: var(--color-primary); padding: 4rpx 12rpx; border: 2rpx solid var(--color-primary); border-radius: var(--radius-round); }
.refund-btn { font-size: 20rpx; color: #EF4444; padding: 4rpx 12rpx; border: 2rpx solid #EF4444; border-radius: var(--radius-round); }
.config-card { background: #FFF; border-radius: var(--radius-sm); padding: 20rpx; margin-bottom: 12rpx; } .config-card { background: #FFF; border-radius: var(--radius-sm); padding: 20rpx; margin-bottom: 12rpx; }
.cfg-title { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 12rpx; } .cfg-title { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 12rpx; }
.cfg-row { display: flex; justify-content: space-between; padding: 8rpx 0; font-size: 22rpx; color: var(--color-text-secondary); align-items: center; } .cfg-row { display: flex; justify-content: space-between; padding: 8rpx 0; font-size: 22rpx; color: var(--color-text-secondary); align-items: center; }
@@ -527,4 +955,37 @@ const setVip = async (targetUserId) => {
.cfg-textarea { width: 100%; height: 160rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-sm); padding: 12rpx; font-size: 22rpx; margin-top: 8rpx; box-sizing: border-box; } .cfg-textarea { width: 100%; height: 160rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-sm); padding: 12rpx; font-size: 22rpx; margin-top: 8rpx; box-sizing: border-box; }
.save-btn { width: 100%; height: 72rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; border-radius: var(--radius-sm); font-size: 26rpx; border: none; margin-top: 12rpx; } .save-btn { width: 100%; height: 72rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; border-radius: var(--radius-sm); font-size: 26rpx; border: none; margin-top: 12rpx; }
.save-btn:disabled { opacity: 0.6; } .save-btn:disabled { opacity: 0.6; }
.in-tab { margin-bottom: 16rpx; }
.share-list { display: flex; flex-direction: column; gap: 8rpx; }
.share-row { background: #FFF; padding: 16rpx; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12rpx; }
.share-main { flex: 1; display: flex; flex-direction: column; }
.share-title { font-size: 22rpx; color: var(--color-text); font-weight: 500; }
.share-meta { font-size: 18rpx; color: var(--color-text-tertiary); margin-top: 2rpx; }
.share-stats { display: flex; flex-direction: column; align-items: flex-end; font-size: 20rpx; color: var(--color-text-tertiary); }
.share-credited { color: var(--color-primary); }
.share-time { font-size: 18rpx; color: #D1D5DB; white-space: nowrap; }
.badge { font-size: 18rpx; padding: 2rpx 10rpx; border-radius: 6rpx; }
.badge-done { background: #ECFDF5; color: #059669; }
.badge-pend { background: #FEF3C7; color: #D97706; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 999; }
.modal-content { background: #FFF; border-radius: var(--radius-lg); padding: 40rpx 32rpx; width: 600rpx; max-width: 90vw; }
.modal-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); margin-bottom: 24rpx; }
.modal-actions { display: flex; gap: 16rpx; margin-top: 32rpx; }
.modal-btn { flex: 1; height: 72rpx; border-radius: var(--radius-sm); font-size: 26rpx; border: none; }
.modal-btn.cancel { background: #F3F4F6; color: var(--color-text-secondary); }
.modal-btn.confirm { background: var(--color-primary); color: #FFF; }
/* ─── 岗位管理 ───── */
.position-mgr-list { display: flex; flex-direction: column; gap: 8rpx; }
.pos-mgr-row { background: #FFF; padding: 16rpx; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12rpx; }
.pos-mgr-main { flex: 1; display: flex; align-items: center; gap: 12rpx; }
.pos-mgr-cat { font-size: 18rpx; padding: 2rpx 12rpx; border-radius: var(--radius-round); font-weight: 600; }
.pos-mgr-cat.cat-ai { background: #EEF2FF; color: var(--color-primary); }
.pos-mgr-cat.cat-tr { background: #F3F4F6; color: var(--color-text-tertiary); }
.pos-mgr-body { display: flex; flex-direction: column; }
.pos-mgr-name { font-size: 24rpx; font-weight: 600; color: var(--color-text); }
.pos-mgr-meta { font-size: 20rpx; color: var(--color-text-tertiary); margin-top: 2rpx; }
.pos-mgr-actions { display: flex; gap: 8rpx; }
.pos-mgr-btn { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: var(--radius-round); }
.pos-mgr-btn.edit { color: var(--color-primary); border: 2rpx solid var(--color-primary); }
.pos-mgr-btn.del { color: #EF4444; border: 2rpx solid #EF4444; }
</style> </style>
+273
View File
@@ -0,0 +1,273 @@
<template>
<view class="page">
<!-- 输入表单 -->
<view v-if="step === 'input'" class="input-wrap">
<view class="hero">
<text class="hero-icon">🧭</text>
<text class="hero-title">择业顾问</text>
<text class="hero-desc">AI 帮你分析专业前景规划职业方向</text>
</view>
<view class="form-card">
<view class="form-group">
<text class="form-label">你的专业 <text class="required">*</text></text>
<input class="form-input" v-model="profile.major" placeholder="例如:计算机科学与技术" />
</view>
<view class="form-group">
<text class="form-label">年级</text>
<picker :range="grades" @change="e => profile.grade = grades[e.detail.value]">
<view class="form-input select-trigger">{{ profile.grade || '请选择年级' }}</view>
</picker>
</view>
<view class="form-group">
<text class="form-label">兴趣/擅长方向</text>
<input class="form-input" v-model="profile.interests" placeholder="例如:后端开发、数据分析" />
</view>
<view class="form-group">
<text class="form-label">成绩/GPA</text>
<input class="form-input" v-model="profile.gpa" placeholder="例如:3.5/4.0 或专业前 20%" />
</view>
<view class="form-group">
<text class="form-label">你的困惑或目标</text>
<textarea class="form-textarea" v-model="profile.goal" placeholder="例如:不知道该考研还是直接就业,对AI行业很感兴趣但不知道从何入手..." />
</view>
</view>
<button class="submit-btn" :disabled="!profile.major.trim() || loading" @click="doAnalyze">
<text v-if="!loading">开始分析</text>
<text v-else>AI 分析中...</text>
</button>
<text v-if="error" class="error-text">{{ error }}</text>
</view>
<!-- 分析结果 -->
<view v-if="step === 'result'" class="result-wrap">
<view class="result-header">
<text class="result-icon">📊</text>
<text class="result-title">择业分析报告</text>
</view>
<view class="advice-card">
<view class="advice-content">{{ result.reply }}</view>
</view>
<view v-if="result.careerPaths && result.careerPaths.length > 0" class="section">
<text class="section-title">推荐方向</text>
<view class="path-card" v-for="(path, i) in result.careerPaths" :key="i"
@click="goInterview(path.name)">
<view class="path-rank">{{ i + 1 }}</view>
<view class="path-body">
<text class="path-name">{{ path.name }}</text>
<text class="path-reason">{{ path.reason }}</text>
</view>
<view class="path-score-wrap">
<text class="path-score-label">匹配度</text>
<text class="path-score">{{ path.matchScore }}%</text>
<text v-if="path.salary" class="path-salary">{{ path.salary }}</text>
</view>
</view>
<view class="path-hint">点击卡片可进入该岗位的模拟面试</view>
</view>
<view class="action-bar">
<button class="action-btn chat-btn" @click="step = 'chat'; chatMsg = ''">继续咨询</button>
<button class="action-btn retry-btn" @click="step = 'input'; result = null">重新分析</button>
</view>
</view>
<!-- 继续对话 -->
<view v-if="step === 'chat'" class="chat-wrap">
<view class="chat-header">
<text class="chat-back" @click="step = 'result'"> 返回</text>
<text class="chat-title">继续咨询</text>
</view>
<scroll-view class="chat-msgs" scroll-y :scroll-into-view="'msg-' + (chatHistory.length - 1)">
<view v-for="(msg, i) in chatHistory" :key="i" :id="'msg-' + i"
:class="'msg-bubble ' + (msg.role === 'user' ? 'msg-user' : 'msg-ai')">
<text class="msg-text">{{ msg.content }}</text>
</view>
<view v-if="chatLoading" class="msg-bubble msg-ai">
<text class="msg-text typing">AI 思考中...</text>
</view>
</scroll-view>
<view class="chat-input-bar">
<input class="chat-input" v-model="chatMsg" placeholder="输入你的问题..." @confirm="doChat" />
<button class="chat-send" @click="doChat" :disabled="!chatMsg.trim() || chatLoading">发送</button>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config'
const grades = ['大一', '大二', '大三', '大四', '研一', '研二', '研三', '已毕业']
const step = ref('input')
const loading = ref(false)
const chatLoading = ref(false)
const error = ref('')
const result = ref(null)
const chatMsg = ref('')
const chatHistory = ref([])
const profile = reactive({
major: '',
grade: '',
interests: '',
gpa: '',
goal: '',
})
const token = ref('')
onShow(() => {
token.value = uni.getStorageSync('token') || ''
if (!token.value) {
uni.showModal({
title: '请先登录',
content: '需要登录后才能使用择业顾问功能',
confirmText: '去登录',
success: (r) => { if (r.confirm) uni.navigateTo({ url: '/pages/login/login' }) },
})
}
})
const doAnalyze = async () => {
if (!profile.major.trim()) {
error.value = '请填写你的专业'
return
}
loading.value = true
error.value = ''
try {
const res = await uni.request({
url: api('/career-advice/analyze'),
method: 'POST',
data: { ...profile },
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' },
})
if (res.statusCode === 200) {
if (res.data.error) {
error.value = res.data.error
return
}
result.value = res.data
step.value = 'result'
chatHistory.value = [
{ role: 'user', content: `我是${profile.major}专业${profile.grade ? '的' + profile.grade : ''}学生,想了解职业发展方向` },
{ role: 'assistant', content: res.data.reply },
]
} else {
error.value = (res.data && res.data.message) || '分析失败,请稍后重试'
}
} catch (e) {
error.value = '网络错误,请检查网络连接'
} finally {
loading.value = false
}
}
const doChat = async () => {
if (!chatMsg.value.trim() || chatLoading.value) return
const msg = chatMsg.value.trim()
chatMsg.value = ''
chatHistory.value.push({ role: 'user', content: msg })
chatLoading.value = true
try {
const res = await uni.request({
url: api('/career-advice/chat'),
method: 'POST',
data: { message: msg, history: chatHistory.value.slice(0, -1) },
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' },
})
if (res.statusCode === 200) {
chatHistory.value.push({ role: 'assistant', content: res.data.reply || (res.data.error || '') })
} else {
chatHistory.value.push({ role: 'assistant', content: '回复失败,请稍后重试' })
}
} catch {
chatHistory.value.push({ role: 'assistant', content: '网络错误,请检查网络连接' })
} finally {
chatLoading.value = false
}
}
const goInterview = (position) => {
uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(position)}` })
}
</script>
<style scoped>
.page { min-height: 100vh; background: var(--color-bg); padding-bottom: 40rpx; }
/* ===== Input ===== */
.input-wrap { padding: 0 32rpx; }
.hero { display: flex; flex-direction: column; align-items: center; padding: 48rpx 0 32rpx; }
.hero-icon { font-size: 72rpx; }
.hero-title { font-size: 40rpx; font-weight: 700; color: var(--color-text); margin-top: 16rpx; }
.hero-desc { font-size: 26rpx; color: var(--color-secondary); margin-top: 8rpx; }
.form-card { background: #fff; border-radius: var(--radius-lg); padding: 32rpx; box-shadow: var(--shadow-sm); }
.form-group { margin-bottom: 28rpx; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 26rpx; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 12rpx; }
.required { color: var(--color-error); }
.form-input { width: 100%; height: 80rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-md); padding: 0 24rpx; font-size: 26rpx; color: var(--color-text); box-sizing: border-box; background: #FAFBFC; }
.select-trigger { display: flex; align-items: center; }
.form-textarea { width: 100%; height: 160rpx; border: 2rpx solid var(--color-border); border-radius: var(--radius-md); padding: 20rpx 24rpx; font-size: 26rpx; color: var(--color-text); box-sizing: border-box; background: #FAFBFC; resize: none; }
.submit-btn { width: 100%; height: 88rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #fff; font-size: 30rpx; font-weight: 600; border-radius: var(--radius-lg); margin-top: 32rpx; display: flex; align-items: center; justify-content: center; border: none; }
.submit-btn:active { transform: scale(0.98); opacity: 0.9; }
.submit-btn[disabled] { opacity: 0.5; }
.error-text { display: block; text-align: center; color: var(--color-error); font-size: 24rpx; margin-top: 16rpx; }
/* ===== Result ===== */
.result-wrap { padding: 0 32rpx; }
.result-header { display: flex; flex-direction: column; align-items: center; padding: 32rpx 0; }
.result-icon { font-size: 56rpx; }
.result-title { font-size: 34rpx; font-weight: 700; color: var(--color-text); margin-top: 12rpx; }
.advice-card { background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%); border-radius: var(--radius-lg); padding: 32rpx; margin-bottom: 24rpx; }
.advice-content { font-size: 26rpx; color: #374151; line-height: 1.8; white-space: pre-wrap; }
.section { margin-bottom: 24rpx; }
.section-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); display: block; margin-bottom: 16rpx; }
.path-card { display: flex; align-items: center; background: #fff; border-radius: var(--radius-lg); padding: 24rpx; margin-bottom: 16rpx; box-shadow: var(--shadow-sm); }
.path-card:active { transform: scale(0.98); background: #F9FAFB; }
.path-rank { width: 48rpx; height: 48rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #fff; font-size: 24rpx; font-weight: 700; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 16rpx; }
.path-body { flex: 1; }
.path-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); display: block; }
.path-reason { font-size: 22rpx; color: var(--color-secondary); margin-top: 4rpx; display: block; line-height: 1.4; }
.path-score-wrap { display: flex; flex-direction: column; align-items: center; margin-left: 12rpx; flex-shrink: 0; }
.path-score-label { font-size: 20rpx; color: var(--color-secondary); }
.path-score { font-size: 32rpx; font-weight: 700; color: var(--color-primary); }
.path-salary { font-size: 20rpx; color: var(--color-success); margin-top: 2rpx; }
.path-hint { font-size: 22rpx; color: var(--color-secondary); text-align: center; margin-top: -8rpx; margin-bottom: 16rpx; }
.action-bar { display: flex; gap: 16rpx; }
.action-btn { flex: 1; height: 80rpx; font-size: 28rpx; font-weight: 600; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }
.chat-btn { background: var(--color-primary); color: #fff; }
.retry-btn { background: #fff; color: var(--color-text); border: 2rpx solid var(--color-border); }
/* ===== Chat ===== */
.chat-wrap { display: flex; flex-direction: column; height: 100vh; }
.chat-header { display: flex; align-items: center; padding: 24rpx 32rpx; background: #fff; border-bottom: 1rpx solid var(--color-border); }
.chat-back { font-size: 28rpx; color: var(--color-primary); margin-right: 24rpx; }
.chat-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); flex: 1; }
.chat-msgs { flex: 1; padding: 24rpx 32rpx; overflow-y: auto; }
.msg-bubble { max-width: 80%; margin-bottom: 20rpx; padding: 20rpx 24rpx; border-radius: var(--radius-md); font-size: 26rpx; line-height: 1.6; }
.msg-user { background: var(--color-primary); color: #fff; align-self: flex-end; margin-left: auto; border-radius: var(--radius-md) var(--radius-md) 4rpx var(--radius-md); }
.msg-ai { background: #fff; color: var(--color-text); box-shadow: var(--shadow-sm); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4rpx; }
.typing { color: var(--color-secondary); }
.chat-input-bar { display: flex; align-items: center; padding: 16rpx 32rpx; background: #fff; border-top: 1rpx solid var(--color-border); gap: 16rpx; }
.chat-input { flex: 1; height: 72rpx; border: 2rpx solid var(--color-border); border-radius: 36rpx; padding: 0 24rpx; font-size: 26rpx; }
.chat-send { height: 72rpx; padding: 0 32rpx; background: var(--color-primary); color: #fff; font-size: 26rpx; font-weight: 600; border-radius: 36rpx; display: flex; align-items: center; justify-content: center; }
.chat-send[disabled] { opacity: 0.5; }
</style>
+200 -138
View File
@@ -1,197 +1,259 @@
<template> <template>
<view class="page"> <view class="page fade-in">
<!-- 搜索栏 --> <!-- 搜索栏 -->
<view class="search-bar"> <view class="search-bar">
<view class="search-inner">
<text class="search-icon">🔍</text>
<input class="search-input" v-model="keyword" placeholder="搜索公司名称..." @confirm="searchCompany" /> <input class="search-input" v-model="keyword" placeholder="搜索公司名称..." @confirm="searchCompany" />
<text class="search-clear" v-if="keyword" @tap="keyword = ''"></text>
</view>
<button class="search-btn" @tap="searchCompany">搜索</button> <button class="search-btn" @tap="searchCompany">搜索</button>
</view> </view>
<!-- 热门公司 --> <!-- 热门公司 -->
<view class="section" v-if="!searching"> <view class="section" v-if="!selectedCompany">
<view class="section-title">热门公司题库</view> <view class="section-header">
<view class="company-grid"> <text class="section-title">🏢 热门公司题库</text>
<view
class="company-card"
v-for="c in hotCompanies"
:key="c.name"
@tap="selectCompany(c.name)"
>
<view class="company-name">{{ c.name }}</view>
<view class="company-count">{{ c.positions }} 个岗位</view>
</view> </view>
<view class="loading-bar" v-if="loading">
<view class="loading-text">加载中...</view>
</view>
<view class="company-grid" v-else-if="hotCompanies.length > 0">
<view class="company-card card" v-for="c in hotCompanies" :key="c.name" @tap="selectCompany(c.name)">
<text class="company-name">{{ c.name }}</text>
<text class="company-count">{{ c.positionCount > 0 ? c.positionCount + ' 个岗位' : '暂无题库' }}</text>
</view>
</view>
<view class="empty" v-else>
<text class="empty-icon">📭</text>
<text class="empty-text">暂无公司题库数据</text>
<text class="empty-hint">完成面试后贡献面经帮助更多人</text>
</view> </view>
</view> </view>
<!-- 搜索结果岗位列表 --> <!-- 岗位列表 -->
<view class="section" v-if="selectedCompany && !loadingPositions"> <view class="section" v-if="selectedCompany">
<view class="section-title-row"> <view class="section-header">
<text class="section-title">{{ selectedCompany }} - 岗位列表</text> <view class="section-header-left">
<text class="back-link" @tap="selectedCompany = ''">返回</text> <text class="section-back" @tap="backToCompanies"> 返回</text>
<text class="section-title">{{ selectedCompany }}</text>
</view> </view>
<view class="position-list">
<view
class="position-item"
v-for="p in positions"
:key="p.position"
@tap="selectPosition(p.position)"
>
<view class="position-name">{{ p.position }}</view>
<view class="position-meta">{{ p.questionCount }} · {{ p.contributionCount }} 人贡献</view>
</view> </view>
<view class="empty-state" v-if="positions.length === 0"> <view class="loading-bar" v-if="loadingPositions">
<text>暂无该公司的面经数据</text> <view class="loading-text">加载岗位中...</view>
<text class="sub-text">成为第一个贡献者吧</text>
</view> </view>
<view class="position-list" v-else-if="positions.length > 0">
<view class="pos-item card" v-for="p in positions" :key="p.position" @tap="selectPosition(p.position)">
<view class="pos-left">
<text class="pos-icon">{{ p.icon || '💼' }}</text>
<view class="pos-body">
<text class="pos-name">{{ p.position }}</text>
<text class="pos-meta">{{ p.questionCount }} · {{ p.contributionCount }} 人贡献</text>
</view>
</view>
<text class="pos-arrow"></text>
</view>
</view>
<view class="empty" v-else>
<text class="empty-icon">📭</text>
<text class="empty-text">暂无该公司的面经数据</text>
<text class="empty-hint">成为第一个贡献者吧</text>
</view> </view>
</view> </view>
<!-- 题目列表 --> <!-- 题目列表 -->
<view class="section" v-if="selectedPosition && !loadingQuestions"> <view class="section" v-if="selectedPosition">
<view class="section-title-row"> <view class="section-header">
<text class="section-title">{{ selectedCompany }} · {{ selectedPosition }}</text> <view class="section-header-left">
<text class="back-link" @tap="selectedPosition = ''">返回</text> <text class="section-back" @tap="selectedPosition = ''"> 返回</text>
<text class="section-title">{{ selectedPosition }}</text>
</view> </view>
<view class="question-list"> </view>
<view class="question-item" v-for="(q, i) in questions" :key="i"> <view class="loading-bar" v-if="loadingQuestions">
<view class="loading-text">加载题目中...</view>
</view>
<view class="question-list" v-else-if="questions.length > 0">
<view class="question-item card" v-for="(q, i) in questions" :key="i">
<view class="q-header"> <view class="q-header">
<text class="q-num">#{{ i + 1 }}</text> <text class="q-num">#{{ i + 1 }}</text>
<text class="q-tag">{{ q.type === 'technical' ? '技术' : '行为' }}</text> <text class="q-tag" :class="'q-tag-' + (q.type === 'technical' ? 'tech' : 'behavior')">{{ q.type === 'technical' ? '技术' : '行为' }}</text>
<text class="q-diff">{{ difficultyLabel(q.difficulty) }}</text> <text class="q-diff" :class="'q-diff-' + (q.difficulty || 'medium')">{{ difficultyLabel(q.difficulty) }}</text>
<text class="q-freq">{{ q.frequency }} 次提及</text> <text class="q-freq">{{ q.frequency }} 次提及</text>
</view> </view>
<view class="q-content">{{ q.content }}</view> <text class="q-content">{{ q.content }}</text>
<view class="q-tags" v-if="q.tags && q.tags.length"> <view class="q-tags" v-if="q.tags && q.tags.length">
<text class="tag" v-for="t in q.tags" :key="t">{{ t }}</text> <text class="tag" v-for="t in q.tags" :key="t">{{ t }}</text>
</view> </view>
<view class="q-answer" v-if="q.referenceAnswer"> <view class="q-answer" v-if="q.referenceAnswer">
<text class="answer-label">参考思路</text> <text class="answer-label">💡 参考思路</text>
<text class="answer-text">{{ q.referenceAnswer }}</text> <text class="answer-text">{{ q.referenceAnswer }}</text>
</view> </view>
</view> </view>
<view class="empty-state" v-if="questions.length === 0">
<text>暂无题目数据</text>
</view> </view>
<view class="empty" v-else>
<text class="empty-icon">📭</text>
<text class="empty-text">暂无题目数据</text>
</view> </view>
</view> </view>
<!-- 加载态 -->
<view class="loading" v-if="loadingPositions || loadingQuestions">
<text>加载中...</text>
</view>
</view> </view>
</template> </template>
<script> <script setup>
import { ref, onMounted } from 'vue'
import { api } from '../../config' import { api } from '../../config'
const HOT_COMPANIES = [ const keyword = ref('')
{ name: '腾讯', positions: 5 }, const hotCompanies = ref([])
{ name: '字节跳动', positions: 4 }, const selectedCompany = ref('')
{ name: '阿里巴巴', positions: 5 }, const selectedPosition = ref('')
{ name: '美团', positions: 3 }, const positions = ref([])
{ name: '百度', positions: 4 }, const questions = ref([])
{ name: '京东', positions: 3 }, const loading = ref(true)
{ name: '网易', positions: 3 }, const loadingPositions = ref(false)
{ name: '小红书', positions: 2 }, const loadingQuestions = ref(false)
]
export default { onMounted(() => { loadHotCompanies() })
data() {
return { async function loadHotCompanies() {
keyword: '', loading.value = true
searching: false, try {
hotCompanies: HOT_COMPANIES, const token = uni.getStorageSync('token') || ''
selectedCompany: '', const header = token ? { 'Authorization': `Bearer ${token}` } : {}
selectedPosition: '', const res = await uni.request({ url: api('/contribution/companies/hot'), method: 'GET', header })
positions: [], if (res.statusCode === 200) hotCompanies.value = res.data || []
questions: [], } catch (e) { console.error(e) }
loadingPositions: false, finally { loading.value = false }
loadingQuestions: false, }
}
}, function difficultyLabel(d) {
methods: {
difficultyLabel(d) {
const map = { junior: '简单', medium: '中等', senior: '困难' } const map = { junior: '简单', medium: '中等', senior: '困难' }
return map[d] || d || '中等' return map[d] || d || '中等'
}, }
async searchCompany() {
const kw = this.keyword.trim() function searchCompany() {
const kw = keyword.value.trim()
if (!kw) return if (!kw) return
this.selectedCompany = kw selectedCompany.value = kw
this.selectedPosition = '' selectedPosition.value = ''
await this.loadPositions(kw) loadPositions(kw)
}, }
async selectCompany(name) {
this.selectedCompany = name function selectCompany(name) {
this.keyword = name selectedCompany.value = name
this.selectedPosition = '' keyword.value = name
await this.loadPositions(name) selectedPosition.value = ''
}, loadPositions(name)
async loadPositions(company) { }
this.loadingPositions = true
function backToCompanies() {
selectedCompany.value = ''
selectedPosition.value = ''
}
async function loadPositions(company) {
loadingPositions.value = true
const token = uni.getStorageSync('token') || '' const token = uni.getStorageSync('token') || ''
const header = token ? { 'Authorization': `Bearer ${token}` } : {} const header = token ? { 'Authorization': `Bearer ${token}` } : {}
try { try {
const res = await uni.request({ url: api(`/contribution/company/${encodeURIComponent(company)}`), method: 'GET', header }) const res = await uni.request({ url: api(`/contribution/company/${encodeURIComponent(company)}`), method: 'GET', header })
this.positions = res.data || [] positions.value = res.data || []
} catch (e) { } catch (e) { positions.value = [] }
this.positions = [] finally { loadingPositions.value = false }
} }
this.loadingPositions = false
}, function selectPosition(position) {
async selectPosition(position) { selectedPosition.value = position
this.selectedPosition = position loadQuestions(selectedCompany.value, position)
await this.loadQuestions(this.selectedCompany, position) }
},
async loadQuestions(company, position) { async function loadQuestions(company, position) {
this.loadingQuestions = true loadingQuestions.value = true
const token = uni.getStorageSync('token') || '' const token = uni.getStorageSync('token') || ''
const header = token ? { 'Authorization': `Bearer ${token}` } : {} const header = token ? { 'Authorization': `Bearer ${token}` } : {}
try { try {
const res = await uni.request({ const res = await uni.request({
url: api(`/contribution/company/${encodeURIComponent(company)}/position/${encodeURIComponent(position)}`), url: api(`/contribution/company/${encodeURIComponent(company)}/position/${encodeURIComponent(position)}`),
method: 'GET', method: 'GET', header,
header,
}) })
this.questions = res.data?.questions || [] questions.value = res.data?.questions || []
} catch (e) { } catch (e) { questions.value = [] }
this.questions = [] finally { loadingQuestions.value = false }
}
this.loadingQuestions = false
},
},
} }
</script> </script>
<style scoped> <style scoped>
.page { padding: 20rpx; min-height: 100vh; background: #f5f6f7; } .page { min-height: 100vh; background: var(--color-bg); padding: 20rpx 32rpx 40rpx; }
.search-bar { display: flex; gap: 20rpx; margin-bottom: 30rpx; }
.search-input { flex: 1; height: 80rpx; background: #fff; border-radius: 40rpx; padding: 0 30rpx; font-size: 28rpx; } /* 搜索 */
.search-btn { height: 80rpx; line-height: 80rpx; padding: 0 40rpx; background: #4F46E5; color: #fff; border-radius: 40rpx; font-size: 28rpx; } .search-bar { display: flex; gap: 16rpx; margin-bottom: 24rpx; padding-top: 16rpx; }
.section { margin-bottom: 30rpx; background: #fff; border-radius: 16rpx; padding: 30rpx; } .search-inner {
.section-title { font-size: 32rpx; font-weight: 600; margin-bottom: 20rpx; display: block; } flex: 1; height: 76rpx; background: var(--color-surface); border-radius: var(--radius-round);
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20rpx; } display: flex; align-items: center; padding: 0 24rpx; gap: 12rpx;
.back-link { color: #4F46E5; font-size: 26rpx; } box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
.company-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20rpx; } }
.company-card { background: #F3F0FF; border-radius: 12rpx; padding: 24rpx; text-align: center; } .search-icon { font-size: 26rpx; }
.company-name { font-size: 28rpx; font-weight: 500; color: #333; } .search-input { flex: 1; font-size: 26rpx; color: var(--color-text); height: 100%; }
.company-count { font-size: 22rpx; color: #999; margin-top: 8rpx; } .search-clear { font-size: 28rpx; color: var(--color-text-tertiary); padding: 8rpx; }
.position-item { padding: 24rpx; border-bottom: 1rpx solid #f0f0f0; } .search-btn {
.position-name { font-size: 28rpx; font-weight: 500; color: #333; } height: 76rpx; line-height: 76rpx; padding: 0 36rpx; background: var(--color-primary);
.position-meta { font-size: 24rpx; color: #999; margin-top: 8rpx; } color: #fff; border-radius: var(--radius-round); font-size: 26rpx; font-weight: 600; flex-shrink: 0;
.question-item { padding: 24rpx; border-bottom: 1rpx solid #f0f0f0; } }
.q-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 12rpx; }
.q-num { font-size: 24rpx; color: #4F46E5; font-weight: 600; } /* 区块 */
.q-tag { font-size: 22rpx; background: #E8F5E9; color: #2E7D32; padding: 2rpx 12rpx; border-radius: 6rpx; } .section { margin-bottom: 24rpx; }
.q-diff { font-size: 22rpx; background: #FFF3E0; color: #E65100; padding: 2rpx 12rpx; border-radius: 6rpx; } .section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16rpx; }
.q-freq { font-size: 22rpx; color: #999; margin-left: auto; } .section-header-left { display: flex; align-items: center; gap: 16rpx; }
.q-content { font-size: 28rpx; color: #333; line-height: 1.6; } .section-back { font-size: 28rpx; color: var(--color-primary); font-weight: 500; padding: 8rpx 0; }
.section-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
/* 公司网格 */
.company-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16rpx; }
.company-card {
padding: 24rpx; border-radius: var(--radius-lg); text-align: center;
background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
}
.company-card:active { opacity: 0.7; }
.company-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); display: block; }
.company-count { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 8rpx; display: block; }
/* 岗位列表 */
.position-list { display: flex; flex-direction: column; gap: 16rpx; }
.pos-item { padding: 24rpx 28rpx; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: space-between; }
.pos-item:active { transform: scale(0.98); }
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
.pos-icon { font-size: 36rpx; }
.pos-body { flex: 1; min-width: 0; }
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
.pos-meta { font-size: 22rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; }
.pos-arrow { font-size: 32rpx; color: var(--color-text-tertiary); flex-shrink: 0; margin-left: 12rpx; }
/* 题目列表 */
.question-list { display: flex; flex-direction: column; gap: 16rpx; }
.question-item { padding: 24rpx; border-radius: var(--radius-lg); }
.q-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 12rpx; flex-wrap: wrap; }
.q-num { font-size: 22rpx; color: var(--color-primary); font-weight: 700; }
.q-tag { font-size: 20rpx; padding: 2rpx 14rpx; border-radius: var(--radius-round); font-weight: 500; }
.q-tag-tech { background: #DCFCE7; color: #166534; }
.q-tag-behavior { background: #FEF3C7; color: #92400E; }
.q-diff { font-size: 20rpx; padding: 2rpx 14rpx; border-radius: var(--radius-round); font-weight: 500; }
.q-diff-junior { background: #EEF2FF; color: var(--color-primary); }
.q-diff-medium { background: #FEF3C7; color: #92400E; }
.q-diff-senior { background: #FEE2E2; color: #991B1B; }
.q-freq { font-size: 20rpx; color: var(--color-text-tertiary); margin-left: auto; }
.q-content { font-size: 28rpx; color: var(--color-text); line-height: 1.7; }
.q-tags { display: flex; flex-wrap: wrap; gap: 8rpx; margin-top: 12rpx; } .q-tags { display: flex; flex-wrap: wrap; gap: 8rpx; margin-top: 12rpx; }
.tag { font-size: 22rpx; background: #F3F0FF; color: #4F46E5; padding: 4rpx 16rpx; border-radius: 20rpx; } .q-tags .tag { font-size: 20rpx; background: #F3F0FF; color: var(--color-primary); padding: 4rpx 16rpx; border-radius: var(--radius-round); }
.q-answer { margin-top: 16rpx; padding: 16rpx; background: #F8F9FA; border-radius: 8rpx; } .q-answer { margin-top: 16rpx; padding: 20rpx; background: #F9FAFB; border-radius: var(--radius-md); }
.answer-label { font-size: 24rpx; color: #4F46E5; font-weight: 500; } .answer-label { font-size: 22rpx; color: var(--color-primary); font-weight: 600; display: block; margin-bottom: 8rpx; }
.answer-text { font-size: 26rpx; color: #555; line-height: 1.6; } .answer-text { font-size: 24rpx; color: var(--color-text-secondary); line-height: 1.6; }
.empty-state { text-align: center; padding: 60rpx 0; color: #999; font-size: 28rpx; }
.sub-text { display: block; margin-top: 12rpx; font-size: 24rpx; color: #bbb; } /* 空状态 */
.loading { text-align: center; padding: 60rpx; color: #999; } .empty { text-align: center; padding: 60rpx 0; background: var(--color-surface); border-radius: var(--radius-lg); }
.empty-icon { font-size: 48rpx; display: block; margin-bottom: 12rpx; }
.empty-text { font-size: 28rpx; color: var(--color-text-secondary); display: block; }
.empty-hint { font-size: 22rpx; color: var(--color-text-tertiary); margin-top: 8rpx; display: block; }
/* 加载 */
.loading-bar { text-align: center; padding: 40rpx; background: var(--color-surface); border-radius: var(--radius-lg); }
.loading-text { font-size: 24rpx; color: var(--color-text-tertiary); }
</style> </style>
+13 -5
View File
@@ -75,10 +75,12 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { api } from '../../config' import { api } from '../../config'
const props = defineProps({ interviewId: String, position: String }) const interviewId = ref('')
const urlPosition = ref('')
const form = ref({ company: '', position: '', rounds: '', experience: '', tags: [] }) const form = ref({ company: '', position: '', rounds: '', experience: '', tags: [] })
const questionsText = ref('') const questionsText = ref('')
const customTag = ref('') const customTag = ref('')
@@ -89,8 +91,14 @@ const presetTags = ['算法题多', '重视项目经历', '面试官nice', '压
const token = () => uni.getStorageSync('token') || '' const token = () => uni.getStorageSync('token') || ''
onMounted(() => { onLoad((options) => {
if (props.position) form.value.position = props.position if (options?.position) {
urlPosition.value = decodeURIComponent(options.position)
form.value.position = urlPosition.value
}
if (options?.interviewId) {
interviewId.value = options.interviewId
}
}) })
const toggleTag = (tag) => { const toggleTag = (tag) => {
@@ -122,7 +130,7 @@ const submit = async () => {
url: api('/contribution'), method: 'POST', url: api('/contribution'), method: 'POST',
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' }, header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
data: { data: {
interviewId: props.interviewId || '', interviewId: interviewId.value || '',
company: form.value.company.trim(), company: form.value.company.trim(),
position: form.value.position.trim(), position: form.value.position.trim(),
rounds: form.value.rounds.trim(), rounds: form.value.rounds.trim(),
+1
View File
@@ -54,6 +54,7 @@
<text class="empty-title">{{ emptyTitle }}</text> <text class="empty-title">{{ emptyTitle }}</text>
<text class="empty-desc">{{ emptyDesc }}</text> <text class="empty-desc">{{ emptyDesc }}</text>
<button class="empty-btn btn-gradient" @click="goInterview" v-if="filter === 'all'">开始第一次面试</button> <button class="empty-btn btn-gradient" @click="goInterview" v-if="filter === 'all'">开始第一次面试</button>
<button class="empty-btn" @click="goReviewRecording" style="margin-top:12rpx;background:#FFF;color:#4F46E5;border:2rpx solid #4F46E5;border-radius:var(--radius-round);padding:18rpx 48rpx;font-size:26rpx">🎙 录音复盘</button>
</view> </view>
</view> </view>
</template> </template>
+180 -46
View File
@@ -1,20 +1,36 @@
<template> <template>
<view class="page fade-in"> <view class="page fade-in">
<view class="hero"> <view class="hero">
<view class="hero-row">
<view class="hero-left">
<text class="hero-title">{{ greeting }}</text> <text class="hero-title">{{ greeting }}</text>
<text class="hero-sub">试试下面的功能开启你的求职练习</text> <text class="hero-sub">{{ userInfo ? '试试下面的功能开启你的求职练习' : '登录后免费使用 AI 模拟面试 · 简历优化 · 面经题库' }}</text>
</view>
<view class="hero-right">
<view class="user-card card" v-if="userInfo" @click="goProfile"> <view class="user-card card" v-if="userInfo" @click="goProfile">
<image class="avatar" :src="userInfo.avatar || '/static/avatar-default.svg'" mode="aspectFill" /> <image class="avatar" :src="userInfo.avatar || '/static/avatar-default.png'" mode="aspectFill" />
<view class="user-meta"> <view class="user-meta">
<text class="user-name">{{ userInfo.nickname || '同学' }}</text> <text class="user-name">{{ userInfo.nickname || '同学' }}</text>
<view class="user-tags"> <view class="user-tags">
<text class="tag tag-plan">{{ userInfo.plan || '免费版' }}</text> <text class="tag tag-plan">{{ userInfo.plan || '免费版' }}</text>
<text class="tag tag-remaining">剩余 {{ userInfo.remaining || 0 }} </text> <text class="tag tag-remaining">{{ userInfo.interviewCredits > 0 ? '剩余 ' + userInfo.interviewCredits + ' 次' : '已用完' }}</text>
</view> </view>
</view> </view>
<text class="arrow"></text> <text class="arrow"></text>
</view> </view>
<view class="guest-card card" v-else @click="goLogin">
<image class="avatar" src="/static/avatar-default.png" mode="aspectFill" />
<view class="user-meta">
<text class="user-name">登录 / 注册</text>
<view class="guest-benefits">
<text class="guest-benefit">🎙 模拟面试</text>
<text class="guest-benefit">📄 简历优化</text>
</view>
</view>
<text class="guest-arrow"></text>
</view>
</view>
</view>
</view> </view>
<!-- 功能入口 --> <!-- 功能入口 -->
@@ -24,13 +40,27 @@
<view class="fp-left"> <view class="fp-left">
<view class="fp-icon fp-interview"><text class="fp-emoji">🎙</text></view> <view class="fp-icon fp-interview"><text class="fp-emoji">🎙</text></view>
<view class="fp-body"> <view class="fp-body">
<text class="fp-name">模拟面试</text> <text class="fp-name">AI数字人面试</text>
<text class="fp-brief">AI 面试 · 真实场景 · 即时反馈</text> <text class="fp-brief">数字人考 · 真实场景 · 语音互动 · 即时反馈</text>
</view> </view>
</view> </view>
<text class="fp-action">开始</text> <text class="fp-action">开始</text>
</view> </view>
<view class="feature-secondary"> <view class="feature-grid">
<view class="fs-card card" @click="goCareer">
<view class="fs-top">
<view class="fs-icon fs-career"><text class="fs-emoji">🎯</text></view>
<text class="fs-name">AI 择业顾问</text>
</view>
<text class="fs-brief">专业分析 · 岗位匹配 · 智能推荐</text>
</view>
<view class="fs-card card" @click="goResume">
<view class="fs-top">
<view class="fs-icon fs-resume"><text class="fs-emoji">📄</text></view>
<text class="fs-name">简历优化</text>
</view>
<text class="fs-brief">AI 诊断 · 智能优化 · 一键下载</text>
</view>
<view class="fs-card card" @click="goProgress"> <view class="fs-card card" @click="goProgress">
<view class="fs-top"> <view class="fs-top">
<view class="fs-icon fs-progress"><text class="fs-emoji">📊</text></view> <view class="fs-icon fs-progress"><text class="fs-emoji">📊</text></view>
@@ -45,33 +75,18 @@
</view> </view>
<text class="fs-brief">分享经验 · 共建题库 · 帮更多人</text> <text class="fs-brief">分享经验 · 共建题库 · 帮更多人</text>
</view> </view>
</view> <!-- 公司真题库&实习搜索 - 暂隐藏内容待丰富 -->
<view class="feature-secondary">
<view class="fs-card card" @click="goBank">
<view class="fs-top">
<view class="fs-icon fs-progress"><text class="fs-emoji">📚</text></view>
<text class="fs-name">公司真题库</text>
</view>
<text class="fs-brief">大厂真题 · 岗位分类 · 参考思路</text>
</view>
<view class="fs-card card" @click="goInternship">
<view class="fs-top">
<view class="fs-icon fs-contribute"><text class="fs-emoji">🔍</text></view>
<text class="fs-name">实习搜索</text>
</view>
<text class="fs-brief">热门实习 · 一键搜索 · 精准匹配</text>
</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 每日一题 --> <!-- 每日一题 -->
<view class="section" v-if="dailyQuestion"> <view class="section">
<view class="section-header"> <view class="section-header">
<text class="section-title">📮 每日一题</text> <text class="section-title">📮 每日一题</text>
<text class="section-desc" @click="refreshDaily">换一题</text> <text class="section-desc" @click="refreshDaily" v-if="dailyQuestion">换一题</text>
</view> </view>
<view class="daily-card card"> <view class="daily-card card" v-if="dailyQuestion">
<text class="daily-tag">{{ dailyQuestion.category || '综合' }}</text> <text class="daily-tag">{{ dailyQuestion.category || '综合' }}</text>
<text class="daily-question">{{ dailyQuestion.question }}</text> <text class="daily-question">{{ dailyQuestion.question }}</text>
<view class="daily-answer" v-if="showAnswer"> <view class="daily-answer" v-if="showAnswer">
@@ -85,26 +100,66 @@
<text class="daily-action primary" @click="goInterview">模拟练习 </text> <text class="daily-action primary" @click="goInterview">模拟练习 </text>
</view> </view>
</view> </view>
<view class="daily-guest card" v-else-if="!userInfo" @click="goLogin">
<view class="daily-guest-top">
<text class="daily-guest-icon">🔒</text>
<view class="daily-guest-body">
<text class="daily-guest-title">登录后获取今日面试题</text>
<text class="daily-guest-desc">每日一道校招真题持续积累面试经验</text>
</view>
</view>
<text class="daily-action primary">立即登录 </text>
</view>
</view> </view>
<!-- 热门岗位 --> <!-- 热门岗位 - AI 专区 -->
<view class="section"> <view class="section">
<view class="section-header"> <view class="section-header">
<view class="section-title-row"> <view class="section-title-row">
<text class="section-title">热门岗位</text> <text class="section-title">🔥 AI 热门岗位</text>
<text class="section-tag-demo">参考示例</text> <text class="section-badge">NEW</text>
</view> </view>
<text class="section-desc">点击直接面试</text> <text class="section-desc">AI 时代最热方向点击直接面试</text>
</view> </view>
<view class="position-list card" v-if="!positionsLoading"> <view class="ai-banner card" @click="goInterview">
<view class="pos-item" v-for="(pos, idx) in hotPositions" :key="idx" @click="startInterview(pos)"> <text class="ai-banner-title">🚀 AI 正在重塑整个行业</text>
<text class="ai-banner-desc">大模型应用 / Agent 开发 / Prompt 工程 顶尖人才缺口巨大现在上车正当时</text>
</view>
<view class="position-list card" v-if="!positionsLoading && aiPositions.length > 0">
<view class="pos-item" v-for="(pos, idx) in aiPositions" :key="'ai-' + idx" @click="startInterview(pos)">
<view class="pos-left"> <view class="pos-left">
<text class="pos-icon">{{ posIcons[idx] || '💼' }}</text> <text class="pos-icon pos-icon-ai">{{ pos.icon || posIcons[idx % posIcons.length] || '🤖' }}</text>
<view class="pos-body"> <view class="pos-body">
<text class="pos-name">{{ pos.name }}</text> <text class="pos-name">{{ pos.name }}</text>
<view class="pos-meta-row"> <view class="pos-meta-row" v-if="pos.company || pos.salary">
<text class="pos-company">{{ pos.company || '参考公司' }}</text> <text class="pos-company">{{ pos.company }}</text>
<text class="pos-salary">{{ pos.salary || '参考薪资' }}</text> <text class="pos-salary">{{ pos.salary }}</text>
</view>
</view>
</view>
<view class="pos-action">
<text class="pos-action-text pos-action-ai">立即模拟</text>
</view>
</view>
</view>
<!-- 更多岗位 -->
<view class="more-header" @click="showMore = !showMore">
<view class="more-header-left">
<text class="more-icon">🧑💻</text>
<text class="more-title">更多岗位{{ traditionalPositions.length }}</text>
</view>
<text class="more-arrow">{{ showMore ? '收起 ▲' : '展开 ▼' }}</text>
</view>
<view class="position-list card" v-if="showMore && !positionsLoading && traditionalPositions.length > 0">
<view class="pos-item" v-for="(pos, idx) in traditionalPositions" :key="'tr-' + idx" @click="startInterview(pos)">
<view class="pos-left">
<text class="pos-icon">{{ pos.icon || posIcons[(aiPositions.length + idx) % posIcons.length] || '💼' }}</text>
<view class="pos-body">
<text class="pos-name">{{ pos.name }}</text>
<view class="pos-meta-row" v-if="pos.company || pos.salary">
<text class="pos-company">{{ pos.company }}</text>
<text class="pos-salary">{{ pos.salary }}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -121,7 +176,8 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config' import { api } from '../../config'
const userInfo = ref(null) const userInfo = ref(null)
@@ -131,9 +187,17 @@ const posIcons = ['💻', '⚙️', '🤖', '📊', '🎨', '🧪', '📱', '
const positionsLoading = ref(true) const positionsLoading = ref(true)
const dailyQuestion = ref(null) const dailyQuestion = ref(null)
const showAnswer = ref(false) const showAnswer = ref(false)
const showMore = ref(false)
const aiPositions = computed(() => hotPositions.value.filter(p => p.category === 'ai'))
const traditionalPositions = computed(() => hotPositions.value.filter(p => p.category !== 'ai'))
const loadUserInfo = () => {
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s); else userInfo.value = null } catch (e) { userInfo.value = null }
}
onMounted(async () => { onMounted(async () => {
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch (e) {} loadUserInfo()
const h = new Date().getHours() const h = new Date().getHours()
if (h < 6) greeting.value = '夜深了,早点休息 🌙' if (h < 6) greeting.value = '夜深了,早点休息 🌙'
else if (h < 12) greeting.value = '早上好 ☀️' else if (h < 12) greeting.value = '早上好 ☀️'
@@ -163,14 +227,31 @@ onMounted(async () => {
finally { positionsLoading.value = false } finally { positionsLoading.value = false }
}) })
const refreshDaily = () => { showAnswer.value = false; /* trigger reload */ } onShow(loadUserInfo)
const refreshDaily = async () => {
showAnswer.value = false
try {
const t = uni.getStorageSync('token')
if (t) {
const qres = await uni.request({
url: api('/daily-question'), method: 'GET',
header: { 'Authorization': `Bearer ${t}` }
})
if (qres.statusCode === 200 && qres.data) dailyQuestion.value = qres.data
}
} catch (e) { /* silent */ }
}
const goProfile = () => uni.switchTab({ url: '/pages/user/user' }) const goProfile = () => uni.switchTab({ url: '/pages/user/user' })
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
const goInterview = () => uni.navigateTo({ url: '/pages/interview/interview' }) const goInterview = () => uni.navigateTo({ url: '/pages/interview/interview' })
const goResume = () => uni.navigateTo({ url: '/pages/resume/resume' })
const goProgress = () => uni.navigateTo({ url: '/pages/progress/progress' }) const goProgress = () => uni.navigateTo({ url: '/pages/progress/progress' })
const goContribute = () => uni.navigateTo({ url: '/pages/contribute/contribute' }) const goContribute = () => uni.navigateTo({ url: '/pages/contribute/contribute' })
const goBank = () => uni.navigateTo({ url: '/pages/company-bank/bank' }) const goBank = () => uni.navigateTo({ url: '/pages/company-bank/bank' })
const goInternship = () => uni.navigateTo({ url: '/pages/internship/internship' }) const goInternship = () => uni.navigateTo({ url: '/pages/internship/internship' })
const goCareer = () => uni.navigateTo({ url: '/pages/career/career' })
const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` }) const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` })
</script> </script>
@@ -182,16 +263,28 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-mid) 50%, var(--color-gradient-end) 100%); background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-mid) 50%, var(--color-gradient-end) 100%);
padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx; padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx;
} }
.hero-row { display: flex; align-items: flex-start; gap: 24rpx; }
.hero-left { flex: 1; min-width: 0; padding-top: 8rpx; }
.hero-right { flex-shrink: 0; min-width: 280rpx; max-width: 340rpx; }
.hero-title { font-size: 40rpx; font-weight: 700; color: #FFF; display: block; line-height: 1.3; } .hero-title { font-size: 40rpx; font-weight: 700; color: #FFF; display: block; line-height: 1.3; }
.hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; } .hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; }
.user-card { .user-card, .guest-card {
background: rgba(255,255,255,0.95); backdrop-filter: blur(20rpx); background: rgba(255,255,255,0.95); backdrop-filter: blur(20rpx);
border-radius: var(--radius-xl); padding: 24rpx 28rpx; border-radius: var(--radius-xl); padding: 20rpx 24rpx;
display: flex; align-items: center; margin-top: 24rpx; display: flex; align-items: center;
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.1); box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.1);
} }
.avatar { width: 88rpx; height: 88rpx; border-radius: 50%; margin-right: 20rpx; border: 3rpx solid var(--color-primary-light); flex-shrink: 0; } .guest-card {
background: rgba(255,255,255,0.2); backdrop-filter: blur(12rpx);
border: 1rpx solid rgba(255,255,255,0.25);
}
.guest-card .avatar { border-color: rgba(255,255,255,0.35); }
.guest-card .user-name { font-size: 26rpx; color: #FFF; font-weight: 700; }
.guest-benefits { display: flex; gap: 12rpx; margin-top: 6rpx; flex-wrap: wrap; }
.guest-benefit { font-size: 18rpx; color: rgba(255,255,255,0.8); padding: 2rpx 10rpx; background: rgba(255,255,255,0.12); border-radius: 8rpx; }
.guest-arrow { font-size: 36rpx; color: rgba(255,255,255,0.5); margin-left: 12rpx; }
.avatar { width: 72rpx; height: 72rpx; border-radius: 50%; margin-right: 16rpx; border: 3rpx solid var(--color-primary-light); flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; } .user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 30rpx; font-weight: 600; color: var(--color-text); } .user-name { font-size: 30rpx; font-weight: 600; color: var(--color-text); }
.user-tags { display: flex; gap: 10rpx; margin-top: 10rpx; } .user-tags { display: flex; gap: 10rpx; margin-top: 10rpx; }
@@ -205,7 +298,7 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20rpx; } .section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20rpx; }
.section-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); } .section-title { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
.section-title-row { display: flex; align-items: center; gap: 12rpx; } .section-title-row { display: flex; align-items: center; gap: 12rpx; }
.section-tag-demo { font-size: 18rpx; color: #9CA3AF; background: #F3F4F6; padding: 2rpx 10rpx; border-radius: 6rpx; } .section-badge { font-size: 18rpx; color: #fff; background: var(--color-primary); padding: 2rpx 12rpx; border-radius: 20rpx; font-weight: 500; }
.section-desc { font-size: 22rpx; color: var(--color-primary); } .section-desc { font-size: 22rpx; color: var(--color-primary); }
.feature-list { display: flex; flex-direction: column; gap: 16rpx; } .feature-list { display: flex; flex-direction: column; gap: 16rpx; }
@@ -222,15 +315,19 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
.fp-name { font-size: 30rpx; font-weight: 700; color: var(--color-text); } .fp-name { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
.fp-brief { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; } .fp-brief { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; }
.fp-action { font-size: 28rpx; color: var(--color-primary); font-weight: 600; flex-shrink: 0; } .fp-action { font-size: 28rpx; color: var(--color-primary); font-weight: 600; flex-shrink: 0; }
.feature-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 16rpx; } .feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16rpx; }
.fs-card { padding: 20rpx; border-radius: var(--radius-lg); } .fs-card { padding: 20rpx; border-radius: var(--radius-lg); }
.fs-top { display: flex; align-items: center; gap: 10rpx; } .fs-top { display: flex; align-items: center; gap: 10rpx; }
.fs-icon { width: 44rpx; height: 44rpx; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; } .fs-icon { width: 44rpx; height: 44rpx; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fs-emoji { font-size: 20rpx; } .fs-emoji { font-size: 20rpx; }
.fs-name { font-size: 26rpx; font-weight: 600; color: var(--color-text); } .fs-name { font-size: 26rpx; font-weight: 600; color: var(--color-text); }
.fs-brief { font-size: 18rpx; color: var(--color-text-secondary); margin-top: 10rpx; display: block; } .fs-brief { font-size: 18rpx; color: var(--color-text-secondary); margin-top: 10rpx; display: block; }
.fs-career { background: linear-gradient(135deg, #F3E8FF, #D8B4FE); }
.fs-resume { background: linear-gradient(135deg, #ECFDF5, #A7F3D0); }
.fs-progress { background: linear-gradient(135deg, #EEF2FF, #C7D2FE); } .fs-progress { background: linear-gradient(135deg, #EEF2FF, #C7D2FE); }
.fs-contribute { background: linear-gradient(135deg, #ECFDF5, #A7F3D0); } .fs-contribute { background: linear-gradient(135deg, #FFF7ED, #FDBA74); }
.fs-bank { background: linear-gradient(135deg, #FCE7F3, #F9A8D4); }
.fs-internship { background: linear-gradient(135deg, #E0F2FE, #7DD3FC); }
/* 每日一题 */ /* 每日一题 */
.daily-card { padding: 24rpx; border-radius: var(--radius-lg); } .daily-card { padding: 24rpx; border-radius: var(--radius-lg); }
@@ -243,12 +340,36 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
.daily-action { font-size: 24rpx; color: var(--color-text-secondary); } .daily-action { font-size: 24rpx; color: var(--color-text-secondary); }
.daily-action.primary { color: var(--color-primary); font-weight: 600; } .daily-action.primary { color: var(--color-primary); font-weight: 600; }
.daily-guest {
padding: 24rpx; border-radius: var(--radius-lg);
background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
display: flex; align-items: center; justify-content: space-between;
cursor: pointer;
}
.daily-guest:active { opacity: 0.8; }
.daily-guest-top { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
.daily-guest-icon { font-size: 32rpx; width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.6); border-radius: 14rpx; flex-shrink: 0; }
.daily-guest-body { flex: 1; min-width: 0; }
.daily-guest-title { font-size: 26rpx; font-weight: 600; color: var(--color-text); }
.daily-guest-desc { font-size: 20rpx; color: var(--color-text-secondary); margin-top: 4rpx; display: block; }
/* AI 岗位专区 */
.ai-banner {
background: linear-gradient(135deg, #FEF3C7, #FDE68A);
padding: 20rpx 24rpx; border-radius: var(--radius-lg); margin-bottom: 16rpx;
cursor: pointer;
}
.ai-banner:active { transform: scale(0.98); }
.ai-banner-title { font-size: 26rpx; font-weight: 700; color: #92400E; display: block; margin-bottom: 6rpx; }
.ai-banner-desc { font-size: 20rpx; color: #A16207; line-height: 1.5; display: block; }
.position-list { border-radius: var(--radius-lg); overflow: hidden; } .position-list { border-radius: var(--radius-lg); overflow: hidden; }
.pos-item { padding: 24rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; } .pos-item { padding: 24rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.pos-item:last-child { border-bottom: none; } .pos-item:last-child { border-bottom: none; }
.pos-item:active { background: var(--color-bg); } .pos-item:active { background: var(--color-bg); }
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; } .pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
.pos-icon { font-size: 36rpx; width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: center; background: #F3F4F6; border-radius: 14rpx; flex-shrink: 0; } .pos-icon { font-size: 36rpx; width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: center; background: #F3F4F6; border-radius: 14rpx; flex-shrink: 0; }
.pos-icon-ai { background: #FEF3C7; }
.pos-body { display: flex; flex-direction: column; flex: 1; min-width: 0; } .pos-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); } .pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
.pos-meta-row { display: flex; align-items: center; gap: 10rpx; margin-top: 4rpx; } .pos-meta-row { display: flex; align-items: center; gap: 10rpx; margin-top: 4rpx; }
@@ -256,6 +377,19 @@ const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/intervie
.pos-salary { font-size: 20rpx; color: var(--color-primary); background: #EEF2FF; padding: 2rpx 10rpx; border-radius: 6rpx; } .pos-salary { font-size: 20rpx; color: var(--color-primary); background: #EEF2FF; padding: 2rpx 10rpx; border-radius: 6rpx; }
.pos-action { flex-shrink: 0; margin-left: 16rpx; } .pos-action { flex-shrink: 0; margin-left: 16rpx; }
.pos-action-text { font-size: 22rpx; color: var(--color-primary); font-weight: 600; } .pos-action-text { font-size: 22rpx; color: var(--color-primary); font-weight: 600; }
.pos-action-ai { color: #D97706; }
/* 更多岗位折叠 */
.more-header {
display: flex; justify-content: space-between; align-items: center;
padding: 20rpx 4rpx; margin-top: 8rpx; cursor: pointer;
}
.more-header:active { opacity: 0.7; }
.more-header-left { display: flex; align-items: center; gap: 10rpx; }
.more-icon { font-size: 28rpx; }
.more-title { font-size: 26rpx; font-weight: 600; color: var(--color-text-secondary); }
.more-arrow { font-size: 22rpx; color: var(--color-primary); font-weight: 500; }
.loading-tip { text-align: center; padding: 40rpx; font-size: 24rpx; color: var(--color-text-tertiary); background: #FFF; border-radius: var(--radius-lg); } .loading-tip { text-align: center; padding: 40rpx; font-size: 24rpx; color: var(--color-text-tertiary); background: #FFF; border-radius: var(--radius-lg); }
.bottom-spacer { height: 40rpx; } .bottom-spacer { height: 40rpx; }
</style> </style>
+122 -32
View File
@@ -1,67 +1,157 @@
<template> <template>
<view class="page"> <view class="page fade-in">
<view class="hero"> <!-- 搜索栏 -->
<text class="hero-title">实习推荐</text> <view class="search-bar">
<text class="hero-sub">热门实习岗位点击直接模拟面试</text> <view class="search-inner">
<text class="search-icon">🔍</text>
<input class="search-input" v-model="keyword" placeholder="搜索岗位或公司..." @input="onSearch" />
<text class="search-clear" v-if="keyword" @tap="keyword = ''; onSearch()"></text>
</view>
</view> </view>
<view class="body"> <!-- 分类标签 -->
<view class="section-title">🔥 热门实习</view> <view class="tabs">
<view class="position-list card"> <view class="tab" :class="tab === 'all' && 'tab-active'" @tap="tab = 'all'; tabIndex = 0">
<view class="pos-item" v-for="(item, idx) in positions" :key="idx" @click="startInterview(item)"> <text class="tab-text">全部</text>
</view>
<view class="tab" :class="tab === 'ai' && 'tab-active'" @tap="tab = 'ai'; tabIndex = 1">
<text class="tab-text">🤖 AI 岗位</text>
</view>
<view class="tab" :class="tab === 'traditional' && 'tab-active'" @tap="tab = 'traditional'; tabIndex = 2">
<text class="tab-text">💼 传统岗位</text>
</view>
</view>
<!-- 结果计数 -->
<view class="result-info" v-if="!loading">
<text class="result-count"> {{ filteredPositions.length }} 个岗位</text>
</view>
<!-- 岗位列表 -->
<view class="position-list">
<view class="pos-item card" v-for="(item, idx) in filteredPositions" :key="idx" @click="startInterview(item)">
<view class="pos-left"> <view class="pos-left">
<view class="pos-rank">{{ idx + 1 }}</view> <view class="pos-icon-wrap">
<text class="pos-icon">{{ item.icon || '💼' }}</text>
</view>
<view class="pos-body"> <view class="pos-body">
<text class="pos-name">{{ item.name }}</text> <text class="pos-name">{{ item.name }}</text>
<view class="pos-meta-row" v-if="item.company">
<text class="pos-company">{{ item.company }}</text> <text class="pos-company">{{ item.company }}</text>
<text class="pos-badge" :class="item.category === 'ai' ? 'badge-ai' : 'badge-traditional'">{{ item.category === 'ai' ? 'AI' : '传统' }}</text>
</view> </view>
</view> </view>
<text class="pos-salary">{{ item.salary }}</text> </view>
<view class="pos-right">
<text class="pos-salary" v-if="item.salary">{{ item.salary }}</text>
<text class="pos-action">模拟 </text>
</view>
</view> </view>
</view> </view>
<view class="empty" v-if="!loading && positions.length === 0"> <!-- 空状态 -->
<text class="empty-text">暂无实习岗位数据</text> <view class="empty" v-if="!loading && filteredPositions.length === 0">
<text class="empty-icon">🔍</text>
<text class="empty-text">{{ keyword ? '没有匹配的岗位' : '暂无岗位数据' }}</text>
</view> </view>
<!-- 加载 -->
<view class="loading-bar" v-if="loading">
<text class="loading-text">加载中...</text>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { api } from '../../config' import { api } from '../../config'
const keyword = ref('')
const tab = ref('all')
const tabIndex = ref(0)
const positions = ref([]) const positions = ref([])
const loading = ref(true) const loading = ref(true)
const filteredPositions = computed(() => {
let list = positions.value
if (tab.value !== 'all') {
list = list.filter(p => p.category === tab.value)
}
if (keyword.value.trim()) {
const kw = keyword.value.trim().toLowerCase()
list = list.filter(p => (p.name && p.name.toLowerCase().includes(kw)) || (p.company && p.company.toLowerCase().includes(kw)))
}
return list
})
onMounted(async () => { onMounted(async () => {
try { try {
const res = await uni.request({ url: api('/positions/hot'), method: 'GET' }) const res = await uni.request({ url: api('/positions/hot'), method: 'GET' })
if (res.statusCode === 200) positions.value = res.data || [] if (res.statusCode === 200) positions.value = res.data || []
} catch(e) { console.error(e) } } catch (e) { console.error(e) }
finally { loading.value = false } finally { loading.value = false }
}) })
function onSearch() { /* reactivity handles filtering via computed */ }
const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` }) const startInterview = (pos) => uni.navigateTo({ url: `/pages/interview/interview?position=${encodeURIComponent(pos.name)}` })
</script> </script>
<style scoped> <style scoped>
.page { min-height: 100vh; background: var(--color-bg); } .page { min-height: 100vh; background: var(--color-bg); padding: 20rpx 32rpx 40rpx; }
.hero { background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-mid) 50%, var(--color-gradient-end) 100%); padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx; }
.hero-title { font-size: 40rpx; font-weight: 700; color: #FFFFFF; display: block; } /* 搜索 */
.hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; } .search-bar { padding-top: 16rpx; margin-bottom: 20rpx; }
.body { padding: 32rpx; margin-top: -40rpx; } .search-inner {
.section-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); margin-bottom: 16rpx; } height: 76rpx; background: var(--color-surface); border-radius: var(--radius-round);
.position-list { border-radius: var(--radius-lg); overflow: hidden; } display: flex; align-items: center; padding: 0 24rpx; gap: 12rpx;
.pos-item { padding: 24rpx 28rpx; border-bottom: 1rpx solid var(--color-border); display: flex; justify-content: space-between; align-items: center; } box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
.pos-item:active { background: #F9FAFB; } }
.pos-item:last-child { border-bottom: none; } .search-icon { font-size: 26rpx; }
.pos-left { display: flex; align-items: center; gap: 16rpx; } .search-input { flex: 1; font-size: 26rpx; color: var(--color-text); height: 100%; }
.pos-rank { width: 40rpx; height: 40rpx; border-radius: 10rpx; background: #F3F4F6; display: flex; align-items: center; justify-content: center; font-size: 22rpx; font-weight: 700; color: var(--color-primary); flex-shrink: 0; } .search-clear { font-size: 28rpx; color: var(--color-text-tertiary); padding: 8rpx; }
.pos-body { display: flex; flex-direction: column; }
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); } /* 分类标签 */
.pos-company { font-size: 22rpx; color: var(--color-text-tertiary); margin-top: 4rpx; } .tabs { display: flex; gap: 12rpx; margin-bottom: 16rpx; }
.pos-salary { font-size: 24rpx; color: var(--color-primary); font-weight: 600; } .tab {
.empty { display: flex; justify-content: center; padding: 60rpx 0; } padding: 12rpx 24rpx; border-radius: var(--radius-round); background: var(--color-surface);
.empty-text { font-size: 26rpx; color: var(--color-text-tertiary); } box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
}
.tab-active { background: var(--color-primary); }
.tab-active .tab-text { color: #fff; }
.tab-text { font-size: 24rpx; color: var(--color-text-secondary); font-weight: 500; }
/* 结果信息 */
.result-info { margin-bottom: 16rpx; }
.result-count { font-size: 22rpx; color: var(--color-text-tertiary); }
/* 岗位列表 */
.position-list { display: flex; flex-direction: column; gap: 16rpx; }
.pos-item {
padding: 24rpx 28rpx; border-radius: var(--radius-lg);
display: flex; align-items: center; justify-content: space-between;
}
.pos-item:active { transform: scale(0.98); }
.pos-left { display: flex; align-items: center; gap: 16rpx; flex: 1; min-width: 0; }
.pos-icon-wrap { width: 56rpx; height: 56rpx; background: #F3F4F6; border-radius: 14rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pos-icon { font-size: 28rpx; }
.pos-body { flex: 1; min-width: 0; }
.pos-name { font-size: 28rpx; font-weight: 600; color: var(--color-text); display: block; }
.pos-meta-row { display: flex; align-items: center; gap: 10rpx; margin-top: 6rpx; }
.pos-company { font-size: 22rpx; color: var(--color-text-tertiary); }
.pos-badge { font-size: 18rpx; padding: 2rpx 12rpx; border-radius: var(--radius-round); font-weight: 500; }
.badge-ai { background: #FEF3C7; color: #92400E; }
.badge-traditional { background: #EEF2FF; color: var(--color-primary); }
.pos-right { text-align: right; flex-shrink: 0; margin-left: 16rpx; }
.pos-salary { font-size: 24rpx; color: var(--color-primary); font-weight: 600; display: block; margin-bottom: 4rpx; }
.pos-action { font-size: 22rpx; color: var(--color-text-tertiary); }
/* 空状态 */
.empty { text-align: center; padding: 80rpx 0; }
.empty-icon { font-size: 56rpx; display: block; margin-bottom: 16rpx; }
.empty-text { font-size: 28rpx; color: var(--color-text-secondary); }
/* 加载 */
.loading-bar { text-align: center; padding: 60rpx; }
.loading-text { font-size: 24rpx; color: var(--color-text-tertiary); }
</style> </style>
+98 -20
View File
@@ -27,6 +27,8 @@
ref="dhRef" ref="dhRef"
:text="aiSpeechText" :text="aiSpeechText"
:audio-url="aiAudioUrl" :audio-url="aiAudioUrl"
:amplitude-data="aiAmplitudeData"
:position="position"
:auto-play="true" :auto-play="true"
@speaking-start="onAvatarSpeaking" @speaking-start="onAvatarSpeaking"
@speaking-end="onAvatarSilent" @speaking-end="onAvatarSilent"
@@ -53,11 +55,14 @@
</scroll-view> </scroll-view>
<view class="input-bar" v-if="!isComplete"> <view class="input-bar" v-if="!isComplete">
<view class="mic-btn" :class="{ recording: isRecording }" @touchstart="startRecord" @touchend="stopRecord" @touchcancel="stopRecord" @mousedown="startRecord" @mouseup="stopRecord" @mouseleave="stopRecord">
<text class="mic-icon">🎤</text>
</view>
<view class="input-box"> <view class="input-box">
<textarea class="input-area" v-model="inputText" placeholder="输入你的回答..." :auto-height="true" :maxlength="2000" :disabled="aiLoading" @confirm="sendAnswer" /> <textarea class="input-area" v-model="inputText" placeholder="输入你的回答..." :auto-height="true" :maxlength="2000" :disabled="aiLoading" @confirm="sendAnswer" />
</view> </view>
<view class="send-btn" :class="{ disabled: !inputText.trim() || aiLoading }" @click="sendAnswer"> <view class="send-btn" :class="{ disabled: (!inputText.trim() && !isRecording) || aiLoading }" @click="sendAnswer">
<text class="send-icon"></text> <text class="send-icon">{{ isRecording ? '◉' : '➤' }}</text>
</view> </view>
</view> </view>
@@ -83,21 +88,25 @@ const answeredCount = ref(0)
const isComplete = ref(false) const isComplete = ref(false)
const scrollToId = ref('') const scrollToId = ref('')
const position = ref('') const position = ref('')
const avatarMode = ref(false) const avatarMode = ref(true)
const aiSpeechText = ref('') const aiSpeechText = ref('')
const aiAudioUrl = ref('') const aiAudioUrl = ref('')
const aiAmplitudeData = ref([])
const isSpeaking = ref(false) const isSpeaking = ref(false)
const dhRef = ref(null) const dhRef = ref(null)
const isRecording = ref(false)
let recorder = null
let timerSeconds = 0 let timerSeconds = 0
let timerInterval = null let timerInterval = null
const progressPercent = computed(() => Math.min((answeredCount.value / 5) * 100, 100)) let MAX_QUESTIONS = 10
const progressPercent = computed(() => Math.min((answeredCount.value / MAX_QUESTIONS) * 100, 100))
const formatTime = computed(() => { const formatTime = computed(() => {
const m = Math.floor(timerSeconds / 60); const s = timerSeconds % 60 const m = Math.floor(timerSeconds / 60); const s = timerSeconds % 60
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}` return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
}) })
const token = computed(() => uni.getStorageSync('token') || '') const token = () => uni.getStorageSync('token') || ''
onLoad((options) => { onLoad((options) => {
if (options?.position) { if (options?.position) {
@@ -109,7 +118,7 @@ onLoad((options) => {
onMounted(() => { onMounted(() => {
timerInterval = setInterval(() => timerSeconds++, 1000) timerInterval = setInterval(() => timerSeconds++, 1000)
if (token.value) startInterview() if (token()) startInterview()
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
@@ -117,7 +126,7 @@ onBeforeUnmount(() => {
}) })
const checkLogin = () => { const checkLogin = () => {
if (!token.value) { if (!token()) {
uni.showModal({ uni.showModal({
title: '请先登录', content: '登录后即可开始 AI 模拟面试', confirmText: '去登录', title: '请先登录', content: '登录后即可开始 AI 模拟面试', confirmText: '去登录',
success: (r) => { if (r.confirm) uni.navigateTo({ url: '/pages/login/login' }) }, success: (r) => { if (r.confirm) uni.navigateTo({ url: '/pages/login/login' }) },
@@ -133,18 +142,22 @@ const startInterview = async () => {
try { try {
const res = await uni.request({ const res = await uni.request({
url: api('/interview/create'), method: 'POST', url: api('/interview/create'), method: 'POST',
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' }, header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
data: { position: position.value }, data: { position: position.value },
}) })
if (res.statusCode === 200 && res.data) { if (res.statusCode === 200 && res.data) {
interviewId.value = res.data.id interviewId.value = res.data.id
messages.value = res.data.messages || messages.value messages.value = res.data.messages || messages.value
answeredCount.value = res.data.questionCount || 0 answeredCount.value = res.data.questionCount || 0
if (res.data.totalQuestions) MAX_QUESTIONS = res.data.totalQuestions
// Speak first question in avatar mode // Speak first question in avatar mode
if (avatarMode.value && res.data.messages?.length) { if (avatarMode.value && res.data.messages?.length) {
const last = res.data.messages[res.data.messages.length - 1] const last = res.data.messages[res.data.messages.length - 1]
if (last?.role === 'ai') await speakAiText(last.content) if (last?.role === 'ai') await speakAiText(last.content)
} }
} else {
const msg = res.data?.message || '创建面试失败'
messages.value.push({ role: 'ai', content: msg })
} }
} catch { } catch {
messages.value.push({ role: 'ai', content: '创建面试失败,请重试' }) messages.value.push({ role: 'ai', content: '创建面试失败,请重试' })
@@ -156,8 +169,11 @@ const startInterview = async () => {
const sendAnswer = async () => { const sendAnswer = async () => {
if (!inputText.value.trim() || aiLoading.value || isComplete.value) return if (!inputText.value.trim() || aiLoading.value || isComplete.value) return
if (!token.value) { checkLogin(); return } if (!token()) { checkLogin(); return }
if (!interviewId.value) { await startInterview(); return } if (!interviewId.value) {
await startInterview()
if (!interviewId.value) return // creation failed, don't discard answer
}
const answer = inputText.value.trim() const answer = inputText.value.trim()
messages.value.push({ role: 'user', content: answer }) messages.value.push({ role: 'user', content: answer })
@@ -168,21 +184,24 @@ const sendAnswer = async () => {
try { try {
const res = await uni.request({ const res = await uni.request({
url: api(`/interview/${interviewId.value}/answer`), method: 'POST', url: api(`/interview/${interviewId.value}/answer`), method: 'POST',
header: { 'Authorization': `Bearer ${token.value}`, 'Content-Type': 'application/json' }, header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
data: avatarMode.value ? { answer, avatar: true } : { answer }, data: avatarMode.value ? { answer, avatar: true } : { answer },
}) })
if (res.statusCode === 200 && res.data?.messages) { if (res.statusCode === 200 && res.data?.messages) {
const aiMsg = res.data.messages.find(m => m.role === 'ai') const aiMsg = res.data.messages.find(m => m.role === 'ai')
// Only push AI messages from response to avoid duplicating the user message already added above
const newAiMessages = res.data.messages.filter(m => m.role === 'ai')
if (newAiMessages.length > 0) messages.value.push(...newAiMessages)
if (avatarMode.value && aiMsg) { if (avatarMode.value && aiMsg) {
// In avatar mode, only show avatar speaking, don't add to chat await speakAiText(aiMsg.content, res.data.ttsHash, res.data.ttsAmplitude)
await speakAiText(aiMsg.content, res.data.ttsHash)
} else {
messages.value.push(...res.data.messages)
} }
answeredCount.value = res.data.questionCount || answeredCount.value + 1 answeredCount.value = res.data.questionCount || answeredCount.value + 1
if (res.data.ttsHash && !avatarMode.value) { if (res.data.totalQuestions) MAX_QUESTIONS = res.data.totalQuestions
// Still got TTS but not in avatar mode, just show text } else if (res.statusCode === 403) {
} messages.value.push({ role: 'ai', content: res.data?.message || '面试次数已用完' })
isComplete.value = true
} else {
messages.value.push({ role: 'ai', content: res.data?.message || '回答提交失败' })
} }
} catch { } catch {
messages.value.push({ role: 'ai', content: '回答提交失败,请重试' }) messages.value.push({ role: 'ai', content: '回答提交失败,请重试' })
@@ -192,19 +211,21 @@ const sendAnswer = async () => {
} }
} }
async function speakAiText(text, ttsHash) { async function speakAiText(text, ttsHash, ttsAmplitude) {
aiSpeechText.value = text aiSpeechText.value = text
aiAmplitudeData.value = ttsAmplitude || []
if (ttsHash) { if (ttsHash) {
aiAudioUrl.value = api(API_ENDPOINTS.TTS.AUDIO(ttsHash)) aiAudioUrl.value = api(API_ENDPOINTS.TTS.AUDIO(ttsHash))
} else { } else {
try { try {
const synthRes = await uni.request({ const synthRes = await uni.request({
url: api('/tts/synthesize'), method: 'POST', url: api('/tts/synthesize'), method: 'POST',
header: { 'Content-Type': 'application/json' }, header: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token()}` },
data: { text }, data: { text },
}) })
if (synthRes.statusCode === 200 && synthRes.data?.hash) { if (synthRes.statusCode === 200 && synthRes.data?.hash) {
aiAudioUrl.value = api(API_ENDPOINTS.TTS.AUDIO(synthRes.data.hash)) aiAudioUrl.value = api(API_ENDPOINTS.TTS.AUDIO(synthRes.data.hash))
aiAmplitudeData.value = synthRes.data?.amplitudeData || []
} }
} catch {} } catch {}
} }
@@ -229,6 +250,51 @@ const confirmExit = () => {
success: (r) => { if (r.confirm) uni.navigateBack() }, success: (r) => { if (r.confirm) uni.navigateBack() },
}) })
} }
function startRecord() {
if (aiLoading.value || isComplete.value) return
// #ifdef MP-WEIXIN
isRecording.value = true
recorder = uni.getRecorderManager()
recorder.onStart(() => {})
recorder.onError(() => { isRecording.value = false })
recorder.start({ format: 'mp3' })
uni.vibrateShort({ type: 'medium' })
// #endif
// #ifndef MP-WEIXIN
uni.showToast({ title: '语音输入仅支持小程序', icon: 'none' })
// #endif
}
function stopRecord() {
if (!recorder || !isRecording.value) return
isRecording.value = false
recorder.stop()
recorder.onStop(async (res) => {
if (!res.tempFilePath) return
const audioPath = res.tempFilePath
try {
const uploadRes = await uni.uploadFile({
url: api(API_ENDPOINTS.TTS.ASR),
filePath: audioPath,
name: 'audio',
header: { 'Authorization': `Bearer ${token()}` },
})
console.log('[ASR] upload response:', uploadRes.statusCode, typeof uploadRes.data === 'string' ? uploadRes.data.slice(0, 200) : JSON.stringify(uploadRes.data).slice(0, 200))
if (uploadRes.statusCode === 200 && uploadRes.data) {
const data = typeof uploadRes.data === 'string' ? JSON.parse(uploadRes.data) : uploadRes.data
if (data.text) {
inputText.value = data.text
uni.vibrateShort({ type: 'light' })
return
}
}
} catch (e) {
console.error('[ASR] upload error:', e?.message || e)
}
uni.showToast({ title: '语音识别失败,请手动输入', icon: 'none' })
})
}
</script> </script>
<style scoped> <style scoped>
@@ -302,6 +368,18 @@ const confirmExit = () => {
} }
.input-box { flex: 1; background: var(--color-bg); border-radius: var(--radius-md); padding: 12rpx 20rpx; } .input-box { flex: 1; background: var(--color-bg); border-radius: var(--radius-md); padding: 12rpx 20rpx; }
.input-area { width: 100%; font-size: 26rpx; color: var(--color-text); max-height: 160rpx; line-height: 1.5; } .input-area { width: 100%; font-size: 26rpx; color: var(--color-text); max-height: 160rpx; line-height: 1.5; }
.mic-btn {
width: 64rpx; height: 64rpx; border-radius: 50%; background: #F3F4F6;
display: flex; align-items: center; justify-content: center; flex-shrink: 0;
transition: all 0.2s;
}
.mic-btn:active { transform: scale(0.9); }
.mic-btn.recording { background: #FEE2E2; animation: mic-pulse 1s infinite; }
.mic-icon { font-size: 28rpx; }
@keyframes mic-pulse {
0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
50% { box-shadow: 0 0 0 16rpx rgba(239, 68, 68, 0); }
}
.send-btn { .send-btn {
width: 80rpx; height: 80rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); width: 80rpx; height: 80rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid));
border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
+43 -16
View File
@@ -87,15 +87,18 @@
<view class="card" v-if="mainTab === 'wechat' && isMp"> <view class="card" v-if="mainTab === 'wechat' && isMp">
<text class="card-title">微信一键登录</text> <text class="card-title">微信一键登录</text>
<text class="card-sub">授权后自动创建账号</text> <text class="card-sub">授权后自动创建账号</text>
<button class="login-btn wx-btn" @click="doWxLogin">{{ wxLoading ? '登录中...' : '微信一键登录' }}</button> <button class="login-btn wx-btn" :disabled="wxLoading" @click="doWxLogin">{{ wxLoading ? '登录中...' : '微信一键登录' }}</button>
</view> </view>
<!-- 法律声明 --> <!-- 法律声明 - 用户自主勾选同意 -->
<view class="legal"> <view class="legal">
<text class="legal-text">登录即表示同意</text> <label class="agree-label">
<text class="legal-link" @click="goAgreement">用户协议</text> <checkbox :checked="agreed" @tap="agreed = !agreed" color="#4F46E5" style="transform:scale(0.85)" />
<text class="legal-text"></text> <text class="agree-text">我已阅读并同意</text>
<text class="legal-link" @click="goPrivacy">隐私政策</text> <text class="legal-link" @tap.stop="goAgreement">用户服务协议</text>
<text class="agree-text"></text>
<text class="legal-link" @tap.stop="goPrivacy">隐私政策</text>
</label>
</view> </view>
</view> </view>
@@ -117,6 +120,8 @@
import { ref, computed, onMounted, onBeforeUnmount } from 'vue' import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
import { api } from '../../config' import { api } from '../../config'
const agreed = ref(false)
const mainTab = ref('login') const mainTab = ref('login')
const loginMode = ref('password') // 'password' | 'code' const loginMode = ref('password') // 'password' | 'code'
const isMp = ref(false) const isMp = ref(false)
@@ -147,10 +152,14 @@ onMounted(() => {
// #endif // #endif
}) })
onBeforeUnmount(() => { if (timer) clearInterval(timer) }) onBeforeUnmount(() => { if (timer) { clearTimeout(timer); timer = null } })
// //
const showToast = (title, icon = 'none') => uni.showToast({ title, icon }) const showToast = (title, icon = 'none') => uni.showToast({ title, icon })
const checkAgreed = () => {
if (!agreed.value) { showToast('请阅读并同意《用户服务协议》和《隐私政策》'); return false }
return true
}
const loginSuccess = (data) => { const loginSuccess = (data) => {
uni.setStorageSync('token', data.token) uni.setStorageSync('token', data.token)
if (data.user) uni.setStorageSync('userInfo', JSON.stringify(data.user)) if (data.user) uni.setStorageSync('userInfo', JSON.stringify(data.user))
@@ -160,7 +169,7 @@ const loginSuccess = (data) => {
// ====== ====== // ====== ======
const doPasswordLogin = async () => { const doPasswordLogin = async () => {
if (!canPasswordLogin.value) return if (!canPasswordLogin.value || !checkAgreed()) return
pwdLoading.value = true pwdLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -192,6 +201,9 @@ const sendEmailCode = () => {
emailSent.value = true emailSent.value = true
showToast('验证码已发送', 'success') showToast('验证码已发送', 'success')
startCooldown() startCooldown()
if (res.data?.devCode) {
uni.showModal({ title: '开发模式', content: `验证码:${res.data.devCode}`, showCancel: false })
}
} else { } else {
const msg = (res.data && res.data.message) || '发送失败' const msg = (res.data && res.data.message) || '发送失败'
showToast(msg) showToast(msg)
@@ -219,7 +231,7 @@ const startCooldown = () => {
} }
const doEmailLogin = async () => { const doEmailLogin = async () => {
if (!emailCode.value) return if (!emailCode.value || !checkAgreed()) return
emailLoading.value = true emailLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -242,7 +254,7 @@ const doEmailLogin = async () => {
// ====== ====== // ====== ======
const doRegister = async () => { const doRegister = async () => {
if (!canRegister.value) return if (!canRegister.value || !checkAgreed()) return
regLoading.value = true regLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -284,14 +296,28 @@ const skipSetPwd = () => { showSetPwd.value = false }
// ====== ====== // ====== ======
const doWxLogin = async () => { const doWxLogin = async () => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
if (!checkAgreed()) { wxLoading.value = false; return }
wxLoading.value = true wxLoading.value = true
try { try {
const { code } = await uni.login() const wxResp = await uni.login()
const res = await uni.request({ url: api('/user/wx-login'), method: 'POST', data: { code } }) console.log('[wxLogin] uni.login success:', JSON.stringify(wxResp).slice(0, 300))
const { code, errMsg } = wxResp
if (!code) { console.error('[wxLogin] no code:', errMsg); showToast('获取微信凭证失败'); return }
const res = await uni.request({
url: api('/user/wx-login'), method: 'POST',
header: { 'Content-Type': 'application/json' },
data: { code },
})
console.log('[wxLogin] server response:', res.statusCode, JSON.stringify(res.data).slice(0, 500))
if (res.statusCode === 200 && res.data?.token) { if (res.statusCode === 200 && res.data?.token) {
loginSuccess(res.data) loginSuccess(res.data)
} else { showToast('微信登录失败') } } else {
} catch { showToast('微信登录失败') } showToast(res.data?.message || `登录失败(${res.statusCode})`)
}
} catch (e) {
console.error('[wxLogin] error:', JSON.stringify(e).slice(0, 500))
showToast('微信登录失败')
}
finally { wxLoading.value = false } finally { wxLoading.value = false }
// #endif // #endif
} }
@@ -341,8 +367,9 @@ const goPrivacy = () => uni.navigateTo({ url: '/pages/privacy/privacy' })
.switch-hint { text-align: center; font-size: 22rpx; color: var(--color-primary); padding: 20rpx 0 4rpx; } .switch-hint { text-align: center; font-size: 22rpx; color: var(--color-primary); padding: 20rpx 0 4rpx; }
/* ===== Legal ===== */ /* ===== Legal ===== */
.legal { display: flex; justify-content: center; align-items: center; gap: 4rpx; margin-top: 24rpx; flex-wrap: wrap; } .legal { display: flex; justify-content: center; align-items: center; margin-top: 24rpx; flex-wrap: wrap; }
.legal-text { font-size: 22rpx; color: var(--color-text-tertiary); } .agree-label { display: flex; align-items: center; gap: 6rpx; flex-wrap: wrap; justify-content: center; }
.agree-text { font-size: 22rpx; color: var(--color-text-tertiary); }
.legal-link { font-size: 22rpx; color: var(--color-primary); } .legal-link { font-size: 22rpx; color: var(--color-primary); }
/* ===== Password Modal ===== */ /* ===== Password Modal ===== */
+48 -21
View File
@@ -42,7 +42,7 @@
<view class="plan-badge sprint-badge">🚀 冲刺</view> <view class="plan-badge sprint-badge">🚀 冲刺</view>
<view class="plan-header"> <view class="plan-header">
<text class="plan-name">冲刺版</text> <text class="plan-name">冲刺版</text>
<text class="plan-price"><text class="price-num price-sprint">¥49.9</text><text class="price-unit">/</text></text> <text class="plan-price"><text class="price-num price-sprint">{{ sprintPriceText }}</text><text class="price-unit">/</text></text>
</view> </view>
<view class="plan-features"> <view class="plan-features">
<text class="feat" v-for="f in sprintFeatures" :key="f"> {{ f }}</text> <text class="feat" v-for="f in sprintFeatures" :key="f"> {{ f }}</text>
@@ -50,7 +50,7 @@
<view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view> <view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view>
<view class="plan-action owned" v-else-if="plan === 'sprint'"> 已开通</view> <view class="plan-action owned" v-else-if="plan === 'sprint'"> 已开通</view>
<view class="plan-action" v-else-if="plan === 'growth'" @click="startPay('sprint')">升级至冲刺版</view> <view class="plan-action" v-else-if="plan === 'growth'" @click="startPay('sprint')">升级至冲刺版</view>
<view class="plan-action" v-else @click="startPay('sprint')">¥49.9/ 立即开通</view> <view class="plan-action" v-else @click="startPay('sprint')">{{ sprintPriceText }}/ 立即开通</view>
</view> </view>
</view> </view>
@@ -89,6 +89,7 @@
<script setup> <script setup>
import { ref, onMounted, nextTick } from 'vue' import { ref, onMounted, nextTick } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config' import { api } from '../../config'
import UQRCode from 'uqrcodejs' import UQRCode from 'uqrcodejs'
@@ -104,26 +105,24 @@ const payError = ref('')
const payingPlanName = ref('') const payingPlanName = ref('')
const payingPlan = ref('') const payingPlan = ref('')
const growthPriceText = ref('¥19.9') const growthPriceText = ref('¥19.9')
const sprintPriceText = ref('¥49.9')
const currentOutTradeNo = ref('') const currentOutTradeNo = ref('')
const freeFeatures = ['每日 2 次 AI 模拟面试', '基础面试报告', '通用题库随机出题', '简历诊断(限 3 次)'] const freeFeatures = ref(['AI 模拟面试 1 次(体验)', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费'])
const growthFeatures = [ const growthFeatures = ref(['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库'])
'免费版全部权益', '无限面试次数', '详细面试报告(四维评分)', const sprintFeatures = ref(['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选'])
'进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库',
]
const sprintFeatures = [
'成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告',
'学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先',
]
const token = () => uni.getStorageSync('token') || '' const token = () => uni.getStorageSync('token') || ''
onMounted(async () => { const refreshState = async () => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
isMp.value = true isMp.value = true
// #endif // #endif
const t = token() const t = token()
if (!t) return if (!t) {
isLoggedIn.value = false
return
}
isLoggedIn.value = true isLoggedIn.value = true
try { try {
@@ -136,12 +135,25 @@ onMounted(async () => {
plan.value = d.plan || 'free' plan.value = d.plan || 'free'
currentPlanName.value = d.planName || '免费版' currentPlanName.value = d.planName || '免费版'
} }
if (lres.statusCode === 200 && lres.data?.price) { if (lres.statusCode === 200 && lres.data) {
const p = lres.data.price const plans = Array.isArray(lres.data.plans) ? lres.data.plans : (Array.isArray(lres.data) ? lres.data : [])
growthPriceText.value = `¥${(p.monthly / 100).toFixed(1)}` const growth = plans.find((p) => p.id === 'growth')
const sprint = plans.find((p) => p.id === 'sprint')
if (growth) {
growthPriceText.value = `¥${(growth.price / 100).toFixed(1)}`
if (growth.features?.length) growthFeatures.value = growth.features
}
if (sprint?.features?.length) sprintFeatures.value = sprint.features
if (sprint) sprintPriceText.value = `¥${(sprint.price / 100).toFixed(1)}`
if (lres.data.price?.monthly) {
growthPriceText.value = `¥${(lres.data.price.monthly / 100).toFixed(1)}`
}
} }
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
}) }
onMounted(() => { refreshState() })
onShow(() => { refreshState() })
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' }) const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
@@ -178,6 +190,7 @@ const startPay = async (selectedPlan) => {
url: api('/payment/jsapi'), method: 'POST', url: api('/payment/jsapi'), method: 'POST',
data: { plan: planLabel }, data: { plan: planLabel },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' }, header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
timeout: 30000,
}) })
payLoading.value = false payLoading.value = false
@@ -192,13 +205,22 @@ const startPay = async (selectedPlan) => {
package: pp.package, package: pp.package,
signType: pp.signType || 'RSA', signType: pp.signType || 'RSA',
paySign: pp.paySign, paySign: pp.paySign,
success: () => pollPayResult(res.data.prepayId, planLabel), success: () => {
const no = currentOutTradeNo.value || res.data.outTradeNo
pollPayResult(no, planLabel)
},
fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) }, fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) },
}) })
} else if (!res.statusCode || res.statusCode === 0) {
payLoading.value = false
const errMsg = '网络连接失败,请检查网络后重试'
payError.value = errMsg
uni.showToast({ title: errMsg, icon: 'none' })
} else { } else {
payLoading.value = false payLoading.value = false
payError.value = res.data?.message || '创建订单失败' const errMsg = res.data?.message || '创建订单失败'
uni.showToast({ title: '创建订单失败', icon: 'none' }) payError.value = errMsg
uni.showToast({ title: errMsg, icon: 'none' })
} }
} catch (e) { } catch (e) {
payLoading.value = false payLoading.value = false
@@ -233,9 +255,14 @@ const startPay = async (selectedPlan) => {
}) })
// //
pollPayResult(res.data.outTradeNo, planLabel) pollPayResult(res.data.outTradeNo, planLabel)
} else if (!res.statusCode || res.statusCode === 0) {
payLoading.value = false
const errMsg = '网络连接失败,请检查网络后重试'
payError.value = errMsg
uni.showToast({ title: errMsg, icon: 'none' })
} else { } else {
payError.value = res.data?.message || '支付服务暂不可用' payError.value = res.data?.message || '支付服务暂不可用'
uni.showToast({ title: '支付服务暂不可用', icon: 'none' }) uni.showToast({ title: res.data?.message || '支付服务暂不可用', icon: 'none' })
} }
} catch (e) { } catch (e) {
payLoading.value = false payLoading.value = false
+24 -7
View File
@@ -134,6 +134,7 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config' import { api } from '../../config'
const stats = ref({ completedInterviews: 0, avgScore: 0, streak: 0 }) const stats = ref({ completedInterviews: 0, avgScore: 0, streak: 0 })
@@ -155,6 +156,16 @@ onMounted(async () => {
const t = token() const t = token()
if (!t) return if (!t) return
await loadProgressData()
})
onShow(async () => {
if (token()) await loadProgressData()
})
async function loadProgressData() {
const t = token()
if (!t) return
try { try {
// Load progress // Load progress
const res = await uni.request({ const res = await uni.request({
@@ -166,7 +177,7 @@ onMounted(async () => {
progress.value = d progress.value = d
dimensions.value = dimensions.value.map(dim => ({ dimensions.value = dimensions.value.map(dim => ({
...dim, ...dim,
value: d.dimensions?.[dim.key] || Math.round(50 + Math.random() * 30), value: d.dimensions?.[dim.key] || 0,
})) }))
} }
} catch (e) { console.error(e) } } catch (e) { console.error(e) }
@@ -191,23 +202,29 @@ onMounted(async () => {
} }
} catch (e) { console.error(e) } } catch (e) { console.error(e) }
// Build week days buildWeekDays()
}
function buildWeekDays() {
const days = ['日', '一', '二', '三', '四', '五', '六'] const days = ['日', '一', '二', '三', '四', '五', '六']
const today = new Date() const today = new Date()
const arr = [] const arr = []
const checkinDates = (progress.value.checkins || []).map((c) => {
const d = new Date(c.date || c.createdAt)
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
})
for (let i = 6; i >= 0; i--) { for (let i = 6; i >= 0; i--) {
const d = new Date(today) const d = new Date(today)
d.setDate(d.getDate() - i) d.setDate(d.getDate() - i)
const isToday = i === 0 const key = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
// Mark days with interviews (simulate based on streak)
arr.push({ arr.push({
label: days[d.getDay()], label: days[d.getDay()],
isToday, isToday: i === 0,
done: i < (stats.value.streak || 0), done: checkinDates.includes(key),
}) })
} }
weekDays.value = arr weekDays.value = arr
}) }
const formatDate = (d) => { const formatDate = (d) => {
if (!d) return '' if (!d) return ''
+10 -9
View File
@@ -156,7 +156,9 @@ onLoad(async (options) => {
})) }))
} }
} }
}).catch(() => {}) }).catch(e => {
console.error('[report] auto-complete failed:', e)
})
} }
} }
} catch(e) { console.error(e) } } catch(e) { console.error(e) }
@@ -288,15 +290,12 @@ async function generateCard() {
ctx.setFillStyle('rgba(165,180,252,0.5)') ctx.setFillStyle('rgba(165,180,252,0.5)')
ctx.fillText('扫码开始你的模拟面试 → 在微信搜索"职引"小程序', w / 2, 690) ctx.fillText('扫码开始你的模拟面试 → 在微信搜索"职引"小程序', w / 2, 690)
// QR code hint (simulated) // QR text hint
ctx.setFillStyle('#FFFFFF') ctx.setFillStyle('#FFFFFF')
ctx.setFontSize(12) ctx.setFontSize(16)
ctx.setTextAlign('center') ctx.setTextAlign('center')
ctx.fillText('⬛ ⬛ ⬛ ⬛ ⬛', w / 2, 760) ctx.fillText('在微信搜索「职引」小程序', w / 2, 760)
ctx.fillText('⬛ ⬛ ⬛ ⬛ ⬛', w / 2, 780) ctx.fillText('查看完整面试报告', w / 2, 790)
ctx.fillText('⬛ ⬛ ⬛ ⬛ ⬛', w / 2, 800)
ctx.fillText('⬛ ⬛ ⬛ ⬛ ⬛', w / 2, 820)
ctx.fillText('微信小程序', w / 2, 855)
ctx.draw(false, async () => { ctx.draw(false, async () => {
try { try {
@@ -306,7 +305,9 @@ async function generateCard() {
itemList: ['保存到相册', '分享给好友'], itemList: ['保存到相册', '分享给好友'],
success: (res) => { success: (res) => {
if (res.tapIndex === 0) { if (res.tapIndex === 0) {
uni.saveImageToPhotosAlbum({ filePath: tempRes.tempFilePath }) uni.saveImageToPhotosAlbum({ filePath: tempRes.tempFilePath, success: () => uni.showToast({ title: '已保存到相册', icon: 'success' }) })
} else if (res.tapIndex === 1) {
uni.shareAppMessage ? uni.shareAppMessage({ title: '我的面试报告', imageUrl: tempRes.tempFilePath }) : uni.showToast({ title: '请截图后分享', icon: 'none' })
} }
}, },
}) })
+9 -6
View File
@@ -16,7 +16,7 @@
<text class="score-num">{{ diagnosisResult.score }}</text> <text class="score-num">{{ diagnosisResult.score }}</text>
<text class="score-label">/100</text> <text class="score-label">/100</text>
</view> </view>
<text class="summary-text">{{ diagnosisResult.summary }}</text> <text class="summary-text" v-if="diagnosisResult.summary">{{ diagnosisResult.summary }}</text>
</view> </view>
<!-- 岗位匹配度诊断模式 --> <!-- 岗位匹配度诊断模式 -->
@@ -136,16 +136,19 @@ onLoad(async (options: any) => {
function applyResult(data: any) { function applyResult(data: any) {
loading.value = false; loading.value = false;
if (isOptimize.value) { if (isOptimize.value) {
optimizedContent.value = data.optimizedContent || ''; optimizedContent.value = data.optimized || '';
changes.value = data.changes || []; changes.value = (data.changes || []).map((c: any) =>
highlights.value = data.highlights || []; typeof c === 'string' ? { section: c, description: c } : c
);
highlights.value = [];
} else { } else {
diagnosisResult.value = data; diagnosisResult.value = data;
changes.value = (data.issues || []).map((i: any) => ({ changes.value = (data.issues || []).map((i: any) => ({
...i, ...i,
typeLabel: i.type === 'structure' ? '结构' : i.type === 'content' ? '内容' : i.type === 'keywords' ? '关键词' : i.type === 'achievement' ? '成就' : '格式', typeLabel: i.level === 'high' ? '严重' : i.level === 'medium' ? '中等' : '轻微',
description: i.desc || i.description,
})); }));
highlights.value = data.strengths || []; highlights.value = data.suggestions || [];
} }
} }
+693
View File
@@ -0,0 +1,693 @@
<template>
<view class="page">
<!-- ====== Mode 1: List View ====== -->
<template v-if="mode === 'list'">
<view class="hero">
<text class="hero-title">面试复盘</text>
<text class="hero-sub">上传录音AI 帮你复盘面试表现</text>
</view>
<view class="stats-bar card" v-if="listData.items.length > 0">
<view class="stat">
<text class="stat-val">{{ listData.total }}</text>
<text class="stat-lbl">复盘次数</text>
</view>
<view class="stat-sep"></view>
<view class="stat">
<text class="stat-val">{{ avgScore }}</text>
<text class="stat-lbl">平均分</text>
</view>
<view class="stat-sep"></view>
<view class="stat">
<text class="stat-val">{{ completedCount }}</text>
<text class="stat-lbl">已完成</text>
</view>
</view>
<view class="list" v-if="listData.items.length > 0">
<view
class="record-card card"
v-for="item in listData.items"
:key="item._id"
@click="viewDetail(item._id)"
>
<view class="record-top">
<view class="record-icon">
{{ item.status === 'completed' ? (item.analysis?.overallScore >= 80 ? '🌟' : '📋') : '⏳' }}
</view>
<view class="record-body">
<view class="record-name">{{ item.position }}</view>
<text class="record-meta">
{{ formatDate(item.createdAt) }}
<template v-if="item.company"> · {{ item.company }}</template>
<template v-if="item.status === 'processing'"> · 分析中...</template>
<template v-if="item.status === 'failed'"> · 分析失败</template>
</text>
</view>
<view class="record-score" v-if="item.status === 'completed'" :class="scoreLevel(item.analysis?.overallScore)">
{{ item.analysis?.overallScore || '--' }}
</view>
<view v-else class="record-score pending">{{ item.status === 'processing' ? '...' : '!' }}</view>
</view>
</view>
<view class="load-more" v-if="hasMore" @click="loadMore">加载更多</view>
</view>
<view class="empty" v-else-if="!loading">
<text class="empty-icon">🎙</text>
<text class="empty-title">暂无复盘记录</text>
<text class="empty-desc">面试后上传录音AI 帮你分析表现</text>
</view>
<view class="fixed-bottom">
<button class="btn-primary" @click="mode = 'upload'">
<text class="btn-icon">+</text> 上传录音复盘
</button>
</view>
</template>
<!-- ====== Mode 2: Upload View ====== -->
<template v-if="mode === 'upload'">
<view class="upload-page">
<view class="upload-header">
<text class="upload-back" @click="mode = 'list'"> 返回</text>
<text class="upload-title">上传面试录音</text>
<view style="width:60rpx"></view>
</view>
<view class="form-card card">
<view class="form-group">
<text class="form-label">面试岗位 <text class="required">*</text></text>
<input class="form-input" v-model="form.position" placeholder="例如:前端开发工程师" />
</view>
<view class="form-group">
<text class="form-label">面试公司</text>
<input class="form-input" v-model="form.company" placeholder="选填" />
</view>
<view class="form-group">
<text class="form-label">上传方式</text>
<view class="tab-bar">
<view class="tab-item" :class="{ active: uploadMode === 'audio' }" @click="uploadMode = 'audio'">录音文件</view>
<view class="tab-item" :class="{ active: uploadMode === 'text' }" @click="uploadMode = 'text'">粘贴文本</view>
</view>
</view>
<!-- Audio upload mode -->
<view v-if="uploadMode === 'audio'" class="audio-upload-area">
<view class="upload-box" @click="chooseFile">
<text class="upload-icon">📁</text>
<text class="upload-text" v-if="!form.file">点击选择录音文件</text>
<text class="upload-text" v-else>{{ form.file.name }}</text>
<text class="upload-hint">支持 mp3/m4a/wav最大 50MB</text>
</view>
</view>
<!-- Text paste mode -->
<view v-else class="text-upload-area">
<textarea
class="text-input"
v-model="form.text"
placeholder="将面试录音转写为文字后粘贴在这里...&#10;&#10;示例:&#10;面试官:请介绍一下你自己&#10;候选人:我毕业于..."
:maxlength="10000"
/>
<text class="char-count">{{ form.text.length }}/10000</text>
</view>
</view>
<view class="submit-area">
<button class="btn-primary" @click="submitReview" :disabled="submitting">
{{ submitting ? '提交中...' : '开始分析' }}
</button>
</view>
</view>
</template>
<!-- ====== Mode 3: Processing View ====== -->
<template v-if="mode === 'processing'">
<view class="processing-page">
<view class="processing-card">
<view class="spinner"></view>
<text class="processing-title">AI 分析中</text>
<text class="processing-desc">正在对面试录音进行深度分析请稍候...</text>
<view class="process-steps">
<view class="step" :class="{ done: processStep >= 1 }">
<text class="step-num">{{ processStep >= 1 ? '✓' : '1' }}</text>
<text class="step-label">文本转录</text>
</view>
<view class="step" :class="{ done: processStep >= 2 }">
<text class="step-num">{{ processStep >= 2 ? '✓' : '2' }}</text>
<text class="step-label">语音分析</text>
</view>
<view class="step" :class="{ done: processStep >= 3 }">
<text class="step-num">{{ processStep >= 3 ? '✓' : '3' }}</text>
<text class="step-label">AI 评估</text>
</view>
</view>
<text class="processing-hint">请勿离开此页面</text>
</view>
</view>
</template>
<!-- ====== Mode 4: Report View ====== -->
<template v-if="mode === 'report' && reportData">
<view class="report-page">
<view class="report-header">
<text class="report-back" @click="mode = 'list'"> 返回列表</text>
<text class="report-title">复盘报告</text>
<view style="width:60rpx"></view>
</view>
<view class="body">
<view class="score-card">
<view class="score-circle" :class="scoreLevel(reportData.analysis.overallScore)">
<text class="score-num">{{ reportData.analysis.overallScore }}</text>
<text class="score-label">总分</text>
</view>
</view>
<view class="info-row">
<text class="info-label">面试岗位</text>
<text class="info-value">{{ reportData.position }}</text>
</view>
<view class="info-row" v-if="reportData.company">
<text class="info-label">面试公司</text>
<text class="info-value">{{ reportData.company }}</text>
</view>
<view class="info-row">
<text class="info-label">分析时间</text>
<text class="info-value">{{ formatDate(reportData.createdAt) }}</text>
</view>
<view class="info-row" v-if="reportData.speechAnalysis">
<text class="info-label">回答总时长</text>
<text class="info-value">{{ reportData.speechAnalysis.totalDuration }}</text>
</view>
<!-- 四维能力评估 -->
<view class="section" v-if="reportData.analysis.dimensions">
<view class="section-title">四维能力评估</view>
<view class="dim-grid">
<view class="dim-item" v-for="dim in dimDefs" :key="dim.key">
<view class="dim-header">
<text class="dim-name">{{ dim.label }}</text>
<text class="dim-score">{{ getDimValue(dim.key) }}</text>
</view>
<view class="dim-bar-bg">
<view class="dim-bar-fill" :style="{ width: getDimValue(dim.key) + '%', background: dim.color }"></view>
</view>
</view>
</view>
</view>
<!-- 语音分析 -->
<view class="section" v-if="reportData.speechAnalysis">
<view class="section-title">语音表达分析</view>
<view class="speech-card">
<view class="speech-row">
<text class="speech-label">语气词评分</text>
<text class="speech-value" :class="scoreLevel(reportData.speechAnalysis.fillerScore)">
{{ reportData.speechAnalysis.fillerScore }}
</text>
</view>
<view class="speech-row">
<text class="speech-label">语气词密度</text>
<text class="speech-value">{{ reportData.speechAnalysis.fillerDensity }}%</text>
</view>
<view class="speech-row">
<text class="speech-label">语速</text>
<text class="speech-value">{{ reportData.speechAnalysis.pace }}</text>
</view>
<view class="filler-tags" v-if="reportData.speechAnalysis.fillerWords.length > 0">
<text class="filler-tag" v-for="fw in reportData.speechAnalysis.fillerWords" :key="fw.word">
"{{ fw.word }}" × {{ fw.count }}
</text>
</view>
</view>
</view>
<!-- 逐题分析 -->
<view class="section" v-if="reportData.analysis.questionBreakdown && reportData.analysis.questionBreakdown.length > 0">
<view class="section-title">逐题分析</view>
<view class="qa-list">
<view class="qa-item" v-for="(qa, idx) in reportData.analysis.questionBreakdown" :key="idx">
<view class="qa-header">
<text class="qa-num">Q{{ idx + 1 }}</text>
<text class="qa-score" :class="scoreLevel(qa.score)">{{ qa.score }}</text>
</view>
<text class="qa-question">{{ qa.question }}</text>
<text class="qa-answer-label">你的回答</text>
<text class="qa-answer">{{ qa.answer }}</text>
<view class="qa-comment" v-if="qa.comment">
<text class="qa-comment-icon">💡</text>
<text class="qa-comment-text">{{ qa.comment }}</text>
</view>
<view class="qa-suggest" v-if="qa.suggestedAnswer">
<text class="qa-suggest-icon">参考思路</text>
<text class="qa-suggest-text">{{ qa.suggestedAnswer }}</text>
</view>
</view>
</view>
</view>
<!-- 改进建议 -->
<view class="section" v-if="reportData.analysis.strengths.length > 0 || reportData.analysis.weaknesses.length > 0">
<view class="section-title">改进建议</view>
<view class="sugg-block" v-if="reportData.analysis.strengths.length > 0">
<text class="sugg-block-title sugg-good"> 表现亮点</text>
<text class="sugg-item" v-for="(s, i) in reportData.analysis.strengths" :key="'str-' + i">{{ s }}</text>
</view>
<view class="sugg-block" v-if="reportData.analysis.weaknesses.length > 0">
<text class="sugg-block-title sugg-warn"> 待改进</text>
<text class="sugg-item" v-for="(w, i) in reportData.analysis.weaknesses" :key="'weak-' + i">{{ w }}</text>
</view>
<view class="sugg-block" v-if="reportData.analysis.suggestions.length > 0">
<text class="sugg-block-title sugg-info">💡 具体建议</text>
<text class="sugg-item" v-for="(s, i) in reportData.analysis.suggestions" :key="'sug-' + i">{{ s }}</text>
</view>
</view>
<view class="actions">
<button class="btn-primary" @click="goInterview">再去模拟面试练练</button>
<button class="btn-outline" @click="mode = 'list'">返回列表</button>
</view>
</view>
</view>
</template>
</view>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config'
const mode = ref('list')
const loading = ref(false)
const submitting = ref(false)
const listData = ref({ items: [], total: 0, page: 1, limit: 20 })
const processStep = ref(0)
const reportData = ref(null)
const pollTimer = ref(null)
const reviewId = ref('')
const form = ref({ position: '', company: '', file: null, text: '' })
const uploadMode = ref('audio')
const dimDefs = [
{ key: 'logic', label: '逻辑思维', color: '#6366F1' },
{ key: 'expression', label: '表达能力', color: '#10B981' },
{ key: 'professionalism', label: '专业度', color: '#F59E0B' },
{ key: 'stability', label: '稳定性', color: '#EF4444' },
]
const avgScore = computed(() => {
const scored = listData.value.items.filter(i => i.status === 'completed' && i.analysis?.overallScore)
if (scored.length === 0) return '--'
return Math.round(scored.reduce((s, i) => s + (i.analysis?.overallScore || 0), 0) / scored.length)
})
const completedCount = computed(() => {
return listData.value.items.filter(i => i.status === 'completed').length
})
const hasMore = computed(() => {
return listData.value.page < Math.ceil(listData.value.total / listData.value.limit)
})
onMounted(() => { fetchList() })
onShow(() => {
if (mode.value === 'list') fetchList()
})
async function fetchList(page = 1) {
const token = uni.getStorageSync('token') || ''
if (!token) return
loading.value = true
try {
const res = await uni.request({
url: api(`/interview-review/list?page=${page}&limit=20`),
method: 'GET',
header: { 'Authorization': `Bearer ${token}` },
})
if (res.statusCode === 200) {
const data = res.data
if (page === 1) {
listData.value = data
} else {
listData.value = {
...data,
items: [...listData.value.items, ...data.items],
}
}
}
} catch(e) { console.error(e) }
finally { loading.value = false }
}
function loadMore() {
const next = listData.value.page + 1
fetchList(next)
listData.value.page = next
}
function chooseFile() {
uni.chooseMessageFile ? uni.chooseMessageFile({
count: 1,
type: 'file',
extension: ['mp3', 'm4a', 'wav', 'aac', 'ogg'],
success: (r) => {
if (r.tempFiles && r.tempFiles[0]) {
form.value.file = r.tempFiles[0]
}
},
}) : uni.showToast({ title: '当前平台不支持文件选择', icon: 'none' })
}
async function submitReview() {
if (!form.value.position.trim()) {
uni.showToast({ title: '请填写面试岗位', icon: 'none' })
return
}
if (uploadMode.value === 'audio' && !form.value.file) {
uni.showToast({ title: '请选择录音文件', icon: 'none' })
return
}
if (uploadMode.value === 'text' && !form.value.text.trim()) {
uni.showToast({ title: '请粘贴面试转录文本', icon: 'none' })
return
}
submitting.value = true
const token = uni.getStorageSync('token') || ''
try {
if (uploadMode.value === 'audio') {
const res = await uni.uploadFile({
url: api('/interview-review'),
filePath: form.value.file.path || form.value.file.tempFilePath,
name: 'file',
formData: {
position: form.value.position.trim(),
company: form.value.company.trim(),
},
header: { 'Authorization': `Bearer ${token}` },
})
if (res.statusCode === 201 || res.statusCode === 200) {
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
reviewId.value = data.id
startPolling(data.id)
mode.value = 'processing'
animateSteps()
} else {
const err = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
uni.showToast({ title: err.message || '上传失败', icon: 'none' })
}
} else {
// Text submission
const res = await uni.request({
url: api('/interview-review/text'),
method: 'POST',
data: {
position: form.value.position.trim(),
company: form.value.company.trim(),
text: form.value.text.trim(),
},
header: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
if (res.statusCode === 201 || res.statusCode === 200) {
reviewId.value = res.data.id
startPolling(res.data.id)
mode.value = 'processing'
animateSteps()
} else {
uni.showToast({ title: res.data?.message || '提交失败', icon: 'none' })
}
}
} catch(e) {
uni.showToast({ title: e.message || '网络错误', icon: 'none' })
}
finally { submitting.value = false }
}
function animateSteps() {
processStep.value = 1
setTimeout(() => { processStep.value = 2 }, 3000)
setTimeout(() => { processStep.value = 3 }, 6000)
}
function startPolling(id) {
let attempts = 0
const maxAttempts = 60 // 5 minutes max
pollTimer.value = setInterval(async () => {
attempts++
if (attempts > maxAttempts) {
clearInterval(pollTimer.value)
uni.showToast({ title: '分析超时,请稍后再查', icon: 'none' })
mode.value = 'list'
return
}
try {
const token = uni.getStorageSync('token') || ''
const res = await uni.request({
url: api(`/interview-review/${id}`),
method: 'GET',
header: { 'Authorization': `Bearer ${token}` },
})
if (res.statusCode === 200) {
const data = res.data
if (data.status === 'completed') {
clearInterval(pollTimer.value)
reportData.value = data
mode.value = 'report'
} else if (data.status === 'failed') {
clearInterval(pollTimer.value)
uni.showToast({ title: '分析失败,请重新上传', icon: 'none' })
mode.value = 'list'
}
// status === 'processing': continue polling
}
} catch(e) { console.error(e) }
}, 5000)
}
function viewDetail(id) {
const token = uni.getStorageSync('token') || ''
uni.request({
url: api(`/interview-review/${id}`),
method: 'GET',
header: { 'Authorization': `Bearer ${token}` },
success: (res) => {
if (res.statusCode === 200) {
if (res.data.status === 'completed') {
reportData.value = res.data
mode.value = 'report'
} else if (res.data.status === 'processing') {
reviewId.value = id
startPolling(id)
mode.value = 'processing'
} else {
uni.showToast({ title: '分析失败', icon: 'none' })
}
}
},
fail: () => { uni.showToast({ title: '加载失败', icon: 'none' }) },
})
}
function getDimValue(key) {
return Math.min(100, Math.max(0, Math.round(reportData.value?.analysis?.dimensions?.[key] || 0)))
}
function formatDate(d) {
if (!d) return '--'
const date = new Date(d)
return `${String(date.getMonth()+1).padStart(2,'0')}-${String(date.getDate()).padStart(2,'0')} ${String(date.getHours()).padStart(2,'0')}:${String(date.getMinutes()).padStart(2,'0')}`
}
const scoreLevel = (s) => {
if (!s && s !== 0) return 'pending'
if (s >= 80) return 'good'
if (s >= 60) return 'medium'
return 'poor'
}
function goInterview() {
uni.switchTab({ url: '/pages/index/index' })
}
onUnmounted(() => {
if (pollTimer.value) clearInterval(pollTimer.value)
})
</script>
<style scoped>
.page { background: #F3F4F6; min-height: 100vh; }
.hero {
background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #6366F1 100%);
padding: 48rpx 32rpx 72rpx; border-radius: 0 0 48rpx 48rpx;
}
.hero-title { font-size: 40rpx; font-weight: 700; color: #FFF; display: block; }
.hero-sub { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 8rpx; display: block; }
.stats-bar { display: flex; align-items: center; padding: 24rpx; margin: -40rpx 32rpx 0; position: relative; z-index: 1; border-radius: 16rpx; background: #FFF; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6rpx; }
.stat-val { font-size: 36rpx; font-weight: 700; color: #4F46E5; }
.stat-lbl { font-size: 20rpx; color: #9CA3AF; }
.stat-sep { width: 1rpx; height: 40rpx; background: #E5E7EB; }
.list { padding: 20rpx 32rpx 160rpx; }
.record-card { background: #FFF; padding: 24rpx 28rpx; margin-bottom: 16rpx; border-radius: 16rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04); }
.record-top { display: flex; align-items: center; gap: 16rpx; }
.record-icon { font-size: 40rpx; width: 64rpx; height: 64rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.record-body { flex: 1; min-width: 0; }
.record-name { font-size: 28rpx; font-weight: 600; color: #111827; }
.record-meta { font-size: 20rpx; color: #9CA3AF; margin-top: 6rpx; display: block; }
.record-score { font-size: 28rpx; font-weight: 700; width: 72rpx; text-align: right; flex-shrink: 0; }
.record-score.good { color: #059669; }
.record-score.medium { color: #D97706; }
.record-score.poor { color: #DC2626; }
.record-score.pending { color: #9CA3AF; }
.empty { display: flex; flex-direction: column; align-items: center; padding: 120rpx 32rpx 200rpx; }
.empty-icon { font-size: 80rpx; margin-bottom: 20rpx; }
.empty-title { font-size: 28rpx; font-weight: 600; color: #111827; }
.empty-desc { font-size: 22rpx; color: #9CA3AF; margin-top: 8rpx; margin-bottom: 36rpx; }
.fixed-bottom { position: fixed; bottom: 0; left: 0; right: 0; padding: 20rpx 32rpx 40rpx; background: linear-gradient(transparent, #F3F4F6 30rpx); }
.btn-primary { background: linear-gradient(135deg, #4F46E5, #7C3AED); color: #FFF; border-radius: 16rpx; height: 88rpx; line-height: 88rpx; font-size: 28rpx; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8rpx; }
.btn-primary:active { opacity: 0.85; }
.btn-icon { font-size: 36rpx; font-weight: 400; }
/* Upload Page */
.upload-page { background: #F3F4F6; min-height: 100vh; }
.upload-header { display: flex; align-items: center; justify-content: space-between; padding: 24rpx 32rpx; background: #FFF; }
.upload-back { font-size: 28rpx; color: #4F46E5; }
.upload-title { font-size: 32rpx; font-weight: 600; color: #111827; }
.form-card { background: #FFF; border-radius: 16rpx; margin: 24rpx 32rpx; padding: 32rpx; }
.form-group { margin-bottom: 28rpx; }
.form-label { font-size: 26rpx; font-weight: 600; color: #374151; display: block; margin-bottom: 12rpx; }
.required { color: #DC2626; }
.form-input { width: 100%; height: 72rpx; border: 2rpx solid #E5E7EB; border-radius: 12rpx; padding: 0 20rpx; font-size: 26rpx; box-sizing: border-box; }
.tab-bar { display: flex; gap: 0; background: #F3F4F6; border-radius: 12rpx; overflow: hidden; }
.tab-item { flex: 1; text-align: center; padding: 18rpx 0; font-size: 24rpx; color: #6B7280; }
.tab-item.active { background: #4F46E5; color: #FFF; font-weight: 600; }
.audio-upload-area { margin-top: 8rpx; }
.upload-box { border: 2rpx dashed #D1D5DB; border-radius: 16rpx; padding: 48rpx 32rpx; display: flex; flex-direction: column; align-items: center; gap: 12rpx; }
.upload-icon { font-size: 60rpx; }
.upload-text { font-size: 26rpx; color: #374151; }
.upload-hint { font-size: 20rpx; color: #9CA3AF; }
.text-upload-area { margin-top: 8rpx; }
.text-input { width: 100%; height: 360rpx; border: 2rpx solid #E5E7EB; border-radius: 12rpx; padding: 20rpx; font-size: 24rpx; line-height: 1.6; box-sizing: border-box; }
.char-count { font-size: 20rpx; color: #9CA3AF; text-align: right; display: block; margin-top: 8rpx; }
.submit-area { padding: 0 32rpx 48rpx; }
/* Processing Page */
.processing-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 32rpx; }
.processing-card { background: #FFF; border-radius: 24rpx; padding: 64rpx 48rpx; text-align: center; box-shadow: 0 8rpx 40rpx rgba(0,0,0,0.08); width: 100%; max-width: 500rpx; }
.spinner { width: 80rpx; height: 80rpx; border: 6rpx solid #E5E7EB; border-top-color: #4F46E5; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 32rpx; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing-title { font-size: 32rpx; font-weight: 700; color: #111827; margin-bottom: 12rpx; }
.processing-desc { font-size: 24rpx; color: #6B7280; margin-bottom: 40rpx; }
.process-steps { display: flex; gap: 16rpx; justify-content: center; margin-bottom: 24rpx; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8rpx; }
.step-num { width: 48rpx; height: 48rpx; border-radius: 50%; background: #F3F4F6; color: #9CA3AF; font-size: 22rpx; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.step.done .step-num { background: #4F46E5; color: #FFF; }
.step-label { font-size: 20rpx; color: #9CA3AF; }
.step.done .step-label { color: #4F46E5; }
.processing-hint { font-size: 20rpx; color: #D1D5DB; }
/* Report Page */
.report-page { background: #F3F4F6; min-height: 100vh; }
.report-header { display: flex; align-items: center; justify-content: space-between; padding: 24rpx 32rpx; background: #FFF; }
.report-back { font-size: 28rpx; color: #4F46E5; }
.report-title { font-size: 32rpx; font-weight: 600; color: #111827; }
.body { padding: 0 32rpx 48rpx; }
.score-card { display: flex; justify-content: center; margin: -20rpx 0 30rpx; }
.score-circle {
width: 180rpx; height: 180rpx; border-radius: 50%;
background: #FFF; display: flex; flex-direction: column;
align-items: center; justify-content: center;
box-shadow: 0 8rpx 30rpx rgba(79,70,229,0.2);
}
.score-circle.good { box-shadow: 0 8rpx 30rpx rgba(5,150,105,0.2); }
.score-circle.medium { box-shadow: 0 8rpx 30rpx rgba(217,119,6,0.2); }
.score-circle.poor { box-shadow: 0 8rpx 30rpx rgba(220,38,38,0.2); }
.score-num { font-size: 56rpx; font-weight: 700; color: #4F46E5; line-height: 1.2; }
.good .score-num { color: #059669; }
.medium .score-num { color: #D97706; }
.poor .score-num { color: #DC2626; }
.score-label { font-size: 20rpx; color: #9CA3AF; margin-top: 4rpx; }
.info-row { display: flex; justify-content: space-between; padding: 20rpx 0; border-bottom: 1rpx solid #E5E7EB; font-size: 24rpx; }
.info-label { color: #6B7280; }
.info-value { color: #111827; font-weight: 500; }
.section { background: #FFF; border-radius: 20rpx; padding: 28rpx; margin-top: 24rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04); }
.section-title { font-size: 28rpx; font-weight: 600; color: #111827; margin-bottom: 16rpx; }
.dim-grid { display: flex; flex-direction: column; gap: 20rpx; }
.dim-header { display: flex; justify-content: space-between; margin-bottom: 8rpx; }
.dim-name { font-size: 24rpx; color: #374151; }
.dim-score { font-size: 24rpx; color: #4F46E5; font-weight: 600; }
.dim-bar-bg { height: 20rpx; background: #F3F4F6; border-radius: 10rpx; overflow: hidden; }
.dim-bar-fill { height: 100%; border-radius: 10rpx; }
.speech-card { display: flex; flex-direction: column; gap: 16rpx; }
.speech-row { display: flex; justify-content: space-between; align-items: center; }
.speech-label { font-size: 24rpx; color: #374151; }
.speech-value { font-size: 24rpx; font-weight: 600; color: #111827; }
.speech-value.good { color: #059669; }
.speech-value.medium { color: #D97706; }
.speech-value.poor { color: #DC2626; }
.filler-tags { display: flex; flex-wrap: wrap; gap: 8rpx; }
.filler-tag { background: #FEF3C7; color: #92400E; padding: 6rpx 16rpx; border-radius: 20rpx; font-size: 20rpx; }
.qa-list { display: flex; flex-direction: column; gap: 24rpx; }
.qa-item { padding: 20rpx; background: #F9FAFB; border-radius: 12rpx; }
.qa-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
.qa-num { font-size: 22rpx; font-weight: 700; color: #4F46E5; background: #EEF2FF; padding: 4rpx 14rpx; border-radius: 8rpx; }
.qa-score { font-size: 24rpx; font-weight: 700; }
.qa-score.good { color: #059669; }
.qa-score.medium { color: #D97706; }
.qa-score.poor { color: #DC2626; }
.qa-score.pending { color: #9CA3AF; }
.qa-question { font-size: 24rpx; font-weight: 600; color: #111827; margin-bottom: 8rpx; display: block; }
.qa-answer-label { font-size: 20rpx; color: #6B7280; display: block; margin-top: 8rpx; }
.qa-answer { font-size: 22rpx; color: #374151; line-height: 1.6; display: block; margin-top: 4rpx; white-space: pre-wrap; }
.qa-comment { background: #EEF2FF; padding: 12rpx; border-radius: 8rpx; margin-top: 12rpx; display: flex; gap: 8rpx; }
.qa-comment-icon { font-size: 22rpx; }
.qa-comment-text { font-size: 22rpx; color: #4338CA; line-height: 1.5; }
.qa-suggest { background: #FEF3C7; padding: 12rpx; border-radius: 8rpx; margin-top: 8rpx; }
.qa-suggest-icon { font-size: 22rpx; font-weight: 600; color: #92400E; }
.qa-suggest-text { font-size: 22rpx; color: #78350F; line-height: 1.5; }
.sugg-block { margin-bottom: 20rpx; }
.sugg-block-title { font-size: 24rpx; font-weight: 600; display: block; margin-bottom: 8rpx; }
.sugg-good { color: #059669; }
.sugg-warn { color: #D97706; }
.sugg-info { color: #4F46E5; }
.sugg-item { display: block; font-size: 22rpx; color: #374151; line-height: 1.8; padding-left: 20rpx; }
.sugg-item::before { content: '• '; color: #D1D5DB; }
.actions { display: flex; flex-direction: column; gap: 16rpx; margin-top: 32rpx; }
.btn-outline { background: #FFF; color: #4F46E5; border-radius: 16rpx; height: 88rpx; line-height: 88rpx; font-size: 28rpx; border: 2rpx solid #4F46E5; }
.btn-outline:active { background: #F5F3FF; }
.load-more { text-align: center; padding: 24rpx; color: #4F46E5; font-size: 24rpx; }
</style>
+275
View File
@@ -0,0 +1,275 @@
<template>
<view class="page fade-in">
<!-- 统计卡片 -->
<view class="stats-card">
<view class="stat-row">
<view class="stat-item">
<text class="stat-value">{{ stats.shareCredits || 0 }}</text>
<text class="stat-label">📦 我的积分</text>
</view>
</view>
<view class="stat-sub-row">
<view class="stat-sub-item">
<text class="stat-sub-value">{{ stats.totalVisits || 0 }}</text>
<text class="stat-sub-label">总点击</text>
</view>
<view class="stat-arrow"></view>
<view class="stat-sub-item">
<text class="stat-sub-value">{{ stats.creditedCount || 0 }}</text>
<text class="stat-sub-label">有效注册</text>
</view>
<view class="stat-arrow"></view>
<view class="stat-sub-item">
<text class="stat-sub-value">{{ stats.shareCredits || 0 }}</text>
<text class="stat-sub-label">获得积分</text>
</view>
</view>
<view class="hint">
💡 好友通过你的链接打开并 <text class="hint-em">登录/注册</text> 才算有效每次有效得 1 积分
</view>
</view>
<!-- 今日数据 -->
<view class="today-card">
<text class="today-title">今日数据</text>
<view class="today-row">
<view class="today-item">
<text class="today-value">{{ todayStats.visits }}</text>
<text class="today-label">点击</text>
</view>
<view class="today-item">
<text class="today-value">{{ todayStats.credited }}</text>
<text class="today-label">有效</text>
</view>
<view class="today-item">
<text class="today-value">{{ 3 - todayStats.credited > 0 ? 3 - todayStats.credited : 0 }}</text>
<text class="today-label">今日剩余</text>
</view>
</view>
<view class="today-bar">
<view class="today-bar-fill" :style="{ width: Math.min(100, (todayStats.credited / 3) * 100) + '%' }"></view>
</view>
<text class="today-hint">每日最多 3 次有效积分</text>
</view>
<!-- 分享按钮 -->
<view class="share-actions">
<button class="share-btn wx-share" @click="shareToWechat" v-if="isWechat">
<text class="btn-icon">💬</text>
<text>分享给微信好友</text>
</button>
<button class="share-btn link-share" @click="copyLink">
<text class="btn-icon">🔗</text>
<text>复制分享链接</text>
</button>
</view>
<!-- Tab 切换 -->
<view class="tab-bar">
<view class="tab-item" :class="{ active: tab === 'records' }" @click="tab = 'records'">分享记录</view>
<view class="tab-item" :class="{ active: tab === 'visitors' }" @click="tab = 'visitors'">访问明细</view>
</view>
<!-- 分享记录 -->
<view class="list" v-if="tab === 'records'">
<view class="list-item" v-for="item in records" :key="item.shareCode">
<view class="item-main">
<text class="item-type">{{ typeLabel(item.type) }}</text>
<text class="item-title">{{ item.title }}</text>
</view>
<view class="item-stats">
<text class="item-stat">👀 {{ item.visitCount }}点击</text>
<text class="item-stat active"> {{ item.creditedCount }}有效</text>
</view>
<text class="item-time">{{ formatTime(item.createdAt) }}</text>
</view>
<view class="empty" v-if="records.length === 0">
<text class="empty-icon">📤</text>
<text class="empty-text">还没有分享记录</text>
<text class="empty-hint">点击上方按钮分享给好友吧</text>
</view>
</view>
<!-- 访问明细 -->
<view class="list" v-if="tab === 'visitors'">
<view class="list-item" v-for="(item, idx) in visitors" :key="idx">
<image class="visitor-avatar" :src="item.avatar || '/static/avatar-default.svg'" />
<view class="item-main">
<text class="item-title">{{ item.nickname || '👤 未登录访客' }}</text>
<text class="item-time">{{ formatTime(item.createdAt) }}</text>
</view>
<view class="badge" :class="item.credited ? 'badge-done' : 'badge-pending'">
{{ item.credited ? '✅ 已积分' : '⏳ 未注册' }}
</view>
</view>
<view class="empty" v-if="visitors.length === 0">
<text class="empty-icon">👀</text>
<text class="empty-text">还没有访问记录</text>
<text class="empty-hint">分享后好友访问就会出现在这里</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { api } from '../../config'
const tab = ref('records')
const stats = ref({ totalShares: 0, totalVisits: 0, creditedCount: 0, todayCredited: 0, shareCredits: 0 })
const records = ref([])
const visitors = ref([])
const todayStats = computed(() => ({
visits: stats.value.todayCredited + Math.round(Math.random() * 0),
credited: stats.value.todayCredited || 0,
}))
const isWechat = ref(false)
onMounted(() => {
// #ifdef H5
isWechat.value = navigator?.userAgent?.toLowerCase().includes('micromessenger') || false
// #endif
loadData()
})
async function loadData() {
const token = uni.getStorageSync('token')
if (!token) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
const header = { Authorization: `Bearer ${token}` }
try {
const [statsRes, recordsRes, visitorsRes] = await Promise.all([
uni.request({ url: api('/share/stats'), method: 'GET', header }),
uni.request({ url: api('/share/records'), method: 'GET', header }),
uni.request({ url: api('/share/visitors'), method: 'GET', header }),
])
if (statsRes.statusCode === 200) stats.value = statsRes.data
if (recordsRes.statusCode === 200) records.value = recordsRes.data.list || []
if (visitorsRes.statusCode === 200) visitors.value = visitorsRes.data.list || []
} catch (e) { console.error(e) }
}
async function shareToWechat() {
const token = uni.getStorageSync('token')
if (!token) return
try {
const res = await uni.request({
url: api('/share/create'),
method: 'POST',
data: { type: 'app', title: '我在AI磁场·职引练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
header: { Authorization: `Bearer ${token}` },
})
if (res.statusCode !== 200) return
const data = res.data
const path = data.wechatShareInfo?.path || `/pages/share/share?code=${data.shareCode}`
uni.shareAppMessage({
provider: 'weixin',
title: data.wechatShareInfo?.title || 'AI磁场·职引',
description: data.wechatShareInfo?.description || '',
path,
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
success: () => { uni.showToast({ title: '分享成功', icon: 'success' }); loadData() },
fail: () => { uni.showToast({ title: '分享取消', icon: 'none' }) },
})
} catch (e) { console.error(e) }
}
async function copyLink() {
const token = uni.getStorageSync('token')
if (!token) return
try {
const res = await uni.request({
url: api('/share/create'),
method: 'POST',
data: { type: 'app', title: '我在AI磁场·职引练习面试', description: 'AI模拟面试+简历优化,快来一起提升吧' },
header: { Authorization: `Bearer ${token}` },
})
if (res.statusCode !== 200) return
const shareUrl = `https://zhiyinwx.yzrcloud.cn/share/${res.data.shareCode}`
uni.setClipboardData({ data: shareUrl, success: () => { uni.showToast({ title: '链接已复制' }); loadData() } })
} catch (e) { console.error(e) }
}
function typeLabel(type) {
const map = { app: '应用', interview: '面试', resume: '简历' }
return map[type] || type
}
function formatTime(t) {
if (!t) return ''
const d = new Date(t)
return `${d.getMonth() + 1}/${d.getDate()} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
}
</script>
<style scoped>
.page { min-height: 100vh; background: var(--color-bg); padding-bottom: 48rpx; }
/* Stats card */
.stats-card { background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%); margin: 24rpx 32rpx; border-radius: var(--radius-lg); padding: 32rpx; }
.stat-row { display: flex; justify-content: center; margin-bottom: 20rpx; }
.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-value { font-size: 56rpx; font-weight: 800; color: #FFFFFF; }
.stat-label { font-size: 22rpx; color: rgba(255,255,255,0.75); margin-top: 6rpx; }
.stat-sub-row { display: flex; align-items: center; justify-content: center; gap: 12rpx; padding: 16rpx 0; border-top: 1rpx solid rgba(255,255,255,0.15); border-bottom: 1rpx solid rgba(255,255,255,0.15); margin-bottom: 16rpx; }
.stat-sub-item { display: flex; flex-direction: column; align-items: center; }
.stat-sub-value { font-size: 32rpx; font-weight: 700; color: #FFFFFF; }
.stat-sub-label { font-size: 18rpx; color: rgba(255,255,255,0.6); margin-top: 4rpx; }
.stat-arrow { font-size: 24rpx; color: rgba(255,255,255,0.4); }
.hint { font-size: 20rpx; color: rgba(255,255,255,0.7); text-align: center; line-height: 1.6; }
.hint-em { color: #FCD34D; font-weight: 600; }
/* Today card */
.today-card { background: #FFFFFF; margin: 0 32rpx 24rpx; border-radius: var(--radius-md); padding: 24rpx; box-shadow: var(--shadow-sm); }
.today-title { font-size: 24rpx; font-weight: 600; color: var(--color-text); margin-bottom: 16rpx; }
.today-row { display: flex; gap: 24rpx; margin-bottom: 16rpx; }
.today-item { flex: 1; display: flex; flex-direction: column; align-items: center; }
.today-value { font-size: 36rpx; font-weight: 700; color: var(--color-primary); }
.today-label { font-size: 20rpx; color: var(--color-text-tertiary); margin-top: 4rpx; }
.today-bar { height: 8rpx; background: #F3F4F6; border-radius: 4rpx; overflow: hidden; margin-bottom: 8rpx; }
.today-bar-fill { height: 100%; background: linear-gradient(90deg, #4F46E5, #7C3AED); border-radius: 4rpx; transition: width 0.3s; }
.today-hint { font-size: 18rpx; color: var(--color-text-tertiary); text-align: center; }
/* Share buttons */
.share-actions { padding: 0 32rpx; display: flex; gap: 20rpx; }
.share-btn { flex: 1; display: flex; align-items: center; justify-content: center; height: 88rpx; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 500; border: none; }
.share-btn:active { transform: scale(0.96); }
.btn-icon { margin-right: 8rpx; font-size: 28rpx; }
.wx-share { background: #07C160; color: #FFFFFF; }
.link-share { background: #FFFFFF; color: var(--color-text); border: 2rpx solid var(--color-border); }
/* Tabs */
.tab-bar { display: flex; margin: 32rpx 32rpx 0; border-bottom: 2rpx solid var(--color-border); }
.tab-item { flex: 1; text-align: center; padding: 20rpx 0; font-size: 28rpx; color: #9CA3AF; font-weight: 500; position: relative; }
.tab-item.active { color: var(--color-primary); }
.tab-item.active::after { content: ''; position: absolute; bottom: -2rpx; left: 30%; right: 30%; height: 4rpx; background: var(--color-primary); border-radius: 2rpx; }
/* List */
.list { padding: 0 32rpx; }
.list-item { background: #FFFFFF; border-radius: var(--radius-md); padding: 24rpx 28rpx; margin-top: 16rpx; display: flex; align-items: center; box-shadow: var(--shadow-sm); }
.item-main { flex: 1; display: flex; flex-direction: column; }
.item-type { font-size: 20rpx; color: var(--color-primary); background: #EEF2FF; padding: 2rpx 12rpx; border-radius: 6rpx; align-self: flex-start; margin-bottom: 4rpx; }
.item-title { font-size: 26rpx; color: var(--color-text); font-weight: 500; }
.item-stats { display: flex; flex-direction: column; align-items: flex-end; margin-left: 12rpx; }
.item-stat { font-size: 22rpx; color: #9CA3AF; white-space: nowrap; }
.item-stat.active { color: var(--color-primary); }
.item-time { font-size: 20rpx; color: #D1D5DB; white-space: nowrap; margin-left: 12rpx; }
.visitor-avatar { width: 56rpx; height: 56rpx; border-radius: 50%; margin-right: 16rpx; flex-shrink: 0; }
.badge { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: 8rpx; white-space: nowrap; }
.badge-done { background: #ECFDF5; color: #059669; }
.badge-pending { background: #FEF3C7; color: #D97706; }
/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; padding: 80rpx 0; }
.empty-icon { font-size: 64rpx; margin-bottom: 16rpx; }
.empty-text { font-size: 28rpx; color: #9CA3AF; }
.empty-hint { font-size: 24rpx; color: #D1D5DB; margin-top: 8rpx; }
</style>
+46 -5
View File
@@ -3,9 +3,10 @@
<!-- 个人中心 --> <!-- 个人中心 -->
<view class="header" v-if="isLoggedIn"> <view class="header" v-if="isLoggedIn">
<view class="profile-section"> <view class="profile-section">
<image class="avatar" :src="userInfo.avatar || '/static/avatar-default.svg'" mode="aspectFill" /> <image class="avatar" :src="userInfo.avatar || '/static/avatar-default.png'" mode="aspectFill" />
<view class="profile-info"> <view class="profile-info">
<text class="nickname">{{ userInfo.nickname || '未设置昵称' }}</text> <text class="nickname">{{ userInfo.nickname || '未设置昵称' }}</text>
<text class="user-id">ID: {{ maskedId }}</text>
<view class="plan-badge">{{ userInfo.plan || '免费版' }}</view> <view class="plan-badge">{{ userInfo.plan || '免费版' }}</view>
</view> </view>
<text class="header-arrow"></text> <text class="header-arrow"></text>
@@ -33,7 +34,6 @@
<view class="guest-avatar"><text class="guest-icon">👤</text></view> <view class="guest-avatar"><text class="guest-icon">👤</text></view>
<view class="guest-info"> <view class="guest-info">
<text class="guest-name">未登录 / 点击登录</text> <text class="guest-name">未登录 / 点击登录</text>
<text class="guest-hint">登录后体验全部功能</text>
</view> </view>
<text class="header-arrow"></text> <text class="header-arrow"></text>
</view> </view>
@@ -42,11 +42,22 @@
<!-- 菜单列表 --> <!-- 菜单列表 -->
<view class="menu-area"> <view class="menu-area">
<view class="menu-group"> <view class="menu-group">
<view class="menu-item" @click="requireLogin(goCareer, '择业顾问')">
<view class="menu-icon-wrap wrap-teal"><text class="menu-icon">🧭</text></view>
<text class="menu-text">择业顾问</text>
<text class="menu-tag">NEW</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @click="requireLogin(goHistory, '面试记录')"> <view class="menu-item" @click="requireLogin(goHistory, '面试记录')">
<view class="menu-icon-wrap wrap-blue"><text class="menu-icon">📋</text></view> <view class="menu-icon-wrap wrap-blue"><text class="menu-icon">📋</text></view>
<text class="menu-text">面试记录</text> <text class="menu-text">面试记录</text>
<text class="menu-arrow"></text> <text class="menu-arrow"></text>
</view> </view>
<view class="menu-item" @click="requireLogin(goReviewReview, '面试复盘')">
<view class="menu-icon-wrap wrap-orange"><text class="menu-icon">🎙</text></view>
<text class="menu-text">面试复盘</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @click="goVip"> <view class="menu-item" @click="goVip">
<view class="menu-icon-wrap wrap-purple"><text class="menu-icon">💎</text></view> <view class="menu-icon-wrap wrap-purple"><text class="menu-icon">💎</text></view>
<text class="menu-text">会员中心</text> <text class="menu-text">会员中心</text>
@@ -57,6 +68,11 @@
<text class="menu-text">我的简历</text> <text class="menu-text">我的简历</text>
<text class="menu-arrow"></text> <text class="menu-arrow"></text>
</view> </view>
<view class="menu-item" @click="requireLogin(goShare, '我的分享')">
<view class="menu-icon-wrap wrap-orange"><text class="menu-icon">📤</text></view>
<text class="menu-text">我的分享</text>
<text class="menu-arrow"></text>
</view>
</view> </view>
<view class="menu-group"> <view class="menu-group">
<view class="menu-item" @click="goAbout"> <view class="menu-item" @click="goAbout">
@@ -79,6 +95,7 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config' import { api } from '../../config'
const userInfo = ref({}) const userInfo = ref({})
@@ -87,14 +104,32 @@ const stats = ref({ interviewCount: 0, avgScore: '--', completedCount: 0 })
const token = ref('') const token = ref('')
const isLoggedIn = computed(() => !!token.value) const isLoggedIn = computed(() => !!token.value)
const maskedId = computed(() => {
const id = userInfo.value.id || ''
return id.length > 6 ? `****${id.slice(-6)}` : id || '--'
})
onMounted(() => { const refreshState = () => {
token.value = uni.getStorageSync('token') || '' token.value = uni.getStorageSync('token') || ''
if (!token.value) return if (!token.value) return
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch(e) {} try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch(e) {}
loadStats() loadStats()
checkAdmin() checkAdmin()
}) fetchUserInfo()
}
const fetchUserInfo = async () => {
try {
const res = await uni.request({ url: api('/user/info'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
if (res.statusCode === 200 && res.data) {
userInfo.value = res.data
uni.setStorageSync('userInfo', JSON.stringify(res.data))
}
} catch(e) { /* silent */ }
}
onMounted(refreshState)
onShow(refreshState)
const loadStats = async () => { const loadStats = async () => {
try { try {
@@ -118,9 +153,12 @@ const checkAdmin = () => {
} }
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' }) const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
const goCareer = () => uni.navigateTo({ url: '/pages/career/career' })
const goHistory = () => uni.switchTab({ url: '/pages/history/history' }) const goHistory = () => uni.switchTab({ url: '/pages/history/history' })
const goReviewReview = () => uni.navigateTo({ url: '/pages/review/review' })
const goVip = () => uni.navigateTo({ url: '/pages/member/member' }) const goVip = () => uni.navigateTo({ url: '/pages/member/member' })
const goResume = () => uni.navigateTo({ url: '/pages/resume/resume' }) const goResume = () => uni.navigateTo({ url: '/pages/resume/resume' })
const goShare = () => uni.navigateTo({ url: '/pages/share/share' })
const goAdmin = () => uni.navigateTo({ url: '/pages/admin/admin' }) const goAdmin = () => uni.navigateTo({ url: '/pages/admin/admin' })
const goAbout = () => uni.navigateTo({ url: '/pages/about/about' }) const goAbout = () => uni.navigateTo({ url: '/pages/about/about' })
@@ -144,6 +182,7 @@ const doLogout = () => {
.profile-info { flex: 1; display: flex; flex-direction: column; } .profile-info { flex: 1; display: flex; flex-direction: column; }
.nickname { font-size: 34rpx; font-weight: 700; color: #FFFFFF; } .nickname { font-size: 34rpx; font-weight: 700; color: #FFFFFF; }
.plan-badge { font-size: 20rpx; color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.2); padding: 4rpx 14rpx; border-radius: 8rpx; align-self: flex-start; margin-top: 8rpx; } .plan-badge { font-size: 20rpx; color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.2); padding: 4rpx 14rpx; border-radius: 8rpx; align-self: flex-start; margin-top: 8rpx; }
.user-id { font-size: 20rpx; color: rgba(255,255,255,0.5); margin-top: 4rpx; }
.header-arrow { font-size: 36rpx; color: rgba(255,255,255,0.5); } .header-arrow { font-size: 36rpx; color: rgba(255,255,255,0.5); }
.stats-bar { display: flex; align-items: center; background: rgba(255,255,255,0.15); border-radius: var(--radius-lg); padding: 24rpx 0; } .stats-bar { display: flex; align-items: center; background: rgba(255,255,255,0.15); border-radius: var(--radius-lg); padding: 24rpx 0; }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; } .stat { flex: 1; display: flex; flex-direction: column; align-items: center; }
@@ -157,7 +196,6 @@ const doLogout = () => {
.guest-icon { font-size: 40rpx; } .guest-icon { font-size: 40rpx; }
.guest-info { flex: 1; } .guest-info { flex: 1; }
.guest-name { font-size: 30rpx; font-weight: 600; color: #FFFFFF; } .guest-name { font-size: 30rpx; font-weight: 600; color: #FFFFFF; }
.guest-hint { font-size: 22rpx; color: rgba(255,255,255,0.7); margin-top: 4rpx; }
.menu-area { padding: 0 32rpx 32rpx; margin-top: -40rpx; } .menu-area { padding: 0 32rpx 32rpx; margin-top: -40rpx; }
.menu-group { background: #FFFFFF; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24rpx; box-shadow: var(--shadow-sm); } .menu-group { background: #FFFFFF; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24rpx; box-shadow: var(--shadow-sm); }
@@ -167,11 +205,14 @@ const doLogout = () => {
.menu-icon-wrap { width: 60rpx; height: 60rpx; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-right: 20rpx; flex-shrink: 0; } .menu-icon-wrap { width: 60rpx; height: 60rpx; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-right: 20rpx; flex-shrink: 0; }
.menu-icon { font-size: 28rpx; } .menu-icon { font-size: 28rpx; }
.menu-text { flex: 1; font-size: 28rpx; color: var(--color-text); font-weight: 500; } .menu-text { flex: 1; font-size: 28rpx; color: var(--color-text); font-weight: 500; }
.menu-tag { font-size: 18rpx; color: #fff; background: var(--color-primary); padding: 2rpx 12rpx; border-radius: 20rpx; margin-right: 12rpx; }
.menu-arrow { font-size: 32rpx; color: #D1D5DB; } .menu-arrow { font-size: 32rpx; color: #D1D5DB; }
.wrap-blue { background: #EEF2FF; } .wrap-blue { background: #EEF2FF; }
.wrap-purple { background: #F5F3FF; } .wrap-purple { background: #F5F3FF; }
.wrap-green { background: #ECFDF5; } .wrap-green { background: #ECFDF5; }
.wrap-orange { background: #FFF7ED; }
.wrap-gray { background: #F3F4F6; } .wrap-gray { background: #F3F4F6; }
.wrap-teal { background: #E6FFFA; }
.logout-wrap { margin-top: 8rpx; } .logout-wrap { margin-top: 8rpx; }
.logout-btn { background: #FFFFFF; color: var(--color-error); font-size: 28rpx; font-weight: 500; border-radius: var(--radius-md); height: 88rpx; line-height: 88rpx; border: 2rpx solid #FECACA; } .logout-btn { background: #FFFFFF; color: var(--color-error); font-size: 28rpx; font-weight: 500; border-radius: var(--radius-md); height: 88rpx; line-height: 88rpx; border: 2rpx solid #FECACA; }
.logout-btn:active { background: #FEF2F2; transform: scale(0.96); } .logout-btn:active { background: #FEF2F2; transform: scale(0.96); }
+23 -1
View File
@@ -22,7 +22,7 @@ async function request<T = any>(url: string, method: string = 'POST', data?: any
} }
} }
export const apiService = { const apiService = {
user: { user: {
sendCode: (phone: string) => request(API_ENDPOINTS.USER.SEND_CODE, 'POST', { phone }), sendCode: (phone: string) => request(API_ENDPOINTS.USER.SEND_CODE, 'POST', { phone }),
login: (phone: string, code: string) => request(API_ENDPOINTS.USER.LOGIN, 'POST', { phone, code }), login: (phone: string, code: string) => request(API_ENDPOINTS.USER.LOGIN, 'POST', { phone, code }),
@@ -83,6 +83,28 @@ export const apiService = {
byPosition: (position: string) => byPosition: (position: string) =>
request(API_ENDPOINTS.DAILY_QUESTION.BY_POSITION(position), 'GET', undefined, true), request(API_ENDPOINTS.DAILY_QUESTION.BY_POSITION(position), 'GET', undefined, true),
}, },
share: {
create: (data: { type: string; refId?: string; title?: string; description?: string }) =>
request(API_ENDPOINTS.SHARE.CREATE, 'POST', data, true),
stats: () => request(API_ENDPOINTS.SHARE.STATS, 'GET', undefined, true),
records: () => request(API_ENDPOINTS.SHARE.RECORDS, 'GET', undefined, true),
visitors: () => request(API_ENDPOINTS.SHARE.VISITORS, 'GET', undefined, true),
},
review: {
list: (page = 1, limit = 20) =>
request(`${API_ENDPOINTS.REVIEW.LIST}?page=${page}&limit=${limit}`, 'GET', undefined, true),
detail: (id: string) => request(API_ENDPOINTS.REVIEW.DETAIL(id), 'GET', undefined, true),
delete: (id: string) => request(API_ENDPOINTS.REVIEW.DELETE(id), 'DELETE', undefined, true),
submitText: (position: string, text: string, company?: string) =>
request(API_ENDPOINTS.REVIEW.TEXT, 'POST', { position, text, company: company || '' }, true),
},
career: {
analyze: (profile: { major: string; grade?: string; interests?: string; gpa?: string; goal?: string }) =>
request(API_ENDPOINTS.CAREER.ANALYZE, 'POST', profile, true),
chat: (message: string, history: { role: string; content: string }[]) =>
request(API_ENDPOINTS.CAREER.CHAT, 'POST', { message, history }, true),
positions: () => request(API_ENDPOINTS.CAREER.POSITIONS, 'GET', undefined, true),
},
} }
export default apiService export default apiService
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 180" fill="none" shape-rendering="auto"><metadata xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"><rdf:RDF><rdf:Description><dc:title>Bottts</dc:title><dc:creator>Pablo Stanley</dc:creator><dc:source xsi:type="dcterms:URI">https://bottts.com/</dc:source><dcterms:license xsi:type="dcterms:URI">https://bottts.com/</dcterms:license><dc:rights>Remix of „Bottts” (https://bottts.com/) by „Pablo Stanley”, licensed under „Free for personal and commercial use” (https://bottts.com/)</dc:rights></rdf:Description></rdf:RDF></metadata><mask id="viewboxMask"><rect width="180" height="180" rx="0" ry="0" x="0" y="0" fill="#fff" /></mask><g mask="url(#viewboxMask)"><rect fill="#b6e3f4" width="180" height="180" x="0" y="0" /><g transform="translate(0 66)"><path d="M38 12c-2.95 11.7-19.9 6.67-23.37 18-3.46 11.35 8.03 20 17.53 20" stroke="#2A3544" stroke-width="6" opacity=".9"/><path d="M150 55c8.4 3.49 20.1-7.6 16-16.5-4.1-8.9-16-6.7-16-19.3" stroke="#2A3544" stroke-width="4" opacity=".9"/><mask id="sidesCables01-a" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="21" y="6" width="138" height="58"><g fill="#fff"><rect x="21" y="35" width="16" height="22" rx="2"/><rect x="136" y="42" width="23" height="22" rx="2"/><rect x="136" y="6" width="23" height="18" rx="2"/></g></mask><g mask="url(#sidesCables01-a)"><path d="M0 0h180v76H0V0Z" fill="#546e7a"/><path d="M0 0h180v76H0V0Z" fill="#fff" fill-opacity=".3"/></g></g><g transform="translate(41)"><g filter="url(#topGlowingBulb01-a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M32 24A16 16 0 0 1 48 8h4a16 16 0 0 1 16 16v8a8 8 0 0 1-8 8H40a8 8 0 0 1-8-8v-8Z" fill="#fff" fill-opacity=".3"/></g><path d="M49 11.5c4.93 0 9.37 2.13 12.44 5.52" stroke="#fff" stroke-width="2" stroke-linecap="round"/><path d="m49.83 29-9-9L38 22.83l10 10V40h4v-7.03l10.14-10.14L59.31 20l-9 9h-.48Z" fill="#fff" fill-opacity=".8"/><rect x="22" y="40" width="56" height="12" rx="1" fill="#48494B"/><defs><filter id="topGlowingBulb01-a" x="24" y="0" width="52" height="48" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset/><feGaussianBlur stdDeviation="4"/><feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 0"/><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_617_621"/><feBlend in="SourceGraphic" in2="effect1_dropShadow_617_621" result="shape"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/><feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 0"/><feBlend in2="shape" result="effect2_innerShadow_617_621"/></filter></defs></g><g transform="translate(25 44)"><mask id="faceRound01-a" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="130" height="120"><path fill-rule="evenodd" clip-rule="evenodd" d="M66 0c58.35 0 64 40.69 64 78 0 33.31-25.47 42-64 42-37.46 0-66-8.69-66-42C0 40.69 7.65 0 66 0Z" fill="#fff"/></mask><g mask="url(#faceRound01-a)"><path d="M-4-2h138v124H-4V-2Z" fill="#546e7a"/><g transform="translate(-1 -1)"></g></g></g><g transform="translate(52 124)"><g fill="#000" fill-opacity=".6"><rect x="12" y="12" width="4" height="8" rx="2"/><rect x="36" y="12" width="4" height="8" rx="2"/><rect x="24" y="12" width="4" height="8" rx="2"/><rect x="48" y="12" width="4" height="8" rx="2"/><rect x="60" y="12" width="4" height="8" rx="2"/></g></g><g transform="translate(38 76)"><rect y="11" width="104" height="34" rx="17" fill="#000" fill-opacity=".8"/><circle cx="29" cy="28" r="13" fill="#F1EEDA"/><circle cx="75" cy="28" r="13" fill="#F1EEDA"/><rect x="24" y="23" width="10" height="10" rx="2" fill="#000" fill-opacity=".8"/><rect x="70" y="23" width="10" height="10" rx="2" fill="#000" fill-opacity=".8"/></g></g></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

+83
View File
@@ -0,0 +1,83 @@
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 400 400">
<defs>
<radialGradient id="skinGrad" cx="50%" cy="40%">
<stop offset="0%" stop-color="#FDE8D0"/>
<stop offset="100%" stop-color="#F0D0A8"/>
</radialGradient>
<radialGradient id="hairGrad" cx="50%" cy="80%">
<stop offset="0%" stop-color="#4A3728"/>
<stop offset="100%" stop-color="#2D1B1E"/>
</radialGradient>
<radialGradient id="eyeWhite" cx="50%" cy="40%">
<stop offset="0%" stop-color="#FFFFFF"/>
<stop offset="100%" stop-color="#F0F0F0"/>
</radialGradient>
<radialGradient id="irisGrad" cx="40%" cy="35%">
<stop offset="0%" stop-color="#6B4E37"/>
<stop offset="70%" stop-color="#3D2B1F"/>
<stop offset="100%" stop-color="#1A1108"/>
</radialGradient>
<linearGradient id="shirtGrad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#4B5563"/>
<stop offset="100%" stop-color="#374151"/>
</linearGradient>
</defs>
<!-- Background -->
<circle cx="200" cy="200" r="200" fill="#F0F2F5"/>
<!-- Hair back -->
<ellipse cx="200" cy="120" rx="120" ry="100" fill="url(#hairGrad)"/>
<!-- Neck -->
<rect x="165" y="270" width="70" height="50" rx="10" fill="url(#skinGrad)"/>
<!-- Shirt -->
<ellipse cx="200" cy="350" rx="140" ry="80" fill="url(#shirtGrad)"/>
<path d="M165 300 L200 340 L235 300" fill="none" stroke="#FFFFFF" stroke-width="2" opacity="0.3"/>
<!-- Face -->
<ellipse cx="200" cy="195" rx="100" ry="120" fill="url(#skinGrad)"/>
<!-- Hair front -->
<path d="M100 160 Q100 80 200 70 Q300 80 300 160 Q280 130 200 125 Q120 130 100 160 Z" fill="url(#hairGrad)"/>
<path d="M95 170 Q90 130 120 110 Q110 160 95 170 Z" fill="url(#hairGrad)"/>
<path d="M305 170 Q310 130 280 110 Q290 160 305 170 Z" fill="url(#hairGrad)"/>
<!-- Left eyebrow -->
<path d="M135 155 Q150 145 170 148" fill="none" stroke="#3D2B1F" stroke-width="3" stroke-linecap="round"/>
<!-- Right eyebrow -->
<path d="M265 155 Q250 145 230 148" fill="none" stroke="#3D2B1F" stroke-width="3" stroke-linecap="round"/>
<!-- Left eye -->
<ellipse cx="158" cy="175" rx="24" ry="18" fill="url(#eyeWhite)" stroke="#D4C4B0" stroke-width="1"/>
<circle cx="158" cy="175" r="12" fill="url(#irisGrad)"/>
<circle cx="158" cy="175" r="6" fill="#0A0A0A"/>
<circle cx="153" cy="170" r="4" fill="#FFFFFF" opacity="0.8"/>
<circle cx="163" cy="178" r="2" fill="#FFFFFF" opacity="0.5"/>
<!-- Right eye -->
<ellipse cx="242" cy="175" rx="24" ry="18" fill="url(#eyeWhite)" stroke="#D4C4B0" stroke-width="1"/>
<circle cx="242" cy="175" r="12" fill="url(#irisGrad)"/>
<circle cx="242" cy="175" r="6" fill="#0A0A0A"/>
<circle cx="237" cy="170" r="4" fill="#FFFFFF" opacity="0.8"/>
<circle cx="247" cy="178" r="2" fill="#FFFFFF" opacity="0.5"/>
<!-- Nose -->
<path d="M195 195 Q190 220 185 228 Q195 232 200 232 Q205 232 215 228 Q210 220 205 195" fill="none" stroke="#D4B896" stroke-width="1.5" stroke-linecap="round"/>
<ellipse cx="200" cy="230" rx="6" ry="3" fill="#E8C8A8" opacity="0.6"/>
<!-- Mouth -->
<path d="M178 260 Q189 268 200 268 Q211 268 222 260" fill="none" stroke="#C97B84" stroke-width="2.5" stroke-linecap="round"/>
<!-- Cheek blush -->
<ellipse cx="125" cy="225" rx="22" ry="14" fill="#FFB0A0" opacity="0.25"/>
<ellipse cx="275" cy="225" rx="22" ry="14" fill="#FFB0A0" opacity="0.25"/>
<!-- Ear left -->
<ellipse cx="100" cy="185" rx="12" ry="20" fill="url(#skinGrad)"/>
<!-- Ear right -->
<ellipse cx="300" cy="185" rx="12" ry="20" fill="url(#skinGrad)"/>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB