|
@@ -1,4 +1,5 @@
|
|
// import {getToken,setToken,removeToken} from '@/utils/auth'
|
|
// import {getToken,setToken,removeToken} from '@/utils/auth'
|
|
|
|
+import { Message } from 'element-ui';
|
|
const state = {
|
|
const state = {
|
|
authToken:localStorage.getItem('authToken') ? localStorage.getItem('authToken'):'', //设置token为共享状态 初始化vuex的时候 就先从缓存中读取
|
|
authToken:localStorage.getItem('authToken') ? localStorage.getItem('authToken'):'', //设置token为共享状态 初始化vuex的时候 就先从缓存中读取
|
|
username:'',
|
|
username:'',
|
|
@@ -6,6 +7,17 @@ const state = {
|
|
const mutations = {
|
|
const mutations = {
|
|
REMOVE_TOKEN(state){
|
|
REMOVE_TOKEN(state){
|
|
localStorage.removeItem('authToken');
|
|
localStorage.removeItem('authToken');
|
|
|
|
+ localStorage.removeItem('username');
|
|
|
|
+ state.authToken = "";
|
|
|
|
+ state.username = "";
|
|
|
|
+ Message({
|
|
|
|
+ message: '退出成功',
|
|
|
|
+ type: 'success'
|
|
|
|
+ });
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ window.location.reload();
|
|
|
|
+ }, 1000);
|
|
|
|
+
|
|
},
|
|
},
|
|
SET_TOKEN: (state, token_name) => {
|
|
SET_TOKEN: (state, token_name) => {
|
|
state.authToken = token_name.token;
|
|
state.authToken = token_name.token;
|