Files
HaHafeng 66255368b7 feat(admin): Add user management and upgrade to module permission system
Features - User Management (Phase 4.1):
- Database: Add user_modules table for fine-grained module permissions
- Database: Add 4 user permissions (view/create/edit/delete) to role_permissions
- Backend: UserService (780 lines) - CRUD with tenant isolation
- Backend: UserController + UserRoutes (648 lines) - 13 API endpoints
- Backend: Batch import users from Excel
- Frontend: UserListPage (412 lines) - list/filter/search/pagination
- Frontend: UserFormPage (341 lines) - create/edit with module config
- Frontend: UserDetailPage (393 lines) - details/tenant/module management
- Frontend: 3 modal components (592 lines) - import/assign/configure
- API: GET/POST/PUT/DELETE /api/admin/users/* endpoints

Architecture Upgrade - Module Permission System:
- Backend: Add getUserModules() method in auth.service
- Backend: Login API returns modules array in user object
- Frontend: AuthContext adds hasModule() method
- Frontend: Navigation filters modules based on user.modules
- Frontend: RouteGuard checks requiredModule instead of requiredVersion
- Frontend: Remove deprecated version-based permission system
- UX: Only show accessible modules in navigation (clean UI)
- UX: Smart redirect after login (avoid 403 for regular users)

Fixes:
- Fix UTF-8 encoding corruption in ~100 docs files
- Fix pageSize type conversion in userService (String to Number)
- Fix authUser undefined error in TopNavigation
- Fix login redirect logic with role-based access check
- Update Git commit guidelines v1.2 with UTF-8 safety rules

Database Changes:
- CREATE TABLE user_modules (user_id, tenant_id, module_code, is_enabled)
- ADD UNIQUE CONSTRAINT (user_id, tenant_id, module_code)
- INSERT 4 permissions + role assignments
- UPDATE PUBLIC tenant with 8 module subscriptions

Technical:
- Backend: 5 new files (~2400 lines)
- Frontend: 10 new files (~2500 lines)
- Docs: 1 development record + 2 status updates + 1 guideline update
- Total: ~4900 lines of code

Status: User management 100% complete, module permission system operational
2026-01-16 13:42:10 +08:00

135 lines
5.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# **壹证循科技 \- AI智能问答 (AIA) V2.1 产品需求文档**
**文档状态:** Draft (V2.1)
**关联原型:** AI问答原型图V11.html
**架构标准:** Postgres-Only | Ant Design X | Schema Isolation
**最后更新:** 2026-01-11
**本次更新:** 新增移动端适配、深度思考模式、UI/UX 细节规范
## **1\. 概述与目标**
### **1.1 背景**
原 AIA 模块功能较为单一。V2.0+ 版本旨在构建一个**全流程驱动的科研智能体大厅 (Agent Hub)**,对标 ChatGPT/Gemini 的流畅体验,并深度结合医学科研场景。
### **1.2 核心价值**
1. **流程化引导**:打破“只有一个对话框”的迷茫感,通过 5 个阶段引导用户逐步推进研究。
2. **专业分工**:不同的智能体加载不同的 System Prompt 和知识库。
3. **全端体验**:提供桌面端到移动端的无缝衔接,随时随地记录科研灵感。
## **2\. 核心业务流程 (User Flow)**
1. **进入大厅 (Dashboard)**
* 顶部提供“全局意图搜索框”,用户输入模糊需求。
* 系统识别意图,自动跳转到对应的智能体。
2. **选择智能体**
* 用户也可以直接点击具体的卡片如“06 样本量计算”)。
3. **沉浸式工作台 (Workspace)**
* 进入具体的对话界面。
* **桌面端**:三栏布局(历史记录 \+ 对话区 \+ 如果有右侧引用栏)。
* **移动端**:单栏布局,历史记录折叠为抽屉。
4. **结果产出**
* AI 展示**思考过程 (Thinking Process)** 后输出最终答案。
* 用户可一键导出 Word 报告。
## **3\. 功能需求详情**
### **F1. 智能体大厅 (Dashboard) \- 基于 V11 原型**
#### **F1.1 全局意图路由 (Intent Router)**
* **UI**:顶部大搜索框,文案“输入研究想法...”。
* **逻辑**:后端调用 Router Agent 识别意图 \-\> 跳转目标 Agent \-\> 自动填入 Prompt。
#### **F1.2 智能体流水线展示 (Agent Pipeline)**
严格还原 V11 原型的 **5 阶段布局****3 色视觉体系**(详见原型图)。
* **跳转逻辑**
* **常规卡片**:进入 Chat Workspace。
* **工具卡片 (09, 10\)**:跳转 /dc/portal 或 /st/dashboard。
### **F2. 沉浸式对话工作台 (Chat Workspace)**
#### **F2.1 界面布局与风格 (UI/UX)**
* **设计理念**:参考 Gemini 的“大留白”风格,减少分割线,使用卡片投影区分层级。
* **左侧侧边栏 (Sidebar)**
* **桌面端**:固定显示,可折叠(图标化)。
* **移动端**默认隐藏通过左上角“汉堡菜单”滑出Drawer 组件)。
* **内容**按时间分组的历史会话今天、昨天、7天前
* **主对话区 (Main Area)**
* **Header**:显示当前智能体名称 \+ 状态("思考中..." / "输入中...")。
* **Input**:底部悬浮,支持多行自动增高。
#### **F2.2 核心对话能力增强**
* **深度思考模式 (Thinking Process)**
* **需求**针对“科学问题梳理”等复杂任务AI 需先输出推理过程。
* **交互**:输出 \<think\>...\</think\> 内容时,前端显示为**可折叠的灰色引用块**,默认展开,生成结束后自动收起,只显示“已深度思考 (耗时 12s)”。
* **Markdown 渲染增强**
* **公式**:使用 Katex 渲染 LaTeX 医学公式。
* **表格**:支持横向滚动,防止手机端撑破布局。
* **代码**:支持一键复制,语法高亮。
* **快捷指令 (Slash Commands)**
* 输入 / 弹出快捷菜单:/润色, /扩写, /翻译, /导出Word。
#### **F2.3 附件上传 (Attachment)**
* **格式**PDF, Word, TXT, Excel (限制 20MB)。
* **处理 (Postgres-Only)**
1. 上传 OSS \-\> common\_schema.files。
2. 后端提取文本 \-\> 截取注入 LLM Context。
3. **UI 显示**:在气泡下方显示附件小卡片(图标+文件名)。
#### **F2.4 结果操作栏 (Action Bar)**
每条 AI 回答下方提供微型工具栏Hover 显示):
* **复制**:复制 Markdown 源码。
* **重新生成**:不满意当前回答,触发重试。
* **导出 Word**:调用 RVW 模块的 docx 导出服务,将当前单轮对话导出为文档。
### **F3. 移动端适配 (Mobile Adaptation)**
#### **F3.1 响应式布局**
* **断点**md (768px)。
* **Dashboard**
* 隐藏顶部复杂导航,只保留 Logo 和 用户头像。
* 智能体卡片由 3 列变为 1 列流式布局。
* 左侧时间轴Timeline在移动端需调整样式避免占用过多水平空间可改为顶部横向步骤条或简化左侧线条
#### **F3.2 交互优化**
* **输入体验**
* 输入框聚焦时,确保不被 iOS/Android 软键盘遮挡scrollIntoView
* 发送按钮在移动端需始终可见。
* **触控反馈**:按钮和卡片增加 active 态背景色变化。
## **4\. 数据架构 (Postgres-Only)**
*(保持不变,复用 V2.0 定义)*
// schema.prisma (新增字段)
model AiaMessage {
// ... 现有字段
thinkingContent String? @db.Text // 存储思维链内容 (\<think\>...\</think\>)
// ...
}
## **5\. 配置化开发策略**
*(保持不变)*
## **6\. 非功能性需求**
* **流式体验**TTFB (首字响应时间) \< 1.5s。
* **移动端性能**:首屏加载 \< 1s (LCP)。
* **防抖**:意图搜索框需增加 500ms 防抖,避免频繁请求 Router Agent。