123456789101112131415161718192021222324252627282930 |
- import {
- VuexModule,
- Module,
- getModule,
- Mutation,
- Action
- } from "vuex-module-decorators";
- import store from "../index";
- import { getMenu } from "@/api/menu";
- @Module({ dynamic: true, store, name: "menu" })
- class Menu extends VuexModule {
- private list = getMenu();
- @Mutation
- public setList(list: IMenu[]) {
- this.list = list;
- }
- get pList() {
- return this.list.filter(({ pId }) => !pId);
- }
- get subList() {
- return (pid: number) => this.list.filter(({ pId }) => pId === pid);
- }
- get info() {
- return (id: number) => this.list.find(x => x.id === id);
- }
- }
- export default getModule(Menu);
|