From 1416849fe954eebf5278fe2e8f73a6547ae732b4 Mon Sep 17 00:00:00 2001 From: huangzhen Date: Thu, 12 Sep 2024 18:28:59 +0800 Subject: [PATCH] =?UTF-8?q?update=20@home=E9=A1=B5=20key=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 3 +++ src/views/home.vue | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 4da9566..47c33df 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -74,6 +74,9 @@ router.beforeEach(async (to, from, next) => { localStorage.setItem("key", strP || ""); next({ path: "/home", + query: { + key: strP || "", + } }); } else { next(); diff --git a/src/views/home.vue b/src/views/home.vue index 78b1e2b..6605cf4 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -12,10 +12,10 @@ export default { name: 'home', data() { return { - key: localStorage.getItem('key'), + key: this.$route.query.key || localStorage.getItem("openid") || '', loginBack: this.$route.query.loginBack, // jumpPath: this.$route.query.jumpPath, - openid: this.$route.query.openid || localStorage.getItem("openid"), // 微信授权id + openid: this.$route.query.openid || localStorage.getItem("openid") || '', // 微信授权id isAutoEmpower: true, loadingText: '加载中', dialogType: '', @@ -31,6 +31,8 @@ export default { if (!this.loginBack) { sessionStorage.clear(); localStorage.clear(); + this.key && localStorage.setItem("token", this.key); + this.openid && localStorage.setItem("openid", this.openid); this.preLogic(); } else { this.dialogText = 'Token已过期'; @@ -42,7 +44,6 @@ export default { if (res && res.code === 200) { if (res.data.Token) { localStorage.setItem("token", res.data.Token || ''); - localStorage.setItem("key", this.key || ''); // sessionStorage.setItem("jumpPath", this.jumpPath || ''); // 复制链接-直接跳转详情页(暂时不用) // 微信环境 自动授权