From 225c1ce1ef3b98db0cbc2f2b545f39624706249f Mon Sep 17 00:00:00 2001 From: Eddie <102564160@qq.com> Date: Wed, 11 Aug 2021 15:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BC=82=E6=AD=A5toen=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5=E5=90=8E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AdminInfoDialog/index.vue | 267 ++++++++++++----------- src/layout/components/Navbar.vue | 9 +- src/permission.js | 8 +- src/utils/request.js | 10 +- 4 files changed, 154 insertions(+), 140 deletions(-) diff --git a/src/components/AdminInfoDialog/index.vue b/src/components/AdminInfoDialog/index.vue index e88de25..5f18818 100644 --- a/src/components/AdminInfoDialog/index.vue +++ b/src/components/AdminInfoDialog/index.vue @@ -6,15 +6,17 @@ '--dialog-width': '807px', '--dialog-height': '543px', '--title-height': '51px', - '--footer-height': '62px' + '--footer-height': '62px', }" @close-dialog="handleClose" > -
+
@@ -35,12 +37,15 @@ {{ adminInfo.phone | maskPhone }}
- + - + - + - + - + @@ -81,164 +95,166 @@ diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index f0238e9..f1e5a35 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -63,6 +63,7 @@ import { maskPhone } from '@/filters' // import SizeSelect from '@/components/SizeSelect' // import LangSelect from '@/components/LangSelect' // import Search from '@/components/HeaderSearch' +import { removeToken } from '@/utils/auth' export default { components: { @@ -89,8 +90,14 @@ export default { this.$store.dispatch('app/toggleSideBar') }, async logout() { - await this.$store.dispatch('user/logout') + + + // await this.$store.dispatch('user/logout') + removeToken() + this.$router.push(`/login?redirect=${this.$route.fullPath}`) + + }, showAdminEditDialog() { this.$store.dispatch('admin-info/initAdminInfo', true) diff --git a/src/permission.js b/src/permission.js index 5df1f42..507d46c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -20,9 +20,7 @@ router.beforeEach(async (to, from, next) => { // determine whether the user has logged in const hasToken = getToken() - console.log(hasToken) - - if ( hasToken) { + if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page next({ path: '/' }) @@ -71,8 +69,8 @@ router.beforeEach(async (to, from, next) => { NProgress.done() } } - - + + }) diff --git a/src/utils/request.js b/src/utils/request.js index 04cb9d6..5682252 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -18,14 +18,8 @@ service.interceptors.request.use( // do something before request is sent config.headers['Content-Type'] = 'application/x-www-form-urlencoded'; - if (store.getters.token) { - - console.log(getToken()) - // let each request carry token - // ['X-Token'] is a custom headers key - // please modify it according to the actual situation - config.headers['api-token'] = getToken() - } + config.headers['api-token'] = getToken() || '' + return config }, error => {