From 12df1dfa6d0404d985f46720a54b4d6083aa100c Mon Sep 17 00:00:00 2001 From: xueyawen <18368883625@163.com> Date: Tue, 25 Feb 2025 15:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E7=B3=BB=E7=BB=9F=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E8=8F=9C=E5=8D=95=E6=A0=8F=EF=BC=8C=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=A1=B5=E9=9D=A2=E9=9C=80=E8=A6=81auth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 10 +- src/components/header.vue | 288 ++++++++++--------- src/components/menu.ts | 426 ++++++++++++++------------- src/router/index.ts | 590 +++++++++++++++++++++----------------- 4 files changed, 693 insertions(+), 621 deletions(-) diff --git a/components.d.ts b/components.d.ts index 3fb6319..5a3f09c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -13,7 +13,9 @@ declare module '@vue/runtime-core' { ElCard: typeof import('element-plus/es')['ElCard'] ElCascader: typeof import('element-plus/es')['ElCascader'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] + ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCol: typeof import('element-plus/es')['ElCol'] + ElColorPicker: typeof import('element-plus/es')['ElColorPicker'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] @@ -33,9 +35,13 @@ declare module '@vue/runtime-core' { ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] ElProgress: typeof import('element-plus/es')['ElProgress'] + ElRadio: typeof import('element-plus/es')['ElRadio'] + ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] + ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] + ElRate: typeof import('element-plus/es')['ElRate'] ElRow: typeof import('element-plus/es')['ElRow'] ElSelect: typeof import('element-plus/es')['ElSelect'] - ElStatistic: typeof import('element-plus/es')['ElStatistic'] + ElSlider: typeof import('element-plus/es')['ElSlider'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] @@ -45,7 +51,9 @@ declare module '@vue/runtime-core' { ElTag: typeof import('element-plus/es')['ElTag'] ElTimeline: typeof import('element-plus/es')['ElTimeline'] ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] + ElTimePicker: typeof import('element-plus/es')['ElTimePicker'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] + ElTransfer: typeof import('element-plus/es')['ElTransfer'] ElUpload: typeof import('element-plus/es')['ElUpload'] Header: typeof import('./src/components/header.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] diff --git a/src/components/header.vue b/src/components/header.vue index 8549ebb..17fae56 100644 --- a/src/components/header.vue +++ b/src/components/header.vue @@ -1,204 +1,216 @@ diff --git a/src/components/menu.ts b/src/components/menu.ts index 2644432..eb8bd5d 100644 --- a/src/components/menu.ts +++ b/src/components/menu.ts @@ -1,221 +1,215 @@ -import { Menus } from '@/types/menu'; +import { Menus } from "@/types/menu"; export const menuData: Menus[] = [ - { - id: '0', - title: '系统首页', - index: '/dashboard', - icon: 'Odometer', - }, - { - id: '1', - title: '系统管理', - index: '1', - icon: 'HomeFilled', + { + id: "1", + title: "系统管理", + index: "1", + icon: "HomeFilled", + children: [ + { + id: "11", + pid: "1", + index: "/system-user", + title: "用户管理", + }, + { + id: "12", + pid: "1", + index: "/system-role", + title: "角色管理", + }, + { + id: "13", + pid: "1", + index: "/system-menu", + title: "菜单管理", + }, + ], + }, + { + id: "2", + title: "组件", + index: "2-1", + icon: "Calendar", + children: [ + { + id: "21", + pid: "3", + index: "/form", + title: "表单", + }, + { + id: "22", + pid: "3", + index: "/upload", + title: "上传", + }, + { + id: "23", + pid: "2", + index: "/carousel", + title: "走马灯", + }, + { + id: "24", + pid: "2", + index: "/calendar", + title: "日历", + }, + { + id: "25", + pid: "2", + index: "/watermark", + title: "水印", + }, + { + id: "26", + pid: "2", + index: "/tour", + title: "分布引导", + }, + { + id: "27", + pid: "2", + index: "/steps", + title: "步骤条", + }, + { + id: "28", + pid: "2", + index: "/statistic", + title: "统计", + }, + { + id: "29", + pid: "3", + index: "29", + title: "三级菜单", children: [ - { - id: '11', - pid: '1', - index: '/system-user', - title: '用户管理', - }, - { - id: '12', - pid: '1', - index: '/system-role', - title: '角色管理', - }, - { - id: '13', - pid: '1', - index: '/system-menu', - title: '菜单管理', - }, + { + id: "291", + pid: "29", + index: "/editor", + title: "富文本编辑器", + }, + { + id: "292", + pid: "29", + index: "/markdown", + title: "markdown编辑器", + }, ], - }, - { - id: '2', - title: '组件', - index: '2-1', - icon: 'Calendar', - children: [ - { - id: '21', - pid: '3', - index: '/form', - title: '表单', - }, - { - id: '22', - pid: '3', - index: '/upload', - title: '上传', - }, - { - id: '23', - pid: '2', - index: '/carousel', - title: '走马灯', - }, - { - id: '24', - pid: '2', - index: '/calendar', - title: '日历', - }, - { - id: '25', - pid: '2', - index: '/watermark', - title: '水印', - }, - { - id: '26', - pid: '2', - index: '/tour', - title: '分布引导', - }, - { - id: '27', - pid: '2', - index: '/steps', - title: '步骤条', - }, - { - id: '28', - pid: '2', - index: '/statistic', - title: '统计', - }, - { - id: '29', - pid: '3', - index: '29', - title: '三级菜单', - children: [ - { - id: '291', - pid: '29', - index: '/editor', - title: '富文本编辑器', - }, - { - id: '292', - pid: '29', - index: '/markdown', - title: 'markdown编辑器', - }, - ], - }, - ], - }, - { - id: '3', - title: '表格', - index: '3', - icon: 'Calendar', - children: [ - { - id: '31', - pid: '3', - index: '/table', - title: '基础表格', - }, - { - id: '32', - pid: '3', - index: '/table-editor', - title: '可编辑表格', - }, - { - id: '33', - pid: '3', - index: '/import', - title: '导入Excel', - }, - { - id: '34', - pid: '3', - index: '/export', - title: '导出Excel', - }, - ], - }, - { - id: '4', - icon: 'PieChart', - index: '4', - title: '图表', - children: [ - { - id: '41', - pid: '4', - index: '/schart', - title: 'schart图表', - }, - { - id: '42', - pid: '4', - index: '/echarts', - title: 'echarts图表', - }, - ], - }, - { - id: '5', - icon: 'Guide', - index: '/icon', - title: '图标', - permiss: '5', - }, - { - id: '7', - icon: 'Brush', - index: '/theme', - title: '主题', - }, - { - id: '6', - icon: 'DocumentAdd', - index: '6', - title: '附加页面', - children: [ - { - id: '61', - pid: '6', - index: '/ucenter', - title: '个人中心', - }, - { - id: '62', - pid: '6', - index: '/login', - title: '登录', - }, - { - id: '63', - pid: '6', - index: '/register', - title: '注册', - }, - { - id: '64', - pid: '6', - index: '/reset-pwd', - title: '重设密码', - }, - { - id: '65', - pid: '6', - index: '/403', - title: '403', - }, - { - id: '66', - pid: '6', - index: '/404', - title: '404', - }, - ], - }, + }, + ], + }, + { + id: "3", + title: "表格", + index: "3", + icon: "Calendar", + children: [ + { + id: "31", + pid: "3", + index: "/table", + title: "基础表格", + }, + { + id: "32", + pid: "3", + index: "/table-editor", + title: "可编辑表格", + }, + { + id: "33", + pid: "3", + index: "/import", + title: "导入Excel", + }, + { + id: "34", + pid: "3", + index: "/export", + title: "导出Excel", + }, + ], + }, + { + id: "4", + icon: "PieChart", + index: "4", + title: "图表", + children: [ + { + id: "41", + pid: "4", + index: "/schart", + title: "schart图表", + }, + { + id: "42", + pid: "4", + index: "/echarts", + title: "echarts图表", + }, + ], + }, + { + id: "5", + icon: "Guide", + index: "/icon", + title: "图标", + permiss: "5", + }, + { + id: "7", + icon: "Brush", + index: "/theme", + title: "主题", + }, + { + id: "6", + icon: "DocumentAdd", + index: "6", + title: "附加页面", + children: [ + { + id: "61", + pid: "6", + index: "/ucenter", + title: "个人中心", + }, + { + id: "62", + pid: "6", + index: "/login", + title: "登录", + }, + { + id: "63", + pid: "6", + index: "/register", + title: "注册", + }, + { + id: "64", + pid: "6", + index: "/reset-pwd", + title: "重设密码", + }, + { + id: "65", + pid: "6", + index: "/403", + title: "403", + }, + { + id: "66", + pid: "6", + index: "/404", + title: "404", + }, + ], + }, ]; diff --git a/src/router/index.ts b/src/router/index.ts index cd6d81c..7d0704f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,293 +1,351 @@ -import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'; -import { usePermissStore } from '../store/permiss'; -import Home from '../views/home.vue'; -import NProgress from 'nprogress'; -import 'nprogress/nprogress.css'; +import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; +import { usePermissStore } from "../store/permiss"; +import Home from "../views/home.vue"; +import NProgress from "nprogress"; +import "nprogress/nprogress.css"; const routes: RouteRecordRaw[] = [ - { - path: '/', - redirect: '/dashboard', - }, - { - path: '/', - name: 'Home', - component: Home, - children: [ - { - path: '/dashboard', - name: 'dashboard', - meta: { - title: '系统首页', - noAuth: true, - }, - component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard.vue'), - }, - { - path: '/system-user', - name: 'system-user', - meta: { - title: '用户管理', - permiss: '11', - }, - component: () => import(/* webpackChunkName: "system-user" */ '../views/system/user.vue'), - }, - { - path: '/system-role', - name: 'system-role', - meta: { - title: '角色管理', - permiss: '12', - }, - component: () => import(/* webpackChunkName: "system-role" */ '../views/system/role.vue'), - }, - { - path: '/system-menu', - name: 'system-menu', - meta: { - title: '菜单管理', - permiss: '13', - }, - component: () => import(/* webpackChunkName: "system-menu" */ '../views/system/menu.vue'), - }, - { - path: '/table', - name: 'basetable', - meta: { - title: '基础表格', - permiss: '31', - }, - component: () => import(/* webpackChunkName: "table" */ '../views/table/basetable.vue'), - }, - { - path: '/table-editor', - name: 'table-editor', - meta: { - title: '可编辑表格', - permiss: '32', - }, - component: () => import(/* webpackChunkName: "table-editor" */ '../views/table/table-editor.vue'), - }, - { - path: '/schart', - name: 'schart', - meta: { - title: 'schart图表', - permiss: '41', - }, - component: () => import(/* webpackChunkName: "schart" */ '../views/chart/schart.vue'), - }, - { - path: '/echarts', - name: 'echarts', - meta: { - title: 'echarts图表', - permiss: '42', - }, - component: () => import(/* webpackChunkName: "echarts" */ '../views/chart/echarts.vue'), - }, + { + path: "/", + redirect: "/dashboard", + }, + { + path: "/", + name: "Home", + component: Home, + children: [ + { + path: "/dashboard", + name: "dashboard", + meta: { + title: "系统首页", + }, + component: () => + import(/* webpackChunkName: "dashboard" */ "../views/dashboard.vue"), + }, + { + path: "/system-user", + name: "system-user", + meta: { + title: "用户管理", + permiss: "11", + }, + component: () => + import( + /* webpackChunkName: "system-user" */ "../views/system/user.vue" + ), + }, + { + path: "/system-role", + name: "system-role", + meta: { + title: "角色管理", + permiss: "12", + }, + component: () => + import( + /* webpackChunkName: "system-role" */ "../views/system/role.vue" + ), + }, + { + path: "/system-menu", + name: "system-menu", + meta: { + title: "菜单管理", + permiss: "13", + }, + component: () => + import( + /* webpackChunkName: "system-menu" */ "../views/system/menu.vue" + ), + }, + { + path: "/table", + name: "basetable", + meta: { + title: "基础表格", + permiss: "31", + }, + component: () => + import( + /* webpackChunkName: "table" */ "../views/table/basetable.vue" + ), + }, + { + path: "/table-editor", + name: "table-editor", + meta: { + title: "可编辑表格", + permiss: "32", + }, + component: () => + import( + /* webpackChunkName: "table-editor" */ "../views/table/table-editor.vue" + ), + }, + { + path: "/schart", + name: "schart", + meta: { + title: "schart图表", + permiss: "41", + }, + component: () => + import(/* webpackChunkName: "schart" */ "../views/chart/schart.vue"), + }, + { + path: "/echarts", + name: "echarts", + meta: { + title: "echarts图表", + permiss: "42", + }, + component: () => + import( + /* webpackChunkName: "echarts" */ "../views/chart/echarts.vue" + ), + }, - { - path: '/icon', - name: 'icon', - meta: { - title: '图标', - permiss: '5', - }, - component: () => import(/* webpackChunkName: "icon" */ '../views/pages/icon.vue'), - }, - { - path: '/ucenter', - name: 'ucenter', - meta: { - title: '个人中心', - }, - component: () => import(/* webpackChunkName: "ucenter" */ '../views/pages/ucenter.vue'), - }, - { - path: '/editor', - name: 'editor', - meta: { - title: '富文本编辑器', - permiss: '291', - }, - component: () => import(/* webpackChunkName: "editor" */ '../views/pages/editor.vue'), - }, - { - path: '/markdown', - name: 'markdown', - meta: { - title: 'markdown编辑器', - permiss: '292', - }, - component: () => import(/* webpackChunkName: "markdown" */ '../views/pages/markdown.vue'), - }, - { - path: '/export', - name: 'export', - meta: { - title: '导出Excel', - permiss: '34', - }, - component: () => import(/* webpackChunkName: "export" */ '../views/table/export.vue'), - }, - { - path: '/import', - name: 'import', - meta: { - title: '导入Excel', - permiss: '33', - }, - component: () => import(/* webpackChunkName: "import" */ '../views/table/import.vue'), - }, - { - path: '/theme', - name: 'theme', - meta: { - title: '主题设置', - permiss: '7', - }, - component: () => import(/* webpackChunkName: "theme" */ '../views/pages/theme.vue'), - }, - { - path: '/calendar', - name: 'calendar', - meta: { - title: '日历', - permiss: '24', - }, - component: () => import(/* webpackChunkName: "calendar" */ '../views/element/calendar.vue'), - }, - { - path: '/watermark', - name: 'watermark', - meta: { - title: '水印', - permiss: '25', - }, - component: () => import(/* webpackChunkName: "watermark" */ '../views/element/watermark.vue'), - }, - { - path: '/carousel', - name: 'carousel', - meta: { - title: '走马灯', - permiss: '23', - }, - component: () => import(/* webpackChunkName: "carousel" */ '../views/element/carousel.vue'), - }, - { - path: '/tour', - name: 'tour', - meta: { - title: '分步引导', - permiss: '26', - }, - component: () => import(/* webpackChunkName: "tour" */ '../views/element/tour.vue'), - }, - { - path: '/steps', - name: 'steps', - meta: { - title: '步骤条', - permiss: '27', - }, - component: () => import(/* webpackChunkName: "steps" */ '../views/element/steps.vue'), - }, - { - path: '/form', - name: 'forms', - meta: { - title: '表单', - permiss: '21', - }, - component: () => import(/* webpackChunkName: "form" */ '../views/element/form.vue'), - }, - { - path: '/upload', - name: 'upload', - meta: { - title: '上传', - permiss: '22', - }, - component: () => import(/* webpackChunkName: "upload" */ '../views/element/upload.vue'), - }, - { - path: '/statistic', - name: 'statistic', - meta: { - title: '统计', - permiss: '28', - }, - component: () => import(/* webpackChunkName: "statistic" */ '../views/element/statistic.vue'), - }, - ], - }, - { - path: '/login', + { + path: "/icon", + name: "icon", meta: { - title: '登录', - noAuth: true, + title: "图标", + permiss: "5", }, - component: () => import(/* webpackChunkName: "login" */ '../views/pages/login.vue'), - }, - { - path: '/register', + component: () => + import(/* webpackChunkName: "icon" */ "../views/pages/icon.vue"), + }, + { + path: "/ucenter", + name: "ucenter", meta: { - title: '注册', - noAuth: true, + title: "个人中心", }, - component: () => import(/* webpackChunkName: "register" */ '../views/pages/register.vue'), - }, - { - path: '/reset-pwd', + component: () => + import( + /* webpackChunkName: "ucenter" */ "../views/pages/ucenter.vue" + ), + }, + { + path: "/editor", + name: "editor", meta: { - title: '重置密码', - noAuth: true, + title: "富文本编辑器", + permiss: "291", }, - component: () => import(/* webpackChunkName: "reset-pwd" */ '../views/pages/reset-pwd.vue'), - }, - { - path: '/403', + component: () => + import(/* webpackChunkName: "editor" */ "../views/pages/editor.vue"), + }, + { + path: "/markdown", + name: "markdown", meta: { - title: '没有权限', - noAuth: true, + title: "markdown编辑器", + permiss: "292", }, - component: () => import(/* webpackChunkName: "403" */ '../views/pages/403.vue'), - }, - { - path: '/404', + component: () => + import( + /* webpackChunkName: "markdown" */ "../views/pages/markdown.vue" + ), + }, + { + path: "/export", + name: "export", meta: { - title: '找不到页面', - noAuth: true, + title: "导出Excel", + permiss: "34", }, - component: () => import(/* webpackChunkName: "404" */ '../views/pages/404.vue'), + component: () => + import(/* webpackChunkName: "export" */ "../views/table/export.vue"), + }, + { + path: "/import", + name: "import", + meta: { + title: "导入Excel", + permiss: "33", + }, + component: () => + import(/* webpackChunkName: "import" */ "../views/table/import.vue"), + }, + { + path: "/theme", + name: "theme", + meta: { + title: "主题设置", + permiss: "7", + }, + component: () => + import(/* webpackChunkName: "theme" */ "../views/pages/theme.vue"), + }, + { + path: "/calendar", + name: "calendar", + meta: { + title: "日历", + permiss: "24", + }, + component: () => + import( + /* webpackChunkName: "calendar" */ "../views/element/calendar.vue" + ), + }, + { + path: "/watermark", + name: "watermark", + meta: { + title: "水印", + permiss: "25", + }, + component: () => + import( + /* webpackChunkName: "watermark" */ "../views/element/watermark.vue" + ), + }, + { + path: "/carousel", + name: "carousel", + meta: { + title: "走马灯", + permiss: "23", + }, + component: () => + import( + /* webpackChunkName: "carousel" */ "../views/element/carousel.vue" + ), + }, + { + path: "/tour", + name: "tour", + meta: { + title: "分步引导", + permiss: "26", + }, + component: () => + import(/* webpackChunkName: "tour" */ "../views/element/tour.vue"), + }, + { + path: "/steps", + name: "steps", + meta: { + title: "步骤条", + permiss: "27", + }, + component: () => + import(/* webpackChunkName: "steps" */ "../views/element/steps.vue"), + }, + { + path: "/form", + name: "forms", + meta: { + title: "表单", + permiss: "21", + }, + component: () => + import(/* webpackChunkName: "form" */ "../views/element/form.vue"), + }, + { + path: "/upload", + name: "upload", + meta: { + title: "上传", + permiss: "22", + }, + component: () => + import( + /* webpackChunkName: "upload" */ "../views/element/upload.vue" + ), + }, + { + path: "/statistic", + name: "statistic", + meta: { + title: "统计", + permiss: "28", + }, + component: () => + import( + /* webpackChunkName: "statistic" */ "../views/element/statistic.vue" + ), + }, + ], + }, + { + path: "/login", + meta: { + title: "登录", + noAuth: true, }, - { path: '/:path(.*)', redirect: '/404' }, + component: () => + import(/* webpackChunkName: "login" */ "../views/pages/login.vue"), + }, + { + path: "/register", + meta: { + title: "注册", + noAuth: true, + }, + component: () => + import(/* webpackChunkName: "register" */ "../views/pages/register.vue"), + }, + { + path: "/reset-pwd", + meta: { + title: "重置密码", + noAuth: true, + }, + component: () => + import( + /* webpackChunkName: "reset-pwd" */ "../views/pages/reset-pwd.vue" + ), + }, + { + path: "/403", + meta: { + title: "没有权限", + noAuth: true, + }, + component: () => + import(/* webpackChunkName: "403" */ "../views/pages/403.vue"), + }, + { + path: "/404", + meta: { + title: "找不到页面", + noAuth: true, + }, + component: () => + import(/* webpackChunkName: "404" */ "../views/pages/404.vue"), + }, + { path: "/:path(.*)", redirect: "/404" }, ]; const router = createRouter({ - history: createWebHashHistory(), - routes, + history: createWebHashHistory(), + routes, }); router.beforeEach((to, from, next) => { - NProgress.start(); - const role = localStorage.getItem('vuems_name'); - const permiss = usePermissStore(); + NProgress.start(); + const role = localStorage.getItem("vuems_name"); + const permiss = usePermissStore(); - if (!role && to.meta.noAuth !== true) { - next('/login'); - } else if (typeof to.meta.permiss == 'string' && !permiss.key.includes(to.meta.permiss)) { - // 如果没有权限,则进入403 - next('/403'); - } else { - next(); - } + if (!role && to.meta.noAuth !== true) { + next("/login"); + } else if ( + typeof to.meta.permiss == "string" && + !permiss.key.includes(to.meta.permiss) + ) { + // 如果没有权限,则进入403 + next("/403"); + } else { + next(); + } }); router.afterEach(() => { - NProgress.done(); + NProgress.done(); }); export default router;