he wei
2023-11-21 62b7215d11e7c08c7f41e26e2ead6ab9f072e55a
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
import Cookies from "js-cookie";
 
const state = {
  name: Cookies.get("uname"),
  uid: Cookies.get('uid'),
  downloadFlag: Cookies.get("download_flag"),
};
 
const mutations = {
  SETUSER(state, uname) {
    state.name = uname;
    Cookies.set("uname", uname);
  },
  SETDOWNLOAD(state, download_flag) {
    state.downloadFlag = download_flag;
    Cookies.set("download_flag", download_flag);
  },
  SETUID(state, uid) {
    state.uid = uid;
    Cookies.set("uid", uid);
  },
};
 
const actions = {
  setUser({ commit }, uname) {
    commit("SETUSER", uname);
  },
  setDownload({ commit }, download_flag) {
    commit("SETDOWNLOAD", download_flag);
  },
  logout({ commit }) {
    commit("SETUSER", "");
    commit("SETDOWNLOAD", 0);
    commit("SETUID", '');
  },
};
 
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};