Merge branch 'hi-ucs-dev' of http://124.222.94.39:3000/wuhongjian/hi-ucs into hi-ucs-dev
This commit is contained in:
commit
ba597c1da4
|
@ -1,7 +1,5 @@
|
||||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||||
import Layout from '@/layout'
|
import Layout from '@/layout'
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
|
|
||||||
export const constantRoutes = [
|
export const constantRoutes = [
|
||||||
{
|
{
|
||||||
|
@ -569,24 +567,4 @@ const router = createRouter({
|
||||||
routes: constantRoutes,
|
routes: constantRoutes,
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
|
||||||
let token = Cookies.get('ucsToken')
|
|
||||||
const tokenStartTime = window.localStorage.getItem('tokenStartTime')
|
|
||||||
// 定义失效时间
|
|
||||||
const timeOver = 2 * 60 * 60 * 1000
|
|
||||||
let date = new Date().getTime()
|
|
||||||
if (date - tokenStartTime > timeOver && token) {
|
|
||||||
message.warning('登录失效,请重新登录!')
|
|
||||||
token = null
|
|
||||||
}
|
|
||||||
console.log('判断token失效', token, date - tokenStartTime > timeOver)
|
|
||||||
if (!token) {
|
|
||||||
if (to.path == '/login') return next()
|
|
||||||
return next('/login')
|
|
||||||
} else if (to.path == '/login') {
|
|
||||||
return next('/home')
|
|
||||||
}
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* @Author: hisense.wuhongjian
|
* @Author: hisense.wuhongjian
|
||||||
* @Date: 2022-03-29 17:48:03
|
* @Date: 2022-03-29 17:48:03
|
||||||
* @LastEditors: hisense.wuhongjian
|
* @LastEditors: Light
|
||||||
* @LastEditTime: 2022-04-25 17:47:09
|
* @LastEditTime: 2022-10-10 16:56:17
|
||||||
* @Description: 告诉大家这是什么
|
* @Description: 告诉大家这是什么
|
||||||
*/
|
*/
|
||||||
import { storage, tokenTableName } from '@/config'
|
import { storage, tokenTableName } from '@/config'
|
||||||
|
@ -42,7 +42,8 @@ export function setAccessToken(accessToken) {
|
||||||
} else if ('sessionStorage' === storage) {
|
} else if ('sessionStorage' === storage) {
|
||||||
return sessionStorage.setItem(tokenTableName, accessToken)
|
return sessionStorage.setItem(tokenTableName, accessToken)
|
||||||
} else if ('cookie' === storage) {
|
} else if ('cookie' === storage) {
|
||||||
return cookie.set(tokenTableName, accessToken)
|
let expires = new Date(new Date() * 1 + 12 * 60 * 60 * 1000)
|
||||||
|
return cookie.set(tokenTableName, accessToken, { expires: expires })
|
||||||
// return cookie.set(tokenTableName, '213124123412341234')
|
// return cookie.set(tokenTableName, '213124123412341234')
|
||||||
} else {
|
} else {
|
||||||
return localStorage.setItem(tokenTableName, accessToken)
|
return localStorage.setItem(tokenTableName, accessToken)
|
||||||
|
|
|
@ -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: hisense.wuhongjian
|
* @LastEditors: Light
|
||||||
* @LastEditTime: 2022-07-18 18:45:20
|
* @LastEditTime: 2022-10-10 16:43:58
|
||||||
* @Description: 告诉大家这是什么
|
* @Description: 告诉大家这是什么
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue