Merge branch 'hi-ucs-dev' of http://124.222.94.39:3000/wuhongjian/hi-ucs into hi-ucs-dev

This commit is contained in:
guoyue 2022-10-10 17:10:57 +08:00
commit ba597c1da4
3 changed files with 6 additions and 27 deletions

View File

@ -1,7 +1,5 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout'
import { message } from 'ant-design-vue'
import Cookies from 'js-cookie'
export const constantRoutes = [
{
@ -569,24 +567,4 @@ const router = createRouter({
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

View File

@ -1,8 +1,8 @@
/*
* @Author: hisense.wuhongjian
* @Date: 2022-03-29 17:48:03
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-04-25 17:47:09
* @LastEditors: Light
* @LastEditTime: 2022-10-10 16:56:17
* @Description: 告诉大家这是什么
*/
import { storage, tokenTableName } from '@/config'
@ -42,7 +42,8 @@ export function setAccessToken(accessToken) {
} else if ('sessionStorage' === storage) {
return sessionStorage.setItem(tokenTableName, accessToken)
} 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')
} else {
return localStorage.setItem(tokenTableName, accessToken)

View File

@ -1,8 +1,8 @@
/*
* @Author: hisense.wuhongjian
* @Date: 2022-04-01 17:23:11
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-07-18 18:45:20
* @LastEditors: Light
* @LastEditTime: 2022-10-10 16:43:58
* @Description: 告诉大家这是什么
*/
/**