All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web.src.store.menu.index.ts Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
/**
 * @name: 菜单store
 * @author: itmobai
 * @date: 2023-02-17 15:09
 * @description:菜单store
 * @update: 2023-02-17 15:09
 */
import router from '@/router';
import {getMenuApi} from '@/apis/core';
import {generateRoutes} from '@/utils/common';

const state = {
  menuList: [],
  menuType: 0
}
const mutations = {
  SET_MENUS(state: any, menus: any) {
    state.menuList = menus;
  }
}
const actions = {
  getMenuRole(ctx: any) {
    return new Promise(resolve => {
      getMenuApi().then(e => {
          let route =
            {
              id: 0,
              pid: 0,
              sort: 1,
              path: "/home",
              name: "home",
              redirect: null,
              menuType: null,
              component: "/home/index.vue",
              meta: {
                title: "主页",
                isLink: null,
                isHide: false,
                isKeepAlive: false,
                isAffix: false,
                isIframe: false,
                auth: "admin",
                icon: null
              },
              children: []
            }
          let menus = [route, ...e] || [route];
        console.log(menus,'menus')
          ctx.commit("SET_MENUS", menus)
          router.addRoutes(generateRoutes(menus))
          resolve(null)
        }
      )
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy