Skip to content

Feat/workspace redesign - #2

Merged
HPUhushicheng merged 25 commits into
mainfrom
feat/workspace-redesign
May 17, 2026
Merged

Feat/workspace redesign#2
HPUhushicheng merged 25 commits into
mainfrom
feat/workspace-redesign

Conversation

@HPUhushicheng

Copy link
Copy Markdown
Owner

No description provided.

HPUhushicheng and others added 25 commits April 29, 2026 01:34
- 将 vue-vben-admin 嵌入到 Timer-Plus 项目中
- 适配 Timer-Plus 的 studentid/password 登录认证
- 实现工作台、今日时长、一周数据、座次表、更新动态页面
- 配置 Vite 代理到远程服务器 (47.120.68.44:666)
- 修改 electron/config/bin.js 指向新的前端目录
- 修复 API 路径适配(移除 /api 前缀)
time 表的 id 字段为 INT 类型,但前端传递的是学号字符串(如 test001),
导致数据库插入时类型不匹配返回 500。

修复方案:所有已认证的路由(get/del/recordTime)统一从 req.user.id
(JWT token 解码后的学号)获取用户身份,避免客户端传入错误类型。

影响范围:
- exports.get: id 从 req.query.id → req.user.id
- exports.del: id 从 req.body.id → req.user.id
- exports.recordTime: id 从 req.body.id → req.user.id
彻底重写 5 个仪表盘页面,使用 @vben/common-ui 和 @vben/plugins/echarts
组件库,统一设计语言:

workspace/index.vue:
- 使用 AnalysisOverview 组件展示概览数据
- 使用 AnalysisChartCard 组件展示功能入口卡片
- 使用 @vben/icons 图标组件

today-time.vue:
- 使用 EchartsUI + useEcharts 替代裸 echarts
- 使用 AnalysisChartCard 包裹图表

week-time.vue:
- 使用 EchartsUI + useEcharts 替代裸 echarts
- 使用 AnalysisChartCard 包裹图表
- 双列 flex 布局

site-chart.vue:
- 使用 Tailwind CSS 网格布局
- 使用 bg-card/border-border 等主题变量
- 统一卡片样式

dong-tai.vue:
- 使用 bg-card/border-border 主题变量
- 统一时间线卡片样式
- 新增 Chat AI 助手页面 (chat.vue),对接服务器 /api/chat/proxy 智谱 GLM-4
- 新增网站导航页面 (site-nav.vue),包含常用网址/实用工具/学习教育
- 新增问题反馈页面 (qq-group.vue),展示 QQ 群二维码和加群功能
- 路由新增 ChatAi/SiteNav/QQGroup 三个仪表盘子路由
- 更新 CI 构建流程:改用 pnpm 构建 vue-vben-admin 前端
- 更新 .env.production API 地址指向生产服务器
- 优化仪表盘页面 UI (workspace/today-time/week-time/site-chart/dong-tai)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- 修复 getTimeApi/getAllTimeApi 查询参数改为 URL 内嵌方式(与 legacy 一致)
- 修复所有页面的 res.data 访问错误(responseReturn: 'data' 已自动 unwrap)
- 修复字段名:daytime 替代 hour,hourtime 替代 duration
- week-time 分钟单位统一:hourtime/60
- 删除 AI 助手和网站导航页面(不需要)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…add error handling

The vben requestClient's complex interceptor chain (defaultResponseInterceptor
with responseReturn: 'data') was interfering with the server's
{status, data, message} response format, causing today-time API to fail
with "缺少 id 或 date 参数" despite valid JWT and URL.

- Rewrote getTimeApi/getAllTimeApi/getAllUsersApi to use native fetch()
  with authFetch() helper, matching the legacy frontend's approach
- Added catch blocks and error UI states to today-time, site-chart,
  and week-time pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…logging

- Added getToken() that tries useAccessStore() first, then falls back to
  localStorage.getItem('auth_token') matching legacy frontend behavior
- Added console.log in authFetch to show whether token is found and
  what the server responds with
- This helps debug the persistent 400 "缺少 id 或 date 参数" error

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added decodeJwtPayload() to extract and log the JWT payload
- Removed Content-Type header from GET requests (no body, unnecessary)
- This will reveal whether the JWT's id field is the root cause of
  the 400 "缺少 id 或 date 参数" error

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…y option

- getTimeApi/getAllTimeApi now use requestClient.get with {params}
  to ensure query strings are correctly serialized through Vite proxy
- Removed ws: true from /api proxy config - not needed for Timer-Plus
  and may interfere with query string forwarding
- authFetch still used for getAllUsersApi (no query params needed)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…Req fix

- Set VITE_GLOB_API_URL=http://47.120.68.44:666 in dev mode to bypass
  Vite proxy entirely - the proxy was not forwarding query strings
- Added proxyReq handler in vite.config.ts to force preserve req.url
  (including query string) as a backup fix for the proxy issue
- Switched getAllUsersApi from authFetch to requestClient.get
- Backend has CORS enabled, so direct cross-origin requests work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…param issue

- Added debug logging for req.query and req.user in time.get
- Will reveal why req.query.date is always falsy despite valid URL params

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
… relying on req.user

