Newer
Older
Nanping_sponge_SJJC / src / store / modules / app.js
@liyingjing liyingjing on 25 Oct 2023 2 KB 数据检测

import Cookies from 'js-cookie'

const useAppStore = defineStore(
  'app',
  {
    state: () => ({
      sidebar: {
        opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
        withoutAnimation: false,
        hide: false
      },
      device: 'desktop',
      size: Cookies.get('size') || 'default',

      TitleIndex: Cookies.get('TitleIndex') || 3,  // 当前顶部标题的索引值
      XunHounNb: Cookies.get('XunHounNb') || {},   //防汛专题 选中为讯后总结后 出现的下拉选择项
      fengxiantuNb: Cookies.get('fengxiantuNb') || {},   //防汛专题 选中为讯后总结后 出现的下拉选择项
      iscockpit: Cookies.get('iscockpit') || false,   //判断是否是驾驶舱页面
      isHome: Cookies.get("isHome") || false, //判断当前路由是否是首页
      isMenu: Cookies.get("isMenu") || false,

    }),
    actions: {
      toggleSideBar (withoutAnimation) {
        if (this.sidebar.hide) {
          return false;
        }
        this.sidebar.opened = !this.sidebar.opened
        this.sidebar.withoutAnimation = withoutAnimation
        if (this.sidebar.opened) {
          Cookies.set('sidebarStatus', 1)
        } else {
          Cookies.set('sidebarStatus', 0)
        }
      },
      closeSideBar ({ withoutAnimation }) {
        Cookies.set('sidebarStatus', 0)
        this.sidebar.opened = false
        this.sidebar.withoutAnimation = withoutAnimation
      },
      toggleDevice (device) {
        this.device = device
      },
      setSize (size) {
        this.size = size;
        Cookies.set('size', size)
      },
      toggleSideBarHide (status) {
        this.sidebar.hide = status
      },
      // // 当前专题选中的索引
      // SET_Top_TitleIndex: (TitleIndex) => {
      //   this.TitleIndex = TitleIndex;
      //   Cookies.set('TitleIndex', TitleIndex)
      // },
      // SET_IS_MENU: (isMenu) => {
      //   debugger
      //   console.log(this, 'this');
      //   this.isMenu = isMenu;
      //   // Cookies.set('isMenu', isMenu)
      // },
      // SET_ISHOME: (isHome) => {
      //   this.isHome = isHome;
      //   Cookies.set('isHome', menu)
      // },
    }
  })

export default useAppStore