From 984fb1bb082b56c87388481879953bba7c548b67 Mon Sep 17 00:00:00 2001 From: sc Date: Sat, 16 Oct 2021 17:08:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=A8=A1=E5=9D=97=E6=89=81?= =?UTF-8?q?=E5=B9=B3=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UP --- src/api/model/system.js | 2 +- src/config/index.js | 3 +++ src/layout/components/tags.vue | 18 +++++++++++--- src/layout/components/topbar.vue | 4 ++-- src/layout/index.vue | 29 ++++++++++++++++------- src/router/index.js | 36 +++++++++++++++++++++++++--- src/router/systemRouter.js | 40 +++++--------------------------- src/store/modules/keepAlive.js | 4 ++-- src/views/other/404.vue | 4 ++++ src/views/other/empty.vue | 19 ++------------- src/views/userCenter/login.vue | 8 +++++++ 11 files changed, 97 insertions(+), 70 deletions(-) diff --git a/src/api/model/system.js b/src/api/model/system.js index 8ea4e27d..1a3381fa 100644 --- a/src/api/model/system.js +++ b/src/api/model/system.js @@ -4,7 +4,7 @@ import http from "@/utils/request" export default { menu: { myMenus: { - url: `${config.API_URL}/system/menu/my/1.2.8`, + url: `${config.API_URL}/system/menu/my/dev`, name: "获取我的菜单", get: async function(){ return await http.get(this.url); diff --git a/src/config/index.js b/src/config/index.js index 096eacdb..a07b3571 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -2,6 +2,9 @@ const DEFAULT_CONFIG = { //标题 APP_NAME: "SCUI", + //首页地址 + DASHBOARD_URL: "/dashboard", + //版本号 APP_VER: "1.2.7", diff --git a/src/layout/components/tags.vue b/src/layout/components/tags.vue index f6755119..732f7862 100644 --- a/src/layout/components/tags.vue +++ b/src/layout/components/tags.vue @@ -67,16 +67,28 @@ } }, created() { - const dashboardRoute = this.$router.options.routes[0].children[0].children[0] + var menu = this.$TOOL.data.get("MENU") + var dashboardRoute = this.treeFind(menu, node => node.path==this.$CONFIG.DASHBOARD_URL) dashboardRoute.fullPath = dashboardRoute.path - this.addViewTags(dashboardRoute); - this.addViewTags(this.$route); + this.addViewTags(dashboardRoute) + this.addViewTags(this.$route) }, mounted() { this.tagDrop(); this.scrollInit() }, methods: { + //查找树 + treeFind(tree, func){ + for (const data of tree) { + if (func(data)) return data + if (data.children) { + const res = this.treeFind(data.children, func) + if (res) return res + } + } + return null + }, //标签拖拽排序 tagDrop(){ const target = this.$refs.tags diff --git a/src/layout/components/topbar.vue b/src/layout/components/topbar.vue index c2d590f1..f76e4e6b 100644 --- a/src/layout/components/topbar.vue +++ b/src/layout/components/topbar.vue @@ -6,7 +6,7 @@ - \ No newline at end of file diff --git a/src/views/userCenter/login.vue b/src/views/userCenter/login.vue index 1725c188..63f26f3e 100644 --- a/src/views/userCenter/login.vue +++ b/src/views/userCenter/login.vue @@ -174,6 +174,14 @@ menu = await this.$API.demo.menu.get() } if(menu.code == 200){ + if(menu.data.menu.length==0){ + this.islogin = false + this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", { + type: 'error', + center: true + }) + return false + } this.$TOOL.data.set("MENU", menu.data.menu) this.$TOOL.data.set("PERMISSIONS", menu.data.permissions) }else{