e7646d17a67dc4a3f0d5faa32d8f8e8268101690
## 修复内容
### 1. 修复一级分组过滤问题
- **问题**: getEvaluationPointGroups 函数忽略了 pid 参数,导致返回所有分组(包括二级分组)
- **修复**: 添加 pid 参数处理逻辑,支持传递 "null" 字符串来查询一级分组
- **文件**: app/api/evaluation_points/rule-groups.ts:1186-1198
### 2. 修复 React key 重复警告
- **问题**: 父分组和子分组可能有相同的 ID,导致 "Encountered two children with the same key" 警告
- **修复**: 将 rowKey 从简单的 "id" 改为根据 isParent 生成唯一 key
- **文件**: app/routes/rule-groups._index.tsx:817
### 3. 新增后端 API 规范文档
- **文件**: docs/evaluation/evaluation_point_groups_backend_api_spec.md
- **内容**:
- 完整的 9 个 FastAPI v3 接口规范
- Python Pydantic 模型定义
- TypeScript 接口定义
- pid 参数处理说明(字符串 "null" 转换为 None)
- 10 个完整测试用例
- 数据库表结构建议
## 技术细节
**pid 参数处理**:
```typescript
// 前端发送
GET /api/v3/evaluation-point-groups?pid=null&page=1
// 后端需要识别字符串 "null" 并转换为 None/NULL
if (pid == "null") {
query = query.filter(EvaluationPointGroup.pid.is_(None))
}
```
**唯一 key 生成**:
```typescript
rowKey={(record) => record.isParent ? `parent-${record.id}` : `child-${record.id}`}
```
🔗 相关文档: docs/evaluation/evaluation_point_groups_backend_api_spec.md
智慧法务系统 - 权限认证系统
认证系统概述
本系统实现了一个简单的基于角色的权限认证系统,支持以下功能:
-
用户可以以不同角色登录系统:
common:普通用户,只能访问基本功能developer:开发者,可以访问所有功能,包括系统设置
-
权限控制:
- 根据用户角色显示或隐藏菜单项
- 防止通过URL直接访问未授权页面
技术实现
权限系统基于以下核心技术实现:
- Cookie会话存储:使用Remix的
createCookieSessionStorage创建基于Cookie的会话存储 - 角色权限控制:将用户角色存储在会话中,并在全局loader中检查访问权限
- 界面适配:根据用户角色动态过滤显示菜单项
使用方法
登录系统
- 访问登录页面(
/login) - 输入用户名和密码
- 选择用户角色:
- 普通用户:只能看到基础功能菜单
- 开发者:可以看到所有菜单,包括系统设置
权限验证
系统会自动执行以下权限验证:
- 未登录用户会被重定向到登录页面
- 普通用户试图访问系统设置等受限页面会被重定向到首页
- 侧边栏菜单会根据用户角色动态显示
关键文件
app/root.tsx:实现会话管理和全局权限检查app/components/layout/Sidebar.tsx:根据用户角色显示不同菜单app/routes/login.tsx:提供角色选择功能
进一步优化建议
- 实现真实的用户认证系统,如接入数据库验证用户
- 添加更细粒度的权限控制
- 实现用户角色和权限的管理界面
- 使用环境变量管理会话密钥等敏感信息
Welcome to Remix!
Development
Run the dev server:
npm run dev
Deployment
First, build your app for production:
npm run build
Then run the app in production mode:
npm start
Now you'll need to pick a host to deploy it to.
DIY
If you're familiar with deploying Node applications, the built-in Remix app server is production-ready.
Make sure to deploy the output of npm run build
build/serverbuild/client
Styling
This template comes with Tailwind CSS already configured for a simple default starting experience. You can use whatever css framework you prefer. See the Vite docs on css for more information.
Description
Languages
JavaScript
72.4%
TypeScript
23.8%
CSS
3.6%