task-55(账号/权限页面): 实现菜单新增表单

menu-manage-model.ts 增 createMenuForm/flattenMenuNodes/nextSiblingSort;menu-manage-api.ts
增 createMenu POST /api/admin/permission-menus(unwrap+解析落库节点);MenusPage 新增菜单
Dialog(名称/标识/父菜单/路由/排序)校验后提交并刷新。8 用例全过,403 单测 + build 绿。
This commit is contained in:
2026-09-05 15:17:55 +08:00
parent ffb16bea9a
commit aaa943a86d
4 changed files with 192 additions and 4 deletions
@@ -1,9 +1,13 @@
/** 菜单管理列表加载适配(任务 54):GET /api/admin/permission-menus(admin) → 展示树。 */
import { http } from '@/api/http'
import { unwrap } from '@/api/envelope'
import {
ADMIN_MENU_TYPE,
buildMenuManageTree,
parseMenuManageItem,
parseMenuManageList,
toMenuCreateRequest,
type MenuManageForm,
type MenuManageNode,
} from './menu-manage-model'
@@ -19,3 +23,11 @@ export async function fetchMenuManageNodes(): Promise<MenuManageNode[]> {
export async function loadMenuManageTree(): Promise<MenuManageNode[]> {
return buildMenuManageTree(await fetchMenuManageNodes())
}
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。 */
export async function createMenu(form: MenuManageForm): Promise<MenuManageNode> {
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form))
const created = parseMenuManageItem(unwrap<unknown>(data))
if (!created) throw new Error('创建菜单响应异常:缺少菜单数据')
return created
}