From e205bd5b51c89a5c6633cd4fa68cdf3b0f97d9d3 Mon Sep 17 00:00:00 2001 From: dusheng <582200563@qq.com> Date: Tue, 7 Nov 2023 10:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=99=BB=E9=99=86=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/App/AppHeader/index.vue | 3 +++ src/router/index.js | 6 ++++++ src/views/login.vue | 20 ++++++++++++++++++++ vue.config.js | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/App/AppHeader/index.vue b/src/components/App/AppHeader/index.vue index 33bf9d7..adbb592 100644 --- a/src/components/App/AppHeader/index.vue +++ b/src/components/App/AppHeader/index.vue @@ -63,6 +63,9 @@ export default { }) .then(() => { this.$store.dispatch("user/setUserAuth", []); + + localStorage.removeItem("userInfo"); + localStorage.removeItem("userAuth"); this.$router.replace("/login"); }) .catch(() => {}); diff --git a/src/router/index.js b/src/router/index.js index fcc95a6..01de8af 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -98,6 +98,12 @@ const router = new VueRouter({ }); router.beforeEach((to, from, next) => { + let storeAuth = localStorage.getItem("userAuth"); + let storeUserInfo = localStorage.getItem("userInfo"); + + store.dispatch("user/setUserAuth", JSON.parse(storeAuth)); + store.dispatch("user/setUserInfo", JSON.parse(storeUserInfo)); + let userAuth = store.state.user.userAuth; // console.log(to, userAuth); if (to.meta.keepAlive) { diff --git a/src/views/login.vue b/src/views/login.vue index 3e697f9..5db3921 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -127,6 +127,14 @@ export default { name: "鍒樹簯", type: 1, }); + localStorage.setItem("userAuth", JSON.stringify(this.testAuthUser)); + localStorage.setItem( + "userInfo", + JSON.stringify({ + name: "鍒樹簯", + type: 1, + }) + ); this.$message.success("鐧婚檰鎴愬姛"); this.$nextTick(() => { this.$router.replace({ @@ -141,6 +149,18 @@ export default { name: "閲嶅簡浼熸槦鏂板瀷寤烘潗鏈夐檺鍏徃", type: 2, }); + + localStorage.setItem( + "userAuth", + JSON.stringify(this.testAuthEnterprise) + ); + localStorage.setItem( + "userInfo", + JSON.stringify({ + name: "閲嶅簡浼熸槦鏂板瀷寤烘潗鏈夐檺鍏徃", + type: 2, + }) + ); this.$message.success("鐧婚檰鎴愬姛"); this.$nextTick(() => { this.$router.replace({ diff --git a/vue.config.js b/vue.config.js index d0c0fba..ce7a925 100644 --- a/vue.config.js +++ b/vue.config.js @@ -2,7 +2,7 @@ const path = require("path"); // const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; module.exports = { - publicPath: "./", + publicPath: "/admin/", lintOnSave: process.env.NODE_ENV === "development", productionSourceMap: false, devServer: { -- GitLab