From e97096ffbc2de867a766bb646b38150723fe3a2b Mon Sep 17 00:00:00 2001 From: xiaoguang Date: Tue, 17 May 2022 10:58:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=BB=E6=8E=89=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E9=92=A9=E5=AD=90=E5=86=85=E6=9C=AA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B7=B3=E8=BD=AC=E9=A1=B5=E9=9D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/router.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/plugins/router.js b/plugins/router.js index 805547e..5bde2fa 100644 --- a/plugins/router.js +++ b/plugins/router.js @@ -1,21 +1,13 @@ export default ({ app }) => { app.router.beforeEach((to, from, next) => { - // const { token, userInfo } = app.store.state; - // if (token) { - // if (Object.keys(userInfo).length === 0) { - // app.store.dispatch("getUserInfo"); - // } - // next(); - // return; - // } - - // // 未登录打开需要登录的页面,跳首页 - // const needLoginPage = [/\/account/, /\/cart/]; - // const result = needLoginPage.some((item) => item.test(to.path)); - // if (result) { - // next("/"); - // return; - // } + const { token, userInfo } = app.store.state; + if (token) { + if (Object.keys(userInfo).length === 0) { + app.store.dispatch("getUserInfo"); + } + next(); + return; + } next(); }); };