From d04215ea7783dd9a893529e2cdc5ae7bd696abf0 Mon Sep 17 00:00:00 2001 From: hezidan <2033098269@qq.com> Date: Fri, 29 Mar 2024 17:34:33 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 9 +++++---- src/router/index.js | 2 +- src/views/fapiao/Fapiao.vue | 7 +++++++ src/views/fapiao/edit.vue | 28 ++++++++++++++++++---------- src/views/login.vue | 2 +- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main.js b/src/main.js index 348c7bb..6d93581 100644 --- a/src/main.js +++ b/src/main.js @@ -36,8 +36,9 @@ Object.keys(custom).forEach(key => { // 路由拦截器 router.beforeEach((to, from, next) => { if (to.matched.length != 0) { - if (to.meta.requireAuth) { // 判断该路由是否需要登录权限 - if (Boolean(localStorage.getItem("userInfo"))) { // 通过vuex state获取当前的user是否存在 + if (to.meta.requireAuth) { // 判断该路由是否需要登录权限 + console.log(Boolean(localStorage.getItem("userInfo"))) + if (Boolean(localStorage.getItem("userInfo"))) { // 通过vuex state获取当前的user是否存在 next(); } else { next({ @@ -46,8 +47,8 @@ router.beforeEach((to, from, next) => { }) } } else { - if (Boolean(localStorage.getItem("userInfo"))) { // 判断是否登录 - if (to.path != "/" && to.path != "/login") { //判断是否要跳到登录界面 + if (Boolean(localStorage.getItem("userInfo"))) { // 判断是否登录 + if (to.path == "/" || to.path == "/login") { //判断是否要跳到登录界面 next(); } else { /** diff --git a/src/router/index.js b/src/router/index.js index c24f2b4..471cd67 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -46,7 +46,7 @@ export default new Router({ { path: '/login', - name: '登录', + name: 'login', component: login, hidden: true, meta: { diff --git a/src/views/fapiao/Fapiao.vue b/src/views/fapiao/Fapiao.vue index 9521d7c..4068257 100644 --- a/src/views/fapiao/Fapiao.vue +++ b/src/views/fapiao/Fapiao.vue @@ -219,6 +219,10 @@ export default { FapiaoList(parameter) .then(res => { this.loading = false + console.log(res) + if(res.code==null){ + this.$router.push({ name: 'login' });//跳转到查询界面 + } if (res.code!=0) { this.$message({ type: 'info', @@ -277,6 +281,9 @@ export default { this.loading = false FapiaoSave(this.editForm) .then(res => { + if(res.code==null){ + this.$router.push({ name: 'login' });//跳转到查询界面 + } this.editFormVisible = false this.loading = false console.log(res.success) diff --git a/src/views/fapiao/edit.vue b/src/views/fapiao/edit.vue index bfccfec..356aa37 100644 --- a/src/views/fapiao/edit.vue +++ b/src/views/fapiao/edit.vue @@ -1,5 +1,5 @@