zhangfufeng 4 meses atrás
pai
commit
b5ae48dac9
2 arquivos alterados com 8 adições e 5 exclusões
  1. 0 2
      src/store/modules/user.js
  2. 8 3
      src/utils/auth.js

+ 0 - 2
src/store/modules/user.js

@@ -122,7 +122,6 @@ const user = {
           commit('SET_ROLES', [])
           commit('SET_PERMS', [])
           removeToken()
-          setLoginStatus(false)
           resolve()
         }).catch(error => {
           reject(error)
@@ -135,7 +134,6 @@ const user = {
       return new Promise(resolve => {
         commit('SET_TOKEN', '')
         removeToken()
-        setLoginStatus(false)
         resolve()
       })
     },

+ 8 - 3
src/utils/auth.js

@@ -3,7 +3,11 @@ import Cookies from 'js-cookie'
 const TokenKey = 'X-JZ-Admin-Token'
 
 export function getToken() {
-  return Cookies.get(TokenKey)
+  let token = Cookies.get(TokenKey);
+  if (token.includes(":")) {
+    token = token.split(":")[1]
+  }
+  return token;
 }
 
 export function setToken(token) {
@@ -11,13 +15,14 @@ export function setToken(token) {
 }
 
 export function removeToken() {
+  Cookies.remove("login")
   return Cookies.remove(TokenKey)
 }
 
 export function setLoginStatus(status) {
-  return Cookies.set('loginStatus', status)
+  return Cookies.set('login', status)
 }
 
 export function getLoginStatus() {
-  return Cookies.get('loginStatus')
+  return Cookies.get('login')
 }