|
@@ -1,15 +1,17 @@
|
|
|
// import {getToken,setToken,removeToken} from '@/utils/auth'
|
|
|
const state = {
|
|
|
authToken:localStorage.getItem('authToken') ? localStorage.getItem('authToken'):'', //设置token为共享状态 初始化vuex的时候 就先从缓存中读取
|
|
|
- username:"",
|
|
|
+ username:'',
|
|
|
}
|
|
|
const mutations = {
|
|
|
REMOVE_TOKEN(state){
|
|
|
localStorage.removeItem('authToken');
|
|
|
},
|
|
|
- SET_TOKEN: (state, token) => {
|
|
|
- state.authToken = token;
|
|
|
- localStorage.setItem('authToken', token);
|
|
|
+ SET_TOKEN: (state, token_name) => {
|
|
|
+ state.authToken = token_name.token;
|
|
|
+ state.username = token_name.username;
|
|
|
+ localStorage.setItem('authToken', token_name.token);
|
|
|
+ localStorage.setItem('username', token_name.username);
|
|
|
},
|
|
|
SET_NAME: (state, name) => {
|
|
|
state.name = name
|