Compare commits

..

2 Commits

5 changed files with 37 additions and 49 deletions

View File

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

View File

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

View File

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

View File

@ -11,14 +11,8 @@ import store from '@/store'
import qs from 'qs' import qs from 'qs'
import router from '@/router' import router from '@/router'
// import { isArray } from '@/utils/validate' // import { isArray } from '@/utils/validate'
import { import { message } from 'ant-design-vue'
message import { getAccessToken, setAccessToken } from '@/utils/accessToken'
} from 'ant-design-vue'
import {
getAccessToken,
setAccessToken
} from '@/utils/accessToken'
let loadingInstance let loadingInstance
@ -33,12 +27,14 @@ const handleCode = (code, msg, res) => {
switch (code) { switch (code) {
case 401: case 401:
debugger debugger
store.dispatch('user/resetAll').catch(() => { }) store.dispatch('user/resetAll').catch(() => {})
break break
case 403: case 403:
router.push({ router
path: '/401' .push({
}).catch(() => { }) path: '/401',
})
.catch(() => {})
break break
case 500: case 500:
message.error(msg || '接口异常') message.error(msg || '接口异常')
@ -103,17 +99,14 @@ instance.interceptors.response.use(
console.log('接口返回headers', response.headers) console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect) console.log('接口返回REDIRECT', response.headers.redirect)
response['Access-Control-Expose-Headers'] = 'redirect' response['Access-Control-Expose-Headers'] = 'redirect'
const { const { code, message } = response.data
code,
message
} = response.data
if (response.headers.token) { if (response.headers.token) {
setAccessToken(response.headers.token) setAccessToken(response.headers.token)
} }
if (response.headers.redirect) { if (response.headers.redirect) {
const _old_href = window.location.href.split('#')[0]; const _old_href = window.location.href.split('#')[0]
const _new_href = response.headers.redirect.split('#')[0]; const _new_href = response.headers.redirect.split('#')[0]
window.location.replace(response.headers.redirect) window.location.replace(response.headers.redirect)
// url // url
if (_old_href === _new_href) { if (_old_href === _new_href) {
@ -124,7 +117,7 @@ instance.interceptors.response.use(
if (response.headers.redirect === '/#/login') { if (response.headers.redirect === '/#/login') {
var keys = document.cookie.match(/[^ =;]+(?=\=)/g) var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
if (keys) { if (keys) {
for (var i = keys.length; i--;) { for (var i = keys.length; i--; ) {
document.cookie = document.cookie =
keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString() //,m.kevis.com keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString() //,m.kevis.com
document.cookie = document.cookie =
@ -168,14 +161,14 @@ instance.interceptors.response.use(
console.log('接口error', error) console.log('接口error', error)
if (loadingInstance) loadingInstance.close() if (loadingInstance) loadingInstance.close()
const { const { response, message } = error
response,
message
} = error
if (error.response) { if (error.response) {
console.log('接口返回', response) console.log('接口返回', response)
console.log('接口返回headers', response.headers) console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect) console.log('接口返回REDIRECT', response.headers.redirect)
const { status, data } = response
handleCode(status, data.msg || message, response.headers.redirect)
if (response.headers.token) { if (response.headers.token) {
setAccessToken(response.headers.token) setAccessToken(response.headers.token)
} }
@ -183,17 +176,10 @@ instance.interceptors.response.use(
window.location.replace(response.headers.redirect) window.location.replace(response.headers.redirect)
return Promise.resolve() return Promise.resolve()
} }
const {
status,
data
} = response
handleCode(status, data.msg || message, response.headers.redirect)
return Promise.reject(error) return Promise.reject(error)
} else { } else {
let { let { message } = error
message
} = error
if (message === 'Network Error') { if (message === 'Network Error') {
message = '后端接口连接异常' message = '后端接口连接异常'
} }

View File

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