Compare commits

...

2 Commits

5 changed files with 37 additions and 49 deletions

View File

@ -2,16 +2,16 @@
* @Author: hisense.wuhongjian
* @Date: 2022-08-25 14:37:49
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-08-27 14:25:39
* @LastEditTime: 2022-10-12 13:40:14
* @Description: 告诉大家这是什么
*/
var _global = {}
var CONFIGITEM = {
// version: 'qingdao', // 青岛
version: 'xihaian', // 西海岸
// version: 'xihaian', // 西海岸
// version: 'test', // 测试
// version: 'frp', // 内网穿透
// version: 'dev', // 开发
version: 'dev', // 开发
vNum: 'v0.8.7.2',
configData: {
// 青岛市大数据局

View File

@ -1,15 +1,15 @@
/*
* @Author: hisense.wuhongjian
* @Date: 2020-07-07 16:03:23
* @LastEditors: hisense.liangjunhua
* @LastEditTime: 2022-09-19 09:36:49
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-10-11 10:46:03
* @Description: 系统静态参数配置
*/
var _global = {}
var CONFIGITEM = {
// version: 'qingdao', //
version: 'xihaian', // 西
// version: 'dev', //
//version: 'xihaian', // 西
version: 'dev', //
// version: 'zhanTingDev', // dev (2022-09-13:)
//version: 'test', //
//version: 'frp', // 穿

View File

@ -126,16 +126,16 @@ const actions = {
* @returns
*/
async getUserInfo({ commit }) {
const { data } = await getUserInfo()
if (!data) {
const res = await getUserInfo()
if (!res || !res.data) {
message.error(`验证失败,请重新登录...`)
return false
}
// debugger
commit('setUsername', data.data.username)
commit('setRealname', data.data.realName)
commit('setRole', data.data.roleIdList.length)
commit('setUserId', data.data.id)
commit('setUsername', res.data.data.username)
commit('setRealname', res.data.data.realName)
commit('setRole', res.data.data.roleIdList.length)
commit('setUserId', res.data.data.id)
// TODO
// let { username, avatar, roles, ability } = data
// if (username && roles && Array.isArray(roles)) {
@ -168,6 +168,7 @@ const actions = {
* @param {*} { commit, dispatch }
*/
async resetAll({ dispatch }) {
debugger
await dispatch('setAccessToken', '')
await dispatch('acl/setFull', false, {
root: true,

View File

@ -11,14 +11,8 @@ import store from '@/store'
import qs from 'qs'
import router from '@/router'
// import { isArray } from '@/utils/validate'
import {
message
} from 'ant-design-vue'
import {
getAccessToken,
setAccessToken
} from '@/utils/accessToken'
import { message } from 'ant-design-vue'
import { getAccessToken, setAccessToken } from '@/utils/accessToken'
let loadingInstance
@ -36,9 +30,11 @@ const handleCode = (code, msg, res) => {
store.dispatch('user/resetAll').catch(() => {})
break
case 403:
router.push({
path: '/401'
}).catch(() => { })
router
.push({
path: '/401',
})
.catch(() => {})
break
case 500:
message.error(msg || '接口异常')
@ -103,17 +99,14 @@ instance.interceptors.response.use(
console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect)
response['Access-Control-Expose-Headers'] = 'redirect'
const {
code,
message
} = response.data
const { code, message } = response.data
if (response.headers.token) {
setAccessToken(response.headers.token)
}
if (response.headers.redirect) {
const _old_href = window.location.href.split('#')[0];
const _new_href = response.headers.redirect.split('#')[0];
const _old_href = window.location.href.split('#')[0]
const _new_href = response.headers.redirect.split('#')[0]
window.location.replace(response.headers.redirect)
// url
if (_old_href === _new_href) {
@ -168,14 +161,14 @@ instance.interceptors.response.use(
console.log('接口error', error)
if (loadingInstance) loadingInstance.close()
const {
response,
message
} = error
const { response, message } = error
if (error.response) {
console.log('接口返回', response)
console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect)
const { status, data } = response
handleCode(status, data.msg || message, response.headers.redirect)
if (response.headers.token) {
setAccessToken(response.headers.token)
}
@ -183,17 +176,10 @@ instance.interceptors.response.use(
window.location.replace(response.headers.redirect)
return Promise.resolve()
}
const {
status,
data
} = response
handleCode(status, data.msg || message, response.headers.redirect)
return Promise.reject(error)
} else {
let {
message
} = error
let { message } = error
if (message === 'Network Error') {
message = '后端接口连接异常'
}

View File

@ -1,8 +1,8 @@
/*
* @Author: hisense.wuhongjian
* @Date: 2022-04-01 17:23:11
* @LastEditors: Light
* @LastEditTime: 2022-10-10 16:43:58
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-10-11 13:59:18
* @Description: 告诉大家这是什么
*/
/**
@ -26,7 +26,7 @@ router.beforeEach(async (to, from, next) => {
// if (SSOTOKEN) {
// setAccessToken(SSOTOKEN)
// }
console.log('验证白名单', routesWhiteList)
const token = getAccessToken()
console.log('token', token)
let hasToken = token
@ -45,6 +45,7 @@ router.beforeEach(async (to, from, next) => {
router.addRoute(item)
})
if (routesWhiteList.indexOf(to.path) !== -1) {
debugger
next()
} else {
//