diff --git a/front/src/router/index.js b/front/src/router/index.js index 536d6b37..47c429c7 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -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 diff --git a/front/src/utils/accessToken.js b/front/src/utils/accessToken.js index 343f3587..b5df58f4 100644 --- a/front/src/utils/accessToken.js +++ b/front/src/utils/accessToken.js @@ -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) diff --git a/front/src/vab/plugins/permissions.js b/front/src/vab/plugins/permissions.js index e7535f15..1cd6fbd4 100644 --- a/front/src/vab/plugins/permissions.js +++ b/front/src/vab/plugins/permissions.js @@ -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: 告诉大家这是什么 */ /**