From edb28f7cac90201b0b06cdbf9a38601b42211534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=B4=87=E6=A0=8B?= <786631302qq.com> Date: Mon, 24 Aug 2020 11:56:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth.json | 10 +++ public/index.html | 4 +- src/App.vue | 33 +++++++++ src/components/common/the-header.vue | 9 ++- src/plugins/antd.js | 4 +- src/plugins/axios/axios.js | 17 +++-- src/router/index.js | 71 +++++++++--------- src/utils/index.js | 17 +++++ src/views/history/api/history-api.js | 8 ++- src/views/history/index.vue | 104 ++++++++++++++++++++------- src/views/login.vue | 66 ++++++++++++++++- vue.config.js | 2 +- 12 files changed, 274 insertions(+), 71 deletions(-) create mode 100644 auth.json diff --git a/auth.json b/auth.json new file mode 100644 index 0000000..f3038e2 --- /dev/null +++ b/auth.json @@ -0,0 +1,10 @@ +{ + "description": "昆船随行垛机检测系统", + "type": -1, + "rights": "duojiSystem", + "children": [{ + "description": "历史监控", + "type": 2, + "rights": "history" + }] +} diff --git a/public/index.html b/public/index.html index c4c824a..fcb9862 100644 --- a/public/index.html +++ b/public/index.html @@ -6,12 +6,12 @@ - 垛机监控系统 + 昆船随行式垛机监测系统
diff --git a/src/App.vue b/src/App.vue index bcfbd85..c03d2b8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,6 +4,39 @@ + + \ No newline at end of file diff --git a/src/views/login.vue b/src/views/login.vue index e2a3ebe..85d958f 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -19,7 +19,7 @@ -
垛机监控系统
+
昆船随行式垛机监测系统
@@ -76,7 +76,69 @@ export default { } } }, - mounted() {} + beforeRouteEnter(to, from, next) { + if (location.search) { + let action = window.location.search.substring( + window.location.search.indexOf("=") + 1 + ); + if (action === "logout") { + localStorage.clear(); + sessionStorage.clear(); + } + next(); + } else { + if (localStorage.getItem("userInfo")) { + next(vm => { + let permissionList = JSON.parse( + localStorage.getItem("userInfo") + ).permissionList; + let router = vm.$router.options.routes[0].children; + if ( + !location.search && + !permissionList.some(item => item.type === 2) + ) { + vm.$message.info("没权限", 1, () => { + vm.$api({ + url: "/app/userCenter", + method: "GET" + }).then(res => { + window.open( + res.url + "?redirect=" + location.origin, + "_self" + ); + }); + }); + return; + } + for (let item of router) { + if ( + permissionList.some(a => { + if (a.rights === item.name && a.type === 2) + return true; + }) + ) { + vm.$router.push({ name: item.name }); + return; + } + } + }); + } else { + if (!location.search) { + next(vm => { + vm.$api({ + url: "/app/userCenter", + method: "GET" + }).then(res => { + window.open( + res.url + "?redirect=" + location.origin, + "_self" + ); + }); + }); + } + } + } + } };