feat: v3.2 - 用户管理功能和后台菜单统一
新增功能: - 用户管理列表页面(搜索、分页) - 用户详情页面(基本信息、收藏统计) - 管理员重置用户密码功能 - 管理员修改用户昵称功能 - 管理后台首页添加用户统计卡片 优化改进: - 统一后台菜单结构,创建可复用的 sidebar 组件 - 所有后台页面使用统一菜单,避免硬编码 - 优化权限配置文件,清理冗余规则 技术文档: - 添加任务分解规则文档 - 添加后台菜单统一规则文档 - 添加数据库字段修复脚本 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
120
.claude/admin-menu-rules.md
Normal file
120
.claude/admin-menu-rules.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# 后台管理菜单统一规则
|
||||
|
||||
## 📋 规则说明
|
||||
|
||||
所有后台管理页面必须使用统一的菜单结构,不允许硬编码不同的菜单。
|
||||
|
||||
---
|
||||
|
||||
## 🎯 菜单结构
|
||||
|
||||
### 主菜单(按顺序)
|
||||
1. **控制台** - `{{ url_for('admin.index') }}`
|
||||
2. **网站管理** - `{{ url_for('site.index_view') }}`
|
||||
3. **标签管理** - `{{ url_for('tag.index_view') }}`
|
||||
4. **新闻管理** - `{{ url_for('news.index_view') }}`
|
||||
5. **Prompt管理** - `{{ url_for('prompttemplate.index_view') }}`
|
||||
6. **管理员** - `{{ url_for('admin_users.index_view') }}`
|
||||
|
||||
### 系统菜单(按顺序)
|
||||
1. **用户管理** - `{{ url_for('admin_users') }}`
|
||||
2. **SEO工具** - `{{ url_for('seo_tools') }}`
|
||||
3. **批量导入** - `{{ url_for('batch_import') }}`
|
||||
4. **修改密码** - `{{ url_for('change_password') }}`
|
||||
5. **查看网站** - `{{ url_for('index') }}` (target="_blank")
|
||||
6. **退出登录** - `{{ url_for('admin_logout') }}`
|
||||
|
||||
---
|
||||
|
||||
## 📝 实现方式
|
||||
|
||||
### 方式1:使用 admin/master.html(推荐)
|
||||
对于新增的后台页面,应该继承 `admin/master.html`:
|
||||
|
||||
```jinja2
|
||||
{% extends 'admin/master.html' %}
|
||||
|
||||
{% block body %}
|
||||
<!-- 页面内容 -->
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
**注意**:需要在路由中传递 `admin_view` 对象。
|
||||
|
||||
### 方式2:使用统一菜单组件
|
||||
对于独立HTML页面,使用 `{% include %}` 引入统一菜单组件:
|
||||
|
||||
```jinja2
|
||||
{% set active_page = 'page_name' %}
|
||||
{% include 'admin/components/sidebar.html' %}
|
||||
```
|
||||
|
||||
**注意**:
|
||||
- `active_page` 变量用于标记当前激活的菜单项
|
||||
- 统一菜单组件位于 `templates/admin/components/sidebar.html`
|
||||
- 禁止复制粘贴菜单代码,必须使用 include 方式
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 重要提醒
|
||||
|
||||
1. **禁止删减菜单项** - 所有页面必须显示完整菜单
|
||||
2. **禁止修改顺序** - 菜单顺序必须一致
|
||||
3. **禁止硬编码菜单** - 必须使用统一组件 `admin/components/sidebar.html`
|
||||
4. **新增菜单项** - 只需在统一组件中添加,所有页面自动生效
|
||||
5. **endpoint 名称** - 必须使用正确的 Flask-Admin endpoint
|
||||
|
||||
---
|
||||
|
||||
## 🔍 检查清单
|
||||
|
||||
添加新后台页面时,必须检查:
|
||||
- [ ] 主菜单包含6个项目
|
||||
- [ ] 系统菜单包含6个项目
|
||||
- [ ] endpoint 名称正确
|
||||
- [ ] 图标使用 Material Symbols
|
||||
- [ ] 当前页面有 `active` 类
|
||||
|
||||
---
|
||||
|
||||
## 📂 涉及的文件
|
||||
|
||||
**统一菜单组件:**
|
||||
- `templates/admin/components/sidebar.html` - 唯一的菜单源文件
|
||||
|
||||
**使用统一菜单的页面:**
|
||||
- `templates/admin/master.html` - Flask-Admin 页面基础模板
|
||||
- `templates/admin/batch_import.html` - 批量导入页面
|
||||
- `templates/admin/change_password.html` - 修改密码页面
|
||||
- `templates/admin/seo_tools.html` - SEO工具页面
|
||||
- `templates/admin/users/list.html` - 用户列表页面
|
||||
- `templates/admin/users/detail.html` - 用户详情页面
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 维护指南
|
||||
|
||||
### 添加新菜单项
|
||||
1. 在 `templates/admin/components/sidebar.html` 中添加
|
||||
2. 更新本文档
|
||||
3. 所有使用该组件的页面自动生效
|
||||
|
||||
### 删除菜单项
|
||||
1. 从 `templates/admin/components/sidebar.html` 中删除
|
||||
2. 更新本文档
|
||||
3. 所有使用该组件的页面自动生效
|
||||
|
||||
### 修改菜单顺序
|
||||
1. 在 `templates/admin/components/sidebar.html` 中调整
|
||||
2. 更新本文档
|
||||
3. 所有使用该组件的页面自动生效
|
||||
|
||||
### 新增后台页面
|
||||
1. 如果是 Flask-Admin 页面,继承 `admin/master.html`
|
||||
2. 如果是独立页面,使用 `{% include 'admin/components/sidebar.html' %}`
|
||||
3. 设置 `active_page` 变量标记当前页面
|
||||
|
||||
---
|
||||
|
||||
**最后更新**: 2025-02-08
|
||||
**维护人**: Claude Sonnet 4.5
|
||||
Reference in New Issue
Block a user