4.0 KiB
4.0 KiB
Requirements Document
Introduction
完善 HoneyBox.Admin 后台管理系统的菜单管理页面功能。当前菜单管理页面只有展示功能,需要实现完整的 CRUD 操作,包括新增菜单、编辑菜单、添加子菜单和删除菜单。
Glossary
- Menu_Page: 菜单管理页面组件
- Menu_API: 前端菜单 API 模块
- Menu_Form: 菜单表单对话框组件
- Menu_Tree: 菜单树形表格
Requirements
Requirement 1: 前端 API 补充
User Story: As a developer, I want to have complete menu API functions, so that the frontend can call backend CRUD operations.
Acceptance Criteria
- THE Menu_API SHALL export createMenu function to call POST /api/admin/menus
- THE Menu_API SHALL export updateMenu function to call PUT /api/admin/menus/{id}
- THE Menu_API SHALL export deleteMenu function to call DELETE /api/admin/menus/{id}
- THE Menu_API SHALL export getMenuById function to call GET /api/admin/menus/{id}
- THE Menu_API SHALL define CreateMenuRequest and UpdateMenuRequest TypeScript interfaces
Requirement 2: 新增菜单功能
User Story: As an administrator, I want to add new menus, so that I can expand the system navigation structure.
Acceptance Criteria
- WHEN the user clicks "新增菜单" button, THE Menu_Page SHALL display a form dialog
- THE Menu_Form SHALL include fields: parentId (tree select), name, path, component, icon, menuType, permission, sortOrder, status, isExternal, isCache
- WHEN the user submits a valid form, THE Menu_Page SHALL call createMenu API and refresh the menu tree
- IF the API returns an error, THEN THE Menu_Page SHALL display the error message
- WHEN the form is submitted successfully, THE Menu_Page SHALL close the dialog and show success message
Requirement 3: 添加子菜单功能
User Story: As an administrator, I want to add child menus under existing menus, so that I can create hierarchical navigation.
Acceptance Criteria
- WHEN the user clicks "添加子菜单" button on a menu row, THE Menu_Page SHALL display the form dialog with parentId pre-filled
- THE Menu_Form SHALL show the parent menu name in the parentId field
- WHEN the user submits the form, THE Menu_Page SHALL create the menu as a child of the selected parent
Requirement 4: 编辑菜单功能
User Story: As an administrator, I want to edit existing menus, so that I can update menu information.
Acceptance Criteria
- WHEN the user clicks "编辑" button on a menu row, THE Menu_Page SHALL display the form dialog with existing data
- THE Menu_Form SHALL populate all fields with the current menu data
- THE Menu_Form SHALL allow changing the parent menu (with validation to prevent circular reference)
- WHEN the user submits a valid form, THE Menu_Page SHALL call updateMenu API and refresh the menu tree
- IF the API returns an error, THEN THE Menu_Page SHALL display the error message
Requirement 5: 删除菜单功能
User Story: As an administrator, I want to delete menus, so that I can remove unused navigation items.
Acceptance Criteria
- WHEN the user clicks "删除" button on a menu row, THE Menu_Page SHALL display a confirmation dialog
- THE confirmation dialog SHALL warn about deleting child menus if the menu has children
- WHEN the user confirms deletion, THE Menu_Page SHALL call deleteMenu API and refresh the menu tree
- IF the API returns an error, THEN THE Menu_Page SHALL display the error message
- WHEN deletion is successful, THE Menu_Page SHALL show success message
Requirement 6: 表单验证
User Story: As an administrator, I want form validation, so that I can ensure data integrity.
Acceptance Criteria
- THE Menu_Form SHALL require name field (non-empty)
- WHEN menuType is "菜单" (type 2), THE Menu_Form SHALL require path and component fields
- WHEN menuType is "按钮" (type 3), THE Menu_Form SHALL require permission field
- THE Menu_Form SHALL validate path format (must start with / for internal routes)
- THE Menu_Form SHALL validate sortOrder as a non-negative integer