diff --git a/src/api/menu.ts b/src/api/menu.ts index f09a351..aa52cbe 100644 --- a/src/api/menu.ts +++ b/src/api/menu.ts @@ -46,7 +46,7 @@ export type MenuNode = { // 新增父级菜单 export function addParentMenu(data: Omit) { return http({ - url: "/api/Menu/create-parent", + url: "/api/Menu/createParent", method: "POST", data, }); @@ -54,7 +54,7 @@ export function addParentMenu(data: Omit) { // 编辑父级菜单 export function editParentMenu(data: Omit) { return http({ - url: "/api/Menu/update-parent", + url: "/api/Menu/updateParent", method: "PUT", data, }); @@ -62,7 +62,7 @@ export function editParentMenu(data: Omit) { // 新增子级菜单 export function addChildMenu(data:Omit){ return http({ - url:'/api/Menu/create-child', + url:'/api/Menu/createChild', method:'POST', data }) @@ -70,7 +70,7 @@ export function addChildMenu(data:Omit){ // 编辑子级菜单 export function eidtChildMenu(data:RawMenu){ return http({ - url:'/api/Menu/update-child', + url:'/api/Menu/updateChild', method:'PUT', data }) @@ -85,7 +85,7 @@ export function getAllMenu():Promise{ // 递归删除菜单 export function deleteMenu(uuid:string){ return http({ - url:`/api/Menu/all/${uuid}`, + url:`/api/Menu/delete/${uuid}`, method:'DELETE' }) } \ No newline at end of file diff --git a/src/assets/icons/mainproject.svg b/src/assets/icons/mainproject.svg index db6d17b..ce3728c 100644 --- a/src/assets/icons/mainproject.svg +++ b/src/assets/icons/mainproject.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/money.svg b/src/assets/icons/money.svg index 2f91336..01b8015 100644 --- a/src/assets/icons/money.svg +++ b/src/assets/icons/money.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/order.svg b/src/assets/icons/order.svg index 9c87c32..eb2ea42 100644 --- a/src/assets/icons/order.svg +++ b/src/assets/icons/order.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/styles/common.scss b/src/assets/styles/common.scss index 88f9f29..8ff0de3 100644 --- a/src/assets/styles/common.scss +++ b/src/assets/styles/common.scss @@ -24,4 +24,7 @@ &.right{ justify-content: right; } + &.between{ + justify-content: space-between; + } } diff --git a/src/components/SvgIcon.vue b/src/components/SvgIcon.vue index a4f45a1..629b82e 100644 --- a/src/components/SvgIcon.vue +++ b/src/components/SvgIcon.vue @@ -39,7 +39,8 @@ const iconName = computed(() => `#icon-${props.iconClass}`); const svgStyle = computed(() => ({ width: typeof props.width === 'number' ? `${props.width}px` : props.width, height: typeof props.height === 'number' ? `${props.height}px` : props.height, - fill: props.color + fill: props.color + ' !important', + '--icon-color': props.color })); @@ -48,5 +49,12 @@ const svgStyle = computed(() => ({ display: inline-block; vertical-align: middle; overflow: hidden; + + :deep(path) { + fill: var(--icon-color) !important; + } + :deep(use) { + fill: var(--icon-color) !important; + } } \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 70ab569..1ba3f21 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,4 +1,9 @@ -import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; +import { + createRouter, + createWebHistory, + RouteRecordRaw, + RouterView, +} from "vue-router"; import NProgress from "nprogress"; // progress bar import "nprogress/nprogress.css"; // progress bar style @@ -36,9 +41,16 @@ const routes: Array = [ component: Home, }, { - path: "role", // 匹配 /layout/role - name: "roleAuth", - component: Auth, + path: "role", + name: "Role", + component: RouterView, + children: [ + { + path: "auth", // 匹配 /layout/role + name: "roleAuth", + component: Auth, + }, + ], }, { path: "menu", diff --git a/src/utils/permission.ts b/src/utils/permission.ts new file mode 100644 index 0000000..67b3c4b --- /dev/null +++ b/src/utils/permission.ts @@ -0,0 +1,59 @@ +import { RouteMeta, RouteRecordRaw, RouterView } from "vue-router"; +import NotFound from "@/views/404/index.vue" +interface MenuItem { + uuid: string; + path: string; + label: string; + icon: string; + menuCode: string; + adaptability: string; + component: string; + sort: number; + status: string; + query: string; + parentId?: string; + children?: MenuItem[]; +} +function getComponent(componentPath: string) { + // 处理view-router特殊路由 + if (componentPath === 'view-router') { + return RouterView + } + + // 动态导入组件,添加错误处理 + return () => { + try { + // 尝试动态导入组件 + const componentPromise = import(`@/views/${componentPath}`) + + // 成功加载则返回组件 + return componentPromise.catch(() => { + console.error(`组件加载失败: @/views/${componentPath}, 回退到404页面`) + return NotFound + }) + + } catch (error) { + console.error('动态导入组件时发生错误:', error) + return NotFound + } + } +} +export function generateRoutes(menuList: MenuItem[]): RouteRecordRaw[] { + return menuList.map((menu) => { + const route: RouteRecordRaw = { + path: menu.path, + name: menu.path.toUpperCase(), //路径转大写 + meta: { + ...(menu.query ? JSON.parse(menu.query) : {}) + }, + component: getComponent(menu.component), + children:[] + }; + + if (menu.children && menu.children.length > 0) { + route.children = generateRoutes(menu.children); + } + + return route; + }); +} diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index 42138a5..450efed 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -1,81 +1,82 @@