/**
 *  菜单数据
 */
import { defineStore } from 'pinia'

export const menusStore = defineStore('menus', {
  state: () => ({
    menus: <any>[],
    menus_obj_id: <any>{},
    menus_obj_path: <any>{},
    menus_roles: <any>{},
    currentMenu: <any>{}, // {name,id}
  }),

  actions: {
    // topBar 右侧选择语言触发
    saveMenus({ menus, menus_obj_id, menus_obj_path, menus_roles }:any){
      this.menus = menus
      this.menus_obj_id = menus_obj_id
      this.menus_obj_path = menus_obj_path
      this.menus_roles = menus_roles
    },

    setCurrentMenu(menu:any){
      this.currentMenu = menu
    },

    setMenuFavorite(menu_id:string, isFavorite:boolean){
      this.menus_obj_id[menu_id].isFavorite = isFavorite
    },

  }

})
