沈丘营商办后台前端项目
346149741
2024-06-18 9fb6a0ff49c2af567be2e3adaf93c4c301b3f102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import menuSettings from "@/config/menuSettings"; //菜单配置文件
const { menuColors, menuHideWidth, menuOpenWidth } = menuSettings;
 
const storageSetting = JSON.parse(localStorage.getItem("layout-menu") as string) || "";
const useMenuStore = defineStore("menu", {
  state: () => ({
    menuColors: storageSetting.menuColors === undefined ? menuColors : storageSetting.menuColors,
    menuHideWidth: storageSetting.menuHideWidth === undefined ? menuHideWidth : storageSetting.menuHideWidth,
    menuOpenWidth: storageSetting.menuOpenWidth === undefined ? menuOpenWidth : storageSetting.menuOpenWidth,
  }),
  actions: {
    //修改设置
    changeSetting(data: Exclude<string, any>) {
      const { key, value } = data;
      if (this.hasOwnProperty(key)) {
        this[key] = value;
      }
    },
  },
});
export default useMenuStore;