From 8be7af61c56cd7be6590dcf89dcaa11b419a582e Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 06 十二月 2022 13:59:56 +0800
Subject: [PATCH] 1.增加页签关闭时重新登录功能
---
src/utils/request.js | 1 +
src/permission.js | 3 ++-
src/store/modules/user.js | 4 ++++
src/store/modules/app.js | 4 +++-
4 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/permission.js b/src/permission.js
index 19d6870..6567fd4 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -19,7 +19,8 @@
// determine whether the user has logged in
// const hasToken = getToken()
- const hasToken = getCookie('admin')
+ // const hasToken = getCookie('admin')
+ const hasToken = store.state.app.isGoToIndex
if (hasToken) {
if (to.path === '/login') {
// if is logged in, redirect to the home page
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index a868bf9..19b8157 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -6,7 +6,8 @@
withoutAnimation: false
},
device: 'desktop',
- buttonIsDisabled: false // 鑷畾涔夊叏灞�鍙橀噺鍙傛暟 鎺у埗鎸夐挳鎻愪氦鏃禿isabled
+ buttonIsDisabled: false, // 鑷畾涔夊叏灞�鍙橀噺鍙傛暟 鎺у埗鎸夐挳鎻愪氦鏃禿isabled
+ isGoToIndex: false // 鑷畾涔夊叏灞�鍙橀噺鍙傛暟 鏄惁杩涘叆鍒扮郴缁熼椤�
}
const mutations = {
@@ -44,6 +45,7 @@
export default {
namespaced: true,
buttonIsDisabled: false,
+ isGoToIndex: false,
state,
mutations,
actions
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index e7e2267..669fb6b 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -1,6 +1,7 @@
import { login, logout, getInfo, LoginMenu } from '@/api/user'
import { getToken, setToken, removeToken, setCookie, removeCookie, getCookie } from '@/utils/auth'
import { resetRouter } from '@/router'
+import store from '@/store'
const getDefaultState = () => {
return {
@@ -53,6 +54,8 @@
// if (res.code === '302') {
setCookie('code', res.code)
// }
+
+ store.state.app.isGoToIndex = true
// commit('SET_TOKEN', data.token)
// setToken(res)
@@ -116,6 +119,7 @@
logout(data).then(res => {
if (res.code === '200') {
+ store.state.app.isGoToIndex = false
removeToken() // must remove token first
resetRouter()
diff --git a/src/utils/request.js b/src/utils/request.js
index e95e5b7..5f7ded7 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -68,6 +68,7 @@
removeCookie('rediskey')
removeCookie('guid')
removeCookie('code')
+ store.state.app.isGoToIndex = false
setTimeout(() => {
sessionStorage.removeItem('tabViews')
window.location.reload()
--
Gitblit v1.9.3