From 9baf3410138cb8a152ec51f70340d500fa009510 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 30 Aug 2023 21:19:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=80=82=E9=85=8D=E5=8F=8A?= =?UTF-8?q?=E5=90=AF=E7=94=A8=20Arco=20Design=20Pro=20Vue=20=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves #1 --- .../cnadmin/auth/model/vo/MetaVO.java | 6 +++ .../auth/service/impl/LoginServiceImpl.java | 1 + continew-admin-ui/.gitignore | 1 - .../src/components/menu/use-menu-tree.ts | 6 +-- continew-admin-ui/src/config/settings.json | 2 +- .../src/router/app-menus/index.ts | 8 ++-- continew-admin-ui/src/router/guard/index.ts | 2 +- .../src/router/guard/permission.ts | 17 +++++--- continew-admin-ui/src/router/index.ts | 4 +- .../src/router/routes/externalModules/arco.ts | 10 ----- .../router/routes/externalModules/github.ts | 10 ----- continew-admin-ui/src/router/routes/index.ts | 18 +++++---- .../{arco-design => demo}/exception.ts | 9 ++--- .../modules/{arco-design => demo}/form.ts | 7 ++-- .../modules/{arco-design => demo}/list.ts | 7 ++-- .../modules/{arco-design => demo}/profile.ts | 5 +-- .../modules/{arco-design => demo}/result.ts | 7 ++-- .../{arco-design => demo}/visualization.ts | 9 ++--- .../routes/modules/{ => fixed}/dashboard.ts | 10 ++--- .../routes/modules/{ => fixed}/user-center.ts | 7 ++-- .../src/router/routes/modules/monitor.ts | 11 ++--- .../src/router/routes/modules/system.ts | 16 +++----- .../src/router/routes/modules/tool.ts | 4 +- .../src/store/modules/app/index.ts | 6 +-- .../controller/tool/GeneratorController.java | 6 +++ .../changelog/v1.0.0/continew-admin_data.sql | 40 +++++++++---------- .../changelog/v1.1.0/continew-admin_data.sql | 8 ++++ 27 files changed, 114 insertions(+), 123 deletions(-) delete mode 100644 continew-admin-ui/src/router/routes/externalModules/arco.ts delete mode 100644 continew-admin-ui/src/router/routes/externalModules/github.ts rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/exception.ts (96%) rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/form.ts (96%) rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/list.ts (96%) rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/profile.ts (94%) rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/result.ts (95%) rename continew-admin-ui/src/router/routes/modules/{arco-design => demo}/visualization.ts (96%) rename continew-admin-ui/src/router/routes/modules/{ => fixed}/dashboard.ts (79%) rename continew-admin-ui/src/router/routes/modules/{ => fixed}/user-center.ts (82%) diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/MetaVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/MetaVO.java index 203bb482..cf2eda28 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/MetaVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/MetaVO.java @@ -46,6 +46,12 @@ public class MetaVO implements Serializable { @Schema(description = "菜单图标", example = "user") private String icon; + /** + * 排序 + */ + @Schema(description = "排序", example = "1") + private Integer order; + /** * 是否隐藏 */ diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java index 170b51ee..c550e086 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java @@ -124,6 +124,7 @@ public class LoginServiceImpl implements LoginService { metaVO.setIcon(m.getIcon()); metaVO.setIgnoreCache(!m.getIsCache()); metaVO.setHideInMenu(m.getIsHidden()); + metaVO.setOrder(m.getSort()); tree.putExtra("meta", metaVO); }); return BeanUtil.copyToList(treeList, RouteVO.class); diff --git a/continew-admin-ui/.gitignore b/continew-admin-ui/.gitignore index d8b900ed..004766c9 100644 --- a/continew-admin-ui/.gitignore +++ b/continew-admin-ui/.gitignore @@ -1,7 +1,6 @@ .DS_Store node_modules/ dist/ -demo/ npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/continew-admin-ui/src/components/menu/use-menu-tree.ts b/continew-admin-ui/src/components/menu/use-menu-tree.ts index ed548c5a..2630a314 100644 --- a/continew-admin-ui/src/components/menu/use-menu-tree.ts +++ b/continew-admin-ui/src/components/menu/use-menu-tree.ts @@ -2,7 +2,7 @@ import { computed } from 'vue'; import { RouteRecordRaw, RouteRecordNormalized } from 'vue-router'; import usePermission from '@/hooks/permission'; import { useAppStore } from '@/store'; -import appClientMenus from '@/router/app-menus'; +import staticMenus from '@/router/app-menus'; import { cloneDeep } from 'lodash'; export default function useMenuTree() { @@ -10,9 +10,9 @@ export default function useMenuTree() { const appStore = useAppStore(); const appRoute = computed(() => { if (appStore.menuFromServer) { - return appStore.appAsyncMenus; + return [...staticMenus, ...appStore.appAsyncMenus]; } - return appClientMenus; + return staticMenus; }); const menuTree = computed(() => { const copyRouter = cloneDeep(appRoute.value) as RouteRecordNormalized[]; diff --git a/continew-admin-ui/src/config/settings.json b/continew-admin-ui/src/config/settings.json index 5bfb6241..544804af 100644 --- a/continew-admin-ui/src/config/settings.json +++ b/continew-admin-ui/src/config/settings.json @@ -13,6 +13,6 @@ "globalSettings": false, "device": "desktop", "tabBar": false, - "menuFromServer": false, + "menuFromServer": true, "serverMenu": [] } diff --git a/continew-admin-ui/src/router/app-menus/index.ts b/continew-admin-ui/src/router/app-menus/index.ts index 2136c969..3148cc06 100644 --- a/continew-admin-ui/src/router/app-menus/index.ts +++ b/continew-admin-ui/src/router/app-menus/index.ts @@ -1,8 +1,8 @@ -import { appRoutes, appExternalRoutes } from '../routes'; +import { fixedRoutes, demoRoutes } from '../routes'; -const mixinRoutes = [...appRoutes, ...appExternalRoutes]; +const mixinRoutes = [...fixedRoutes, ...demoRoutes]; -const appClientMenus = mixinRoutes.map((el) => { +const staticMenus = mixinRoutes.map((el) => { const { name, path, meta, redirect, children } = el; return { name, @@ -13,4 +13,4 @@ const appClientMenus = mixinRoutes.map((el) => { }; }); -export default appClientMenus; +export default staticMenus; diff --git a/continew-admin-ui/src/router/guard/index.ts b/continew-admin-ui/src/router/guard/index.ts index bedc28d2..c03a99c3 100644 --- a/continew-admin-ui/src/router/guard/index.ts +++ b/continew-admin-ui/src/router/guard/index.ts @@ -11,7 +11,7 @@ function setupPageGuard(router: Router) { } export default function createRouteGuard(router: Router) { - setupPageGuard(router); setupUserLoginInfoGuard(router); setupPermissionGuard(router); + setupPageGuard(router); } diff --git a/continew-admin-ui/src/router/guard/permission.ts b/continew-admin-ui/src/router/guard/permission.ts index d3c60d1f..b8aceec2 100644 --- a/continew-admin-ui/src/router/guard/permission.ts +++ b/continew-admin-ui/src/router/guard/permission.ts @@ -3,7 +3,7 @@ import NProgress from 'nprogress'; // progress bar import usePermission from '@/hooks/permission'; import { useLoginStore, useAppStore } from '@/store'; -import { appRoutes } from '../routes'; +import { fixedRoutes, demoRoutes } from '../routes'; import { WHITE_LIST, NOT_FOUND } from '../constants'; export default function setupPermissionGuard(router: Router) { @@ -16,7 +16,7 @@ export default function setupPermissionGuard(router: Router) { // 针对来自服务端的菜单配置进行处理 // Handle routing configuration from the server - // 根据需要自行完善来源于服务端的菜单配置的permission逻辑 + // 根据需要自行完善来源于服务端的菜单配置的 permission 逻辑 // Refine the permission logic from the server's menu configuration as needed if ( !appStore.appAsyncMenus.length && @@ -24,7 +24,12 @@ export default function setupPermissionGuard(router: Router) { ) { await appStore.fetchServerMenuConfig(); } - const serverMenuConfig = [...appStore.appAsyncMenus, ...WHITE_LIST]; + const serverMenuConfig = [ + ...appStore.appAsyncMenus, + ...WHITE_LIST, + ...fixedRoutes, + ...demoRoutes, + ]; let exist = false; while (serverMenuConfig.length && !exist) { @@ -45,8 +50,10 @@ export default function setupPermissionGuard(router: Router) { if (permissionsAllow) next(); else { const destination = - Permission.findFirstPermissionRoute(appRoutes, loginStore.roles[0]) || - NOT_FOUND; + Permission.findFirstPermissionRoute( + [...fixedRoutes, ...demoRoutes], + loginStore.roles[0] + ) || NOT_FOUND; next(destination); } } diff --git a/continew-admin-ui/src/router/index.ts b/continew-admin-ui/src/router/index.ts index e230a4b8..b417382c 100644 --- a/continew-admin-ui/src/router/index.ts +++ b/continew-admin-ui/src/router/index.ts @@ -2,7 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'; import NProgress from 'nprogress'; // progress bar import 'nprogress/nprogress.css'; -import { appRoutes } from './routes'; +import { appRoutes, fixedRoutes, demoRoutes } from './routes'; import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base'; import createRouteGuard from './guard'; @@ -24,6 +24,8 @@ const router = createRouter({ }, }, ...appRoutes, + ...fixedRoutes, + ...demoRoutes, REDIRECT_MAIN, NOT_FOUND_ROUTE, ], diff --git a/continew-admin-ui/src/router/routes/externalModules/arco.ts b/continew-admin-ui/src/router/routes/externalModules/arco.ts deleted file mode 100644 index 6cc2a1bf..00000000 --- a/continew-admin-ui/src/router/routes/externalModules/arco.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default { - path: 'https://arco.design/vue/docs/start', - name: 'ArcoWebsite', - meta: { - locale: 'menu.arcoWebsite', - icon: 'link', - requiresAuth: true, - order: 106, - }, -}; diff --git a/continew-admin-ui/src/router/routes/externalModules/github.ts b/continew-admin-ui/src/router/routes/externalModules/github.ts deleted file mode 100644 index 954032ed..00000000 --- a/continew-admin-ui/src/router/routes/externalModules/github.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default { - path: 'https://github.com/Charles7c/continew-admin', - name: 'GitHub', - meta: { - locale: 'menu.github', - icon: 'github', - requiresAuth: true, - order: 107, - }, -}; diff --git a/continew-admin-ui/src/router/routes/index.ts b/continew-admin-ui/src/router/routes/index.ts index 9337bfb0..6c205403 100644 --- a/continew-admin-ui/src/router/routes/index.ts +++ b/continew-admin-ui/src/router/routes/index.ts @@ -1,9 +1,8 @@ import type { RouteRecordNormalized } from 'vue-router'; -const modules = import.meta.glob('./modules/**/*.ts', { eager: true }); -const externalModules = import.meta.glob('./externalModules/*.ts', { - eager: true, -}); +const appModules = import.meta.glob('./modules/*.ts', { eager: true }); +const fixedModules = import.meta.glob('./modules/fixed/*.ts', { eager: true }); +const demoModules = import.meta.glob('./modules/demo/*.ts', { eager: true }); function formatModules(_modules: any, result: RouteRecordNormalized[]) { Object.keys(_modules).forEach((key) => { @@ -17,9 +16,12 @@ function formatModules(_modules: any, result: RouteRecordNormalized[]) { return result; } -export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []); - -export const appExternalRoutes: RouteRecordNormalized[] = formatModules( - externalModules, +export const appRoutes: RouteRecordNormalized[] = formatModules(appModules, []); +export const fixedRoutes: RouteRecordNormalized[] = formatModules( + fixedModules, + [] +); +export const demoRoutes: RouteRecordNormalized[] = formatModules( + demoModules, [] ); diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/exception.ts b/continew-admin-ui/src/router/routes/modules/demo/exception.ts similarity index 96% rename from continew-admin-ui/src/router/routes/modules/arco-design/exception.ts rename to continew-admin-ui/src/router/routes/modules/demo/exception.ts index 0f9099f4..f70bb711 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/exception.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/exception.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const EXCEPTION: AppRouteRecordRaw = { path: '/exception', - name: 'exception', component: DEFAULT_LAYOUT, meta: { locale: 'menu.exception', requiresAuth: true, icon: 'exclamation-circle', - order: 104, + order: 904, }, children: [ { - path: '403', name: '403', + path: '403', component: () => import('@/views/arco-design/exception/403/index.vue'), meta: { locale: 'menu.exception.403', @@ -23,8 +22,8 @@ const EXCEPTION: AppRouteRecordRaw = { }, }, { - path: '404', name: '404', + path: '404', component: () => import('@/views/arco-design/exception/404/index.vue'), meta: { locale: 'menu.exception.404', @@ -33,8 +32,8 @@ const EXCEPTION: AppRouteRecordRaw = { }, }, { - path: '500', name: '500', + path: '500', component: () => import('@/views/arco-design/exception/500/index.vue'), meta: { locale: 'menu.exception.500', diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/form.ts b/continew-admin-ui/src/router/routes/modules/demo/form.ts similarity index 96% rename from continew-admin-ui/src/router/routes/modules/arco-design/form.ts rename to continew-admin-ui/src/router/routes/modules/demo/form.ts index 39aed815..3d6da436 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/form.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/form.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const FORM: AppRouteRecordRaw = { path: '/form', - name: 'form', component: DEFAULT_LAYOUT, meta: { locale: 'menu.form', icon: 'bookmark', requiresAuth: true, - order: 101, + order: 901, }, children: [ { - path: 'step', name: 'Step', + path: 'step', component: () => import('@/views/arco-design/form/step/index.vue'), meta: { locale: 'menu.form.step', @@ -23,8 +22,8 @@ const FORM: AppRouteRecordRaw = { }, }, { - path: 'group', name: 'Group', + path: 'group', component: () => import('@/views/arco-design/form/group/index.vue'), meta: { locale: 'menu.form.group', diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/list.ts b/continew-admin-ui/src/router/routes/modules/demo/list.ts similarity index 96% rename from continew-admin-ui/src/router/routes/modules/arco-design/list.ts rename to continew-admin-ui/src/router/routes/modules/demo/list.ts index a4d4e9dc..a77788ce 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/list.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/list.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const LIST: AppRouteRecordRaw = { path: '/list', - name: 'list', component: DEFAULT_LAYOUT, meta: { locale: 'menu.list', requiresAuth: true, icon: 'list', - order: 100, + order: 900, }, children: [ { - path: 'search-table', // The midline path complies with SEO specifications name: 'SearchTable', + path: 'search-table', // The midline path complies with SEO specifications component: () => import('@/views/arco-design/list/search-table/index.vue'), meta: { @@ -24,8 +23,8 @@ const LIST: AppRouteRecordRaw = { }, }, { - path: 'card', name: 'Card', + path: 'card', component: () => import('@/views/arco-design/list/card/index.vue'), meta: { locale: 'menu.list.cardList', diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/profile.ts b/continew-admin-ui/src/router/routes/modules/demo/profile.ts similarity index 94% rename from continew-admin-ui/src/router/routes/modules/arco-design/profile.ts rename to continew-admin-ui/src/router/routes/modules/demo/profile.ts index 6d947b0a..75144900 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/profile.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/profile.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const PROFILE: AppRouteRecordRaw = { path: '/profile', - name: 'profile', component: DEFAULT_LAYOUT, meta: { locale: 'menu.profile', requiresAuth: true, icon: 'file', - order: 102, + order: 902, }, children: [ { - path: 'basic', name: 'Basic', + path: 'basic', component: () => import('@/views/arco-design/profile/basic/index.vue'), meta: { locale: 'menu.profile.basic', diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/result.ts b/continew-admin-ui/src/router/routes/modules/demo/result.ts similarity index 95% rename from continew-admin-ui/src/router/routes/modules/arco-design/result.ts rename to continew-admin-ui/src/router/routes/modules/demo/result.ts index 224c9be5..78d85992 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/result.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/result.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const RESULT: AppRouteRecordRaw = { path: '/result', - name: 'result', component: DEFAULT_LAYOUT, meta: { locale: 'menu.result', icon: 'check-circle', requiresAuth: true, - order: 103, + order: 903, }, children: [ { - path: 'success', name: 'Success', + path: 'success', component: () => import('@/views/arco-design/result/success/index.vue'), meta: { locale: 'menu.result.success', @@ -23,8 +22,8 @@ const RESULT: AppRouteRecordRaw = { }, }, { - path: 'error', name: 'Error', + path: 'error', component: () => import('@/views/arco-design/result/error/index.vue'), meta: { locale: 'menu.result.error', diff --git a/continew-admin-ui/src/router/routes/modules/arco-design/visualization.ts b/continew-admin-ui/src/router/routes/modules/demo/visualization.ts similarity index 96% rename from continew-admin-ui/src/router/routes/modules/arco-design/visualization.ts rename to continew-admin-ui/src/router/routes/modules/demo/visualization.ts index f15ea42a..d747a084 100644 --- a/continew-admin-ui/src/router/routes/modules/arco-design/visualization.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/visualization.ts @@ -3,18 +3,17 @@ import { AppRouteRecordRaw } from '../../types'; const VISUALIZATION: AppRouteRecordRaw = { path: '/visualization', - name: 'visualization', component: DEFAULT_LAYOUT, meta: { locale: 'menu.visualization', requiresAuth: true, icon: 'bar-chart', - order: 105, + order: 905, }, children: [ { - path: 'data-analysis', name: 'DataAnalysis', + path: 'data-analysis', component: () => import('@/views/arco-design/visualization/data-analysis/index.vue'), meta: { @@ -24,8 +23,8 @@ const VISUALIZATION: AppRouteRecordRaw = { }, }, { - path: 'multi-dimension-data-analysis', name: 'MultiDimensionDataAnalysis', + path: 'multi-dimension-data-analysis', component: () => import( '@/views/arco-design/visualization/multi-dimension-data-analysis/index.vue' @@ -37,8 +36,8 @@ const VISUALIZATION: AppRouteRecordRaw = { }, }, { - path: 'monitor', name: 'Monitor', + path: 'monitor', component: () => import('@/views/arco-design/visualization/monitor/index.vue'), meta: { diff --git a/continew-admin-ui/src/router/routes/modules/dashboard.ts b/continew-admin-ui/src/router/routes/modules/fixed/dashboard.ts similarity index 79% rename from continew-admin-ui/src/router/routes/modules/dashboard.ts rename to continew-admin-ui/src/router/routes/modules/fixed/dashboard.ts index 20cfc223..92e57fe1 100644 --- a/continew-admin-ui/src/router/routes/modules/dashboard.ts +++ b/continew-admin-ui/src/router/routes/modules/fixed/dashboard.ts @@ -1,9 +1,9 @@ -import { DEFAULT_LAYOUT } from '../base'; -import { AppRouteRecordRaw } from '../types'; +import { DEFAULT_LAYOUT } from '../../base'; +import { AppRouteRecordRaw } from '../../types'; const DASHBOARD: AppRouteRecordRaw = { path: '/dashboard', - name: 'dashboard', + name: 'Dashboard', component: DEFAULT_LAYOUT, redirect: '/dashboard/workplace', meta: { @@ -15,14 +15,14 @@ const DASHBOARD: AppRouteRecordRaw = { }, children: [ { - path: 'workplace', name: 'Workplace', + path: 'workplace', component: () => import('@/views/dashboard/workplace/index.vue'), meta: { locale: 'menu.dashboard.workplace', requiresAuth: true, roles: ['*'], - activeMenu: 'dashboard', + activeMenu: 'Dashboard', }, }, ], diff --git a/continew-admin-ui/src/router/routes/modules/user-center.ts b/continew-admin-ui/src/router/routes/modules/fixed/user-center.ts similarity index 82% rename from continew-admin-ui/src/router/routes/modules/user-center.ts rename to continew-admin-ui/src/router/routes/modules/fixed/user-center.ts index 88bdf188..67dac539 100644 --- a/continew-admin-ui/src/router/routes/modules/user-center.ts +++ b/continew-admin-ui/src/router/routes/modules/fixed/user-center.ts @@ -1,9 +1,8 @@ -import { DEFAULT_LAYOUT } from '../base'; -import { AppRouteRecordRaw } from '../types'; +import { DEFAULT_LAYOUT } from '../../base'; +import { AppRouteRecordRaw } from '../../types'; const UserCenter: AppRouteRecordRaw = { path: '/login/user', - name: 'user', component: DEFAULT_LAYOUT, meta: { locale: 'menu.user', @@ -12,8 +11,8 @@ const UserCenter: AppRouteRecordRaw = { }, children: [ { - path: 'center', name: 'UserCenter', + path: 'center', component: () => import('@/views/system/user/center/index.vue'), meta: { locale: 'menu.user.center', diff --git a/continew-admin-ui/src/router/routes/modules/monitor.ts b/continew-admin-ui/src/router/routes/modules/monitor.ts index a2e844b7..e7b3cd0b 100644 --- a/continew-admin-ui/src/router/routes/modules/monitor.ts +++ b/continew-admin-ui/src/router/routes/modules/monitor.ts @@ -3,7 +3,6 @@ import { AppRouteRecordRaw } from '../types'; const Monitor: AppRouteRecordRaw = { path: '/monitor', - name: 'monitor', component: DEFAULT_LAYOUT, meta: { locale: 'menu.monitor', @@ -13,23 +12,21 @@ const Monitor: AppRouteRecordRaw = { }, children: [ { - path: '/monitor/online', name: 'OnlineUser', + path: '/monitor/online', component: () => import('@/views/monitor/online/index.vue'), meta: { locale: 'menu.online.user.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/monitor/log/login', name: 'LoginLog', + path: '/monitor/log/login', component: () => import('@/views/monitor/log/login/index.vue'), meta: { locale: 'menu.log.login.list', requiresAuth: true, - roles: ['*'], }, }, { @@ -39,17 +36,15 @@ const Monitor: AppRouteRecordRaw = { meta: { locale: 'menu.log.operation.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/monitor/log/system', name: 'SystemLog', + path: '/monitor/log/system', component: () => import('@/views/monitor/log/system/index.vue'), meta: { locale: 'menu.log.system.list', requiresAuth: true, - roles: ['*'], }, }, ], diff --git a/continew-admin-ui/src/router/routes/modules/system.ts b/continew-admin-ui/src/router/routes/modules/system.ts index 44a2a6e8..5ab8eba1 100644 --- a/continew-admin-ui/src/router/routes/modules/system.ts +++ b/continew-admin-ui/src/router/routes/modules/system.ts @@ -3,7 +3,6 @@ import { AppRouteRecordRaw } from '../types'; const System: AppRouteRecordRaw = { path: '/system', - name: 'system', component: DEFAULT_LAYOUT, meta: { locale: 'menu.system', @@ -13,53 +12,48 @@ const System: AppRouteRecordRaw = { }, children: [ { - path: '/system/user', name: 'User', + path: '/system/user', component: () => import('@/views/system/user/index.vue'), meta: { locale: 'menu.system.user.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/system/role', name: 'Role', + path: '/system/role', component: () => import('@/views/system/role/index.vue'), meta: { locale: 'menu.system.role.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/system/menu', name: 'Menu', + path: '/system/menu', component: () => import('@/views/system/menu/index.vue'), meta: { locale: 'menu.system.menu.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/system/dept', name: 'Dept', + path: '/system/dept', component: () => import('@/views/system/dept/index.vue'), meta: { locale: 'menu.system.dept.list', requiresAuth: true, - roles: ['*'], }, }, { - path: '/system/announcement', name: 'Announcement', + path: '/system/announcement', component: () => import('@/views/system/announcement/index.vue'), meta: { locale: 'menu.system.announcement.list', requiresAuth: true, - roles: ['*'], }, }, ], diff --git a/continew-admin-ui/src/router/routes/modules/tool.ts b/continew-admin-ui/src/router/routes/modules/tool.ts index dacf81b6..1a727918 100644 --- a/continew-admin-ui/src/router/routes/modules/tool.ts +++ b/continew-admin-ui/src/router/routes/modules/tool.ts @@ -3,7 +3,6 @@ import { AppRouteRecordRaw } from '../types'; const Tool: AppRouteRecordRaw = { path: '/tool', - name: 'tool', component: DEFAULT_LAYOUT, meta: { locale: 'menu.tool', @@ -13,13 +12,12 @@ const Tool: AppRouteRecordRaw = { }, children: [ { - path: '/tool/generator', name: 'Generator', + path: '/tool/generator', component: () => import('@/views/tool/generator/index.vue'), meta: { locale: 'menu.tool.generator.list', requiresAuth: true, - roles: ['*'], }, }, ], diff --git a/continew-admin-ui/src/store/modules/app/index.ts b/continew-admin-ui/src/store/modules/app/index.ts index e39110e5..38182ce6 100644 --- a/continew-admin-ui/src/store/modules/app/index.ts +++ b/continew-admin-ui/src/store/modules/app/index.ts @@ -49,21 +49,21 @@ const useAppStore = defineStore('app', { try { notifyInstance = Notification.info({ id: 'menuNotice', // Keep the instance id the same - content: 'loading', + content: '菜单加载中...', closable: true, }); const { data } = await listRoute(); this.serverMenu = data; notifyInstance = Notification.success({ id: 'menuNotice', - content: 'success', + content: '菜单加载成功', closable: true, }); } catch (error) { // eslint-disable-next-line @typescript-eslint/no-unused-vars notifyInstance = Notification.error({ id: 'menuNotice', - content: 'error', + content: '菜单加载失败', closable: true, }); } diff --git a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/tool/GeneratorController.java b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/tool/GeneratorController.java index 0d6953eb..c58b8a58 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/tool/GeneratorController.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/tool/GeneratorController.java @@ -30,6 +30,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.extra.spring.SpringUtil; import top.charles7c.cnadmin.common.model.query.PageQuery; @@ -59,6 +60,7 @@ public class GeneratorController { private final GeneratorService generatorService; @Operation(summary = "分页查询数据表", description = "分页查询数据表") + @SaCheckPermission("tool:generator:list") @GetMapping("/table") public R> pageTable(TableQuery query, @Validated PageQuery pageQuery) throws SQLException { return R.ok(generatorService.pageTable(query, pageQuery)); @@ -69,6 +71,7 @@ public class GeneratorController { @Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH), @Parameter(name = "requireSync", description = "是否需要同步", example = "true", in = ParameterIn.QUERY)}) + @SaCheckPermission("tool:generator:list") @GetMapping("/field/{tableName}") public R> listFieldConfig(@PathVariable String tableName, @RequestParam(required = false, defaultValue = "false") Boolean requireSync) { @@ -77,6 +80,7 @@ public class GeneratorController { @Operation(summary = "查询生成配置信息", description = "查询生成配置信息") @Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH) + @SaCheckPermission("tool:generator:list") @GetMapping("/config/{tableName}") public R getGenConfig(@PathVariable String tableName) throws SQLException { return R.ok(generatorService.getGenConfig(tableName)); @@ -84,6 +88,7 @@ public class GeneratorController { @Operation(summary = "保存配置信息", description = "保存配置信息") @Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH) + @SaCheckPermission("tool:generator:list") @PostMapping("/config/{tableName}") public R saveConfig(@Validated @RequestBody GenConfigRequest request, @PathVariable String tableName) { generatorService.saveConfig(request, tableName); @@ -92,6 +97,7 @@ public class GeneratorController { @Operation(summary = "生成代码", description = "生成代码") @Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH) + @SaCheckPermission("tool:generator:list") @PostMapping("/{tableName}") public R generate(@PathVariable String tableName) { ValidationUtils.throwIf("prod".equals(SpringUtil.getActiveProfile()), "仅支持在开发环境生成代码"); diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql index 3d5f6c4d..4eeabdcc 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql @@ -2,7 +2,7 @@ -- changeset Charles7c:1 -- 初始化默认菜单 -INSERT IGNORE INTO `sys_menu` VALUES (1000, '系统管理', 0, 1, 'system', NULL, NULL, 'settings', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1000, '系统管理', 0, 1, '/system', NULL, NULL, 'settings', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1010, '用户管理', 1000, 2, '/system/user', 'User', '/system/user/index', NULL, b'0', b'0', b'0', 'system:user:list', 1, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1011, '用户新增', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:add', 1, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1012, '用户修改', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:update', 2, 1, 1, NOW(), NULL, NULL); @@ -10,29 +10,29 @@ INSERT IGNORE INTO `sys_menu` VALUES (1013, '用户删除', 1010, 3, NULL, NULL, INSERT IGNORE INTO `sys_menu` VALUES (1014, '用户导出', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:export', 4, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1015, '重置密码', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:password:reset', 5, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1016, '分配角色', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:role:update', 6, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1020, '角色管理', 1000, 2, '/system/role', 'Role', 'system/role/index', NULL, b'0', b'0', b'0', 'system:role:list', 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1020, '角色管理', 1000, 2, '/system/role', 'Role', '/system/role/index', NULL, b'0', b'0', b'0', 'system:role:list', 2, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1021, '角色新增', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:add', 1, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1022, '角色修改', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:update', 2, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1023, '角色删除', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:delete', 3, 1, 1, NOW(), NULL, NULL); INSERT IGNORE INTO `sys_menu` VALUES (1024, '角色导出', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:export', 4, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1030, '菜单管理', 1000, 2, '/system/menu', 'Menu', 'system/menu/index', NULL, b'0', b'0', b'0', 'system:menu:list', 3, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1031, '菜单新增', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:add', 1, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1032, '菜单修改', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:update', 2, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1033, '菜单删除', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:delete', 3, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1034, '菜单导出', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:export', 4, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1040, '部门管理', 1000, 2, '/system/dept', 'Dept', 'system/dept/index', NULL, b'0', b'0', b'0', 'system:dept:list', 4, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1041, '部门新增', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:add', 1, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1042, '部门修改', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:update', 2, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1043, '部门删除', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:delete', 3, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (1044, '部门导出', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:export', 4, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2000, '系统监控', 0, 1, 'monitor', NULL, NULL, 'computer', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2010, '在线用户', 2000, 2, '/monitor/online', 'OnlineUser', 'monitor/online/index', NULL, b'0', b'0', b'0', 'monitor:online:user:list', 1, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2011, '强退用户', 2010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'monitor:online:user:delete', 1, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2030, '登录日志', 2000, 2, '/monitor/log/login', 'LoginLog', 'monitor/log/login/index', NULL, b'0', b'0', b'0', 'monitor:log:login:list', 2, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2050, '操作日志', 2000, 2, '/monitor/log/operation', 'OperationLog', 'monitor/log/operation/index', NULL, b'0', b'0', b'0', 'monitor:log:operation:list', 3, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (2070, '系统日志', 2000, 2, '/monitor/log/system', 'SystemLog', 'monitor/log/system/index', NULL, b'0', b'0', b'0', 'monitor:log:system:list', 4, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (10000, 'Arco Design Vue', 0, 1, 'https://arco.design/vue/docs/start', NULL, NULL, 'link', b'1', b'0', b'0', NULL, 100, 1, 1, NOW(), NULL, NULL); -INSERT IGNORE INTO `sys_menu` VALUES (10001, 'GitHub', 0, 1, 'https://github.com/Charles7c/continew-admin', NULL, NULL, 'github', b'1', b'0', b'0', NULL, 101, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1030, '部门管理', 1000, 2, '/system/dept', 'Dept', '/system/dept/index', NULL, b'0', b'0', b'0', 'system:dept:list', 3, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1031, '部门新增', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:add', 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1032, '部门修改', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:update', 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1033, '部门删除', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:delete', 3, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1034, '部门导出', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:export', 4, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1900, '菜单管理', 1000, 2, '/system/menu', 'Menu', '/system/menu/index', NULL, b'0', b'0', b'0', 'system:menu:list', 999, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1901, '菜单新增', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:add', 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1902, '菜单修改', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:update', 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1903, '菜单删除', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:delete', 3, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1904, '菜单导出', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:export', 4, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9000, '系统监控', 0, 1, '/monitor', NULL, NULL, 'computer', b'0', b'0', b'0', NULL, 899, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9010, '在线用户', 9000, 2, '/monitor/online', 'OnlineUser', '/monitor/online/index', NULL, b'0', b'0', b'0', 'monitor:online:user:list', 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9011, '强退用户', 9010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'monitor:online:user:delete', 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9030, '登录日志', 9000, 2, '/monitor/log/login', 'LoginLog', '/monitor/log/login/index', NULL, b'0', b'0', b'0', 'monitor:log:login:list', 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9050, '操作日志', 9000, 2, '/monitor/log/operation', 'OperationLog', '/monitor/log/operation/index', NULL, b'0', b'0', b'0', 'monitor:log:operation:list', 3, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (9070, '系统日志', 9000, 2, '/monitor/log/system', 'SystemLog', '/monitor/log/system/index', NULL, b'0', b'0', b'0', 'monitor:log:system:list', 4, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (10000, 'Arco Design Vue', 0, 1, 'https://arco.design/vue/docs/start', NULL, NULL, 'link', b'1', b'0', b'0', NULL, 998, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (10001, 'GitHub', 0, 1, 'https://github.com/Charles7c/continew-admin', NULL, NULL, 'github', b'1', b'0', b'0', NULL, 999, 1, 1, NOW(), NULL, NULL); -- 初始化默认部门 INSERT IGNORE INTO `sys_dept` VALUES (1, 'Xxx科技有限公司', 0, '0', '系统初始部门', 1, 1, 1, 1, NOW(), NULL, NULL); diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql index 874085b8..9f91dcf9 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql @@ -1,2 +1,10 @@ -- liquibase formatted sql +-- changeset Charles7c:1 +INSERT IGNORE INTO `sys_menu` VALUES (1040, '公告管理', 1000, 2, '/system/announcement', 'Announcement', 'system/announcement/index', NULL, b'0', b'0', b'0', 'system:announcement:list', 4, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1041, '公告新增', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:add', 1, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1042, '公告修改', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:update', 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1043, '公告删除', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:delete', 3, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (1044, '公告导出', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:export', 4, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (2000, '系统工具', 0, 1, '/tool', NULL, NULL, 'tool', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL); +INSERT IGNORE INTO `sys_menu` VALUES (2010, '代码生成', 2000, 2, '/tool/generator', 'Generator', '/tool/generator/index', NULL, b'0', b'0', b'0', 'tool:generator:list', 1, 1, 1, NOW(), NULL, NULL); \ No newline at end of file