From 157491c6f48836ebf449c01908ab7e220f47dcf1 Mon Sep 17 00:00:00 2001 From: fangyunong Date: Tue, 15 Jul 2025 14:19:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto-imports.d.ts | 6 + src/api/menu.ts | 91 ++++++ src/views/system/menu/index.vue | 494 +++++++++++++++++++++++++++++++- 3 files changed, 588 insertions(+), 3 deletions(-) create mode 100644 src/api/menu.ts diff --git a/auto-imports.d.ts b/auto-imports.d.ts index b9a680c..e4734c3 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -7,15 +7,21 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] + const addChildMenu: typeof import('./src/api/menu')['addChildMenu'] + const addParentMenu: typeof import('./src/api/menu')['addParentMenu'] const computed: typeof import('vue')['computed'] const createApp: typeof import('vue')['createApp'] const customRef: typeof import('vue')['customRef'] const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] + const deleteMenu: typeof import('./src/api/menu')['deleteMenu'] const deleteUser: typeof import('./src/api/roleApi')['deleteUser'] + const editParentMenu: typeof import('./src/api/menu')['editParentMenu'] const effectScope: typeof import('vue')['effectScope'] + const eidtChildMenu: typeof import('./src/api/menu')['eidtChildMenu'] const enable: typeof import('./src/api/roleApi')['enable'] const enableRole: typeof import('./src/api/roleApi')['enableRole'] + const getAllMenu: typeof import('./src/api/menu')['getAllMenu'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] const getCurrentScope: typeof import('vue')['getCurrentScope'] const getRoleList: typeof import('./src/api/roleApi')['getRoleList'] diff --git a/src/api/menu.ts b/src/api/menu.ts new file mode 100644 index 0000000..f09a351 --- /dev/null +++ b/src/api/menu.ts @@ -0,0 +1,91 @@ +import http from "@/utils/request"; + +export interface RawMenu { + uuid:string; + parentId:string; + path: string; + label: string; + icon: string; + menuCode: string; + adaptability: string; + component: string; + sort: number; + status: string; + query: string; +} +// 返回的树结构 +export type MenuTree = { + uuid: string; + parentId: null; // 根节点的parentId必须为null + path: string; + label: string; + icon: string; + menuCode: string; + adaptability: string; + component: string; + sort: number; + status: string; + query: string; + children: MenuNode[]; +}; + +export type MenuNode = { + uuid: string; + parentId: string; // 子节点的parentId必须为字符串 + path: string; + label: string; + icon: string; + menuCode: string; + adaptability: string; + component: string; + sort: number; + status: string; + query: string; + children: MenuNode[]; +}; +// 新增父级菜单 +export function addParentMenu(data: Omit) { + return http({ + url: "/api/Menu/create-parent", + method: "POST", + data, + }); +} +// 编辑父级菜单 +export function editParentMenu(data: Omit) { + return http({ + url: "/api/Menu/update-parent", + method: "PUT", + data, + }); +} +// 新增子级菜单 +export function addChildMenu(data:Omit){ + return http({ + url:'/api/Menu/create-child', + method:'POST', + data + }) +} +// 编辑子级菜单 +export function eidtChildMenu(data:RawMenu){ + return http({ + url:'/api/Menu/update-child', + method:'PUT', + data + }) +} +//菜单全量返回 +export function getAllMenu():Promise{ + return http({ + url:'/api/Menu/all', + method:'GET', + }) +} +// 递归删除菜单 +export function deleteMenu(uuid:string){ + return http({ + url:`/api/Menu/all/${uuid}`, + method:'DELETE' + }) +} \ No newline at end of file diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index b113563..42138a5 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -1,8 +1,496 @@ - - \ No newline at end of file