app.js
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Local } from "src/utils/storage";
const app = {
state: {
slideBar: {
opened: Local.get("slideBarStatus"),
},
tagViews: JSON.parse(Local.get("tagViews")) || [],
is_add_router: false,
},
mutations: {
TOGGLE_SIDEBAR(state) {
if (state.slideBar.opened) {
Local.set("slideBarStatus", false);
} else {
Local.set("slideBarStatus", true);
}
state.slideBar.opened = !state.slideBar.opened;
},
ADD_TAGVIEW(state, tag) {
if (state.tagViews.some((v) => v.name === tag.name)) return;
state.tagViews.push({ name: tag.name, path: tag.path });
Local.set("tagViews", JSON.stringify(state.tagViews));
},
DEL_TAGVIEW(state, tag) {
let index;
for (let [i, v] of state.tagViews.entries()) {
if (v.name === tag.name) index = i;
}
state.tagViews.splice(index, 1);
Local.set("tagViews", JSON.stringify(state.tagViews));
},
},
actions: {
toggleSideBar({ commit }) {
commit("TOGGLE_SIDEBAR");
},
addTagView({ commit }, tag) {
commit("ADD_TAGVIEW", tag);
},
delTagView({ commit }, tag) {
commit("DEL_TAGVIEW", tag);
},
},
};
export default app;