You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
767 B
35 lines
767 B
//引入vue和vuex
|
|
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
Vue.use(Vuex)
|
|
|
|
const store = new Vuex.Store({ //全局变量定义
|
|
state: {
|
|
forcedLogin: false, //是否需要强制登录
|
|
hasLogin: false,
|
|
userName: "",
|
|
userId: '',
|
|
token: '',
|
|
pointId: '',
|
|
},
|
|
mutations: {
|
|
login(state, user) {
|
|
console.log("vuex state", state, user)
|
|
state.userName = user.username || '';
|
|
state.hasLogin = true;
|
|
state.userId = user.id || '';
|
|
state.token = user.token || '';
|
|
state.token_type = user.token_type || '';
|
|
state.pointId = user.pointId || '';
|
|
},
|
|
logout(state) {
|
|
state.userName = "";
|
|
state.hasLogin = false;
|
|
state.userId = '';
|
|
state.token = '';
|
|
state.token_type = '';
|
|
state.pointId = '';
|
|
}
|
|
}
|
|
})
|
|
export default store
|
|
|