From 6b0bb852120f09aadaec3d96a73b0d626b2e3007 Mon Sep 17 00:00:00 2001 From: wuhongjian Date: Sat, 16 Jul 2022 15:04:25 +0800 Subject: [PATCH 1/2] =?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 --- front/public/index.html | 6 +- front/src/utils/request.js | 5 +- front/src/vab/plugins/permissions.js | 96 ++-- .../components/PutOnTheShelf.vue | 450 +++++++++--------- .../ApplicationDeploymentAndSecurity.vue | 5 - .../views/personalCenter/VueTemplateDemo.vue | 36 +- .../components/PurchaseVehicle.vue | 61 ++- 7 files changed, 349 insertions(+), 310 deletions(-) diff --git a/front/public/index.html b/front/public/index.html index 040ff813..90bd3425 100644 --- a/front/public/index.html +++ b/front/public/index.html @@ -1,8 +1,8 @@ @@ -46,7 +46,7 @@ // window.SITE_CONFIG['frontUrl'] = 'http://10.134.135.9:9796/document/#/devModelFile/'; // window.SITE_CONFIG['apiURL'] = 'http://10.134.135.9:8888/renren-admin'; // 开发 - window.SITE_CONFIG['backUrl'] = 'http://15.2.21.238:9797'; + window.SITE_CONFIG['backUrl'] = 'http://localhost:8001'; window.SITE_CONFIG['previewUrl'] = 'http://15.2.21.238:9796/'; window.SITE_CONFIG['frontUrl'] = 'http://15.2.21.238:9796/document/#/devModelFile/'; window.SITE_CONFIG['apiURL'] = 'http://15.2.21.238:8888/renren-admin'; diff --git a/front/src/utils/request.js b/front/src/utils/request.js index 0f02346e..b51e88b3 100644 --- a/front/src/utils/request.js +++ b/front/src/utils/request.js @@ -74,8 +74,7 @@ instance.interceptors.request.use( (config) => { debugger const token = getAccessToken() - if (token) - config.headers[tokenName] = token + if (token) config.headers[tokenName] = token if ( config.data && config.headers['Content-Type'] === @@ -105,7 +104,7 @@ instance.interceptors.response.use( response['Access-Control-Expose-Headers'] = 'redirect' const { code, message } = response.data debugger - if (code=='0' && response.headers.token) { + if (code == '0' && response.headers.token) { setAccessToken(response.headers.token) } else { const token = getAccessToken() diff --git a/front/src/vab/plugins/permissions.js b/front/src/vab/plugins/permissions.js index 6139bd4b..f52e9f30 100644 --- a/front/src/vab/plugins/permissions.js +++ b/front/src/vab/plugins/permissions.js @@ -2,65 +2,65 @@ * @Author: hisense.wuhongjian * @Date: 2022-04-01 17:23:11 * @LastEditors: hisense.wuhongjian - * @LastEditTime: 2022-07-11 16:39:36 + * @LastEditTime: 2022-07-16 10:57:59 * @Description: 告诉大家这是什么 */ /** * @author chuzhixin 1204505056@qq.com * @description 路由守卫,目前两种模式:all模式与intelligence模式 */ - import router from '@/router' - import store from '@/store' - import getPageTitle from '@/utils/pageTitle' - import { getUserInfo } from '@/api/user' - import { - // authentication, - loginInterception, - // recordRoute, - routesWhiteList, - } from '@/config' - import { setAccessToken, getAccessToken } from '@/utils/accessToken' - router.beforeEach(async (to, from, next) => { - // debugger - // const SSOTOKEN = to.query.SSOToken - // if (SSOTOKEN) { - // setAccessToken(SSOTOKEN) - // } - const token = getAccessToken() - console.log('token', token) - let hasToken = token || store.getters['user/accessToken'] - // debugger - if (!loginInterception) hasToken = true - console.log('hasToken存在巨大问题', hasToken) - if (hasToken) { +import router from '@/router' +import store from '@/store' +import getPageTitle from '@/utils/pageTitle' +import { getUserInfo } from '@/api/user' +import { + // authentication, + loginInterception, + // recordRoute, + routesWhiteList, +} from '@/config' +import { setAccessToken, getAccessToken } from '@/utils/accessToken' +router.beforeEach(async (to, from, next) => { + // debugger + // const SSOTOKEN = to.query.SSOToken + // if (SSOTOKEN) { + // setAccessToken(SSOTOKEN) + // } + const token = getAccessToken() + console.log('token', token) + let hasToken = token || store.getters['user/accessToken'] + // debugger + if (!loginInterception) hasToken = true + console.log('hasToken存在巨大问题', hasToken) + if (hasToken) { // setAccessToken(hasToken) - await store.dispatch('user/getUserInfo') - debugger - next() - } else { - let accessRoutes = [] - accessRoutes = await store.dispatch('routes/setRoutes') - accessRoutes.forEach((item) => { - router.addRoute(item) - }) - if (routesWhiteList.indexOf(to.path) !== -1) { - next() - } else { + await store.dispatch('user/getUserInfo') + debugger + next() + } else { + let accessRoutes = [] + accessRoutes = await store.dispatch('routes/setRoutes') + accessRoutes.forEach((item) => { + router.addRoute(item) + }) + if (routesWhiteList.indexOf(to.path) !== -1) { + next() + } else { // 这里是一个单点登录的入口 - getUserInfo().then(res=>{ + getUserInfo().then((res) => { console.log(res) router.replace('/home') }) // await store.dispatch('user/getUserInfo') // next() - // if (recordRoute) - // next({ path: '/login', query: { redirect: to.path }, replace: true }) - // else next({ path: '/login', replace: true }) + // if (recordRoute) + // next({ path: '/login', query: { redirect: to.path }, replace: true }) + // else next({ path: '/login', replace: true }) // next() - // window.open('http://www.baidu.com', '_self') - } - } - }) - router.afterEach((to) => { - document.title = getPageTitle(to.meta.title) - }) + // window.open('http://www.baidu.com', '_self') + } + } +}) +router.afterEach((to) => { + document.title = getPageTitle(to.meta.title) +}) diff --git a/front/src/views/capacityOnTheShelf/components/PutOnTheShelf.vue b/front/src/views/capacityOnTheShelf/components/PutOnTheShelf.vue index 742dc973..dbed1200 100644 --- a/front/src/views/capacityOnTheShelf/components/PutOnTheShelf.vue +++ b/front/src/views/capacityOnTheShelf/components/PutOnTheShelf.vue @@ -1,8 +1,8 @@