You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
2 years ago
|
import Vue from "vue";
|
||
|
import Vuex from "vuex";
|
||
|
|
||
|
Vue.use(Vuex);
|
||
|
|
||
|
export default new Vuex.Store({
|
||
|
state: {
|
||
|
//用户登录token 存储
|
||
|
token: "",
|
||
|
userName: "",
|
||
|
userid: "",
|
||
|
role: "",
|
||
|
currentData: "",
|
||
|
channelId: "",
|
||
|
termId: "",
|
||
|
protocol: "",
|
||
|
cmdId: "",
|
||
|
channelIdList: [],
|
||
|
},
|
||
|
getters: {
|
||
|
token: (state) => state.token,
|
||
|
userName: (state) => state.userName,
|
||
|
role: (state) => state.role,
|
||
|
},
|
||
|
mutations: {
|
||
|
//点击获取的左侧列表
|
||
|
currentData(state, currentData) {
|
||
|
state.currentData = currentData;
|
||
|
console.log("保存起来currentData", state.currentData);
|
||
|
localStorage.setItem("currentData", JSON.stringify(currentData));
|
||
|
},
|
||
|
|
||
|
channelId(state, channelId) {
|
||
|
state.channelId = channelId;
|
||
|
console.log("channelId", state.channelId);
|
||
|
localStorage.setItem("channelId", JSON.stringify(channelId));
|
||
|
},
|
||
|
termId(state, termId) {
|
||
|
state.termId = termId;
|
||
|
console.log("termId", state.termId);
|
||
|
localStorage.setItem("termId", JSON.stringify(termId));
|
||
|
},
|
||
|
|
||
|
protocol(state, protocol) {
|
||
|
state.protocol = protocol;
|
||
|
console.log("protocol", state.protocol);
|
||
|
localStorage.setItem("protocol", JSON.stringify(protocol));
|
||
|
},
|
||
|
cmdId(state, cmdId) {
|
||
|
state.cmdId = cmdId;
|
||
|
console.log("protocol", state.cmdId);
|
||
|
localStorage.setItem("protocol", JSON.stringify(cmdId));
|
||
|
},
|
||
|
channelIdList(state, channelIdList) {
|
||
|
state.channelIdList = channelIdList;
|
||
|
console.log("channelIdList", state.channelIdList);
|
||
|
localStorage.setItem("channelIdList", JSON.stringify(channelIdList));
|
||
|
},
|
||
|
|
||
|
SET_TOKEN(state, token) {
|
||
|
state.token = token;
|
||
|
localStorage.setItem("token", state.token);
|
||
|
},
|
||
|
SET_USERINFO(state, val) {
|
||
|
state.userName = val.userName;
|
||
|
state.userid = val.id;
|
||
|
state.role = val.role;
|
||
|
localStorage.setItem("userName", state.userName);
|
||
|
localStorage.setItem("userid", state.userid);
|
||
|
localStorage.setItem("role", state.role);
|
||
|
},
|
||
|
//退出清除locastorge
|
||
|
REMOVE_INFO(state) {
|
||
|
localStorage.clear();
|
||
|
},
|
||
|
},
|
||
|
actions: {},
|
||
|
modules: {},
|
||
|
});
|