All /api/time/* handlers (get, del, recordTime) were calling req.user.id
which was null/undefined on the production server. Added getUserId(req)
helper that decodes JWT from the Authorization header directly, bypassing
the middleware compatibility issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…timer_dbId

The production server still uses the old code where time.get reads id from
req.query instead of JWT. This fix:
1. Adds getUserStudentId() helper that reads studentid from userStore or localStorage
2. getTimeApi() now auto-includes the user's studentid as the id query param
3. Sets timer_dbId in localStorage on login for timer store compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The time table stores records with numeric info.id (not studentid). Fixed:
- getCurrentUserId() reads numeric userId from userStore or localStorage
- getTimeApi() passes the numeric user ID as the id query param
- auth store stores String(timerUser.id) (numeric) in timer_dbId

Tested: all 4 time endpoints (get, record, getall, del) return 200 OK.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Server-side changes:
- Add role + last_active columns to info table (deploy.sh migration)
- Add requireAdmin middleware for admin-only endpoints
- JWT now includes role field; login returns user.role
- New admin.js: user update, password change, seat assign, stats
- list.js now returns role, online status, seat info
- time.js recordTime updates last_active for online detection
- Admin-protect DELETE /list/del

Frontend changes:
- Auth store reads role from backend, sets accessCodes accordingly
- New API functions: updateProfile, changePassword, assignSeat, deleteUser, adminStats
- Profile page rewritten: personal info edit, password change, my stats tab
- Site-chart now shows real online status and seat info
- Admin panel: user management, seat management, data stats
- Workspace shows admin shortcuts and role badge for admins

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added `visible` TINYINT(1) DEFAULT 1 column to info table
- list.js now returns visible field for all users
- New PUT /list/visible endpoint (admin-only) to toggle visibility
- toggleVisibilityApi() added to frontend API layer
- Site-chart: hidden users filtered by default, toggle to show them
- Seat management: eye icon per user to show/hide on seat chart
- Hidden count reminder with switch toggle on site-chart

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add announcements table, API endpoints (create/list/delete), and admin
  management page
- Add latest announcement banner on workspace for all users
- Replace broken iconify eye icon in seat management with text buttons
  (visible/hidden label)
- Each feature includes server-side (admin.js, router.js, deploy.sh)
  and front-end (timer.ts, Vue pages, routes) changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…e metrics

- Redesigned workspace page with hero banner, metric cards, and focus panel
- Added real-time clock (1s refresh), session timer, and daily target progress
- 6 quick-entry cards with color-coded tones and hover animations
- Announcement panel with dismiss/expand and proper empty states
- Insight section showing session health and daily target hints
- Admin panel with stats overview for admin users
- Dark mode support with full is-dark styling
- Simplified announcements admin page from table to card layout
- Updated CI workflow to trigger on feat/workspace-redesign branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
After npm install, patch electron/config/config.prod.js to enable DevTools
in undocked mode for all platform builds. This allows debugging frontend
routing and API issues directly in the packaged app.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Electron v21 bundles Chromium ~96 which lacks Array.prototype.toSorted
(added in Chrome 110 / ES2023). Added polyfill at entry point before
any imports to prevent "e.toSorted is not a function" error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add lg: grid breakpoint so the two-column hero and content panels
adapt better on mid-sized screens before hitting xl breakpoint.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Deleted:
- Demo route modules (demos.ts, vben.ts)
- Demo views (demos/antd, _core/about)
- Analytics demo charts (trends, visits, visits-data, visits-source, visits-sales)
- Demo locale files (zh-CN/en-US demos.json)

Profile route moved to its own module (profile.ts).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Tabs: increase active tab background opacity for better visibility
- Workspace: adjust grid gap for mid-sized screens

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
新增基于多维行为指纹与加密活性证明的在线时长可信计量系统,
包含以下核心模块:

客户端:
- ActivitySampler: 鼠标轨迹/击键动力学/窗口焦点/系统空闲多维采样
- BehavioralFingerprint: 分形维度+击键CV+活动节律行为指纹引擎
- ActivityProofEngine: 加密活性证明上报协调器
- ClockDriftDetector: 系统时钟篡改检测

服务端:
- TimeValidator: 时间连续性+行为指纹+群体基线多层验证
- BehaviorAnalyzer: 跨用户行为基线3σ交叉验证
- ChallengeManager: 加密挑战-响应概率验证协议

Electron:
- 系统级powerMonitor空闲/锁屏监听

数据库:
- behavior_records表 + activity_baselines表

文档:
- PATENT_APPLICATION.md: 完整中国发明专利申请文件(12项权利要求)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Implement frontend activity proof system (ActivitySampler, BehavioralFingerprint,
  ClockDriftDetector, ActivityProofEngine) for anti-cheating liveness detection
- Implement server-side validation services (TimeValidator, BehaviorAnalyzer,
  ChallengeManager) with multi-layer verification engine
- Fix ClockDriftDetector.isHealthy() using absolute drift instead of relative
  drift, causing clockHealthy to always return false
- Fix vben timer store _continuity.gapWallClock semantics (was using UI elapsed
  instead of real wall clock gap)
- Remove dead authFetch/getToken/decodeJwtPayload code from vben timer API
- Add timerStore.stopTimer() in workspace onBeforeUnmount to prevent timer leaks
- Fix week-time.vue totalUsers to use registered user count, not just active ones
- Add loading/error/empty states to legacy WeekTime.vue with chart memory leak fix
- Remove hardcoded AI API key from server/app.js, switch to env variable
- Add sessionId + sequenceNumber tracking to vben timer store for continuity validation
- Add non-enhanced client validation on server side (request frequency, gaps)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 17, 2026 11:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@HPUhushicheng
HPUhushicheng merged commit 0fcd696 into main May 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants