import { VuexModule, Module, getModule, Mutation } from 'vuex-module-decorators';
import store from '@/store';

export interface IBreadcrumbItem {
  label: string,
  path?: string
}

@Module({ namespaced: true, name: 'breadcrumb', dynamic: true, store })
export class Breadcrumb extends VuexModule {

  breadcrumbs: IBreadcrumbItem[] = [
    { label: '首页', path: '/' },
  ]

  @Mutation
  setBreadcrumb(breadcrumbs: IBreadcrumbItem[]) {
    this.breadcrumbs.splice(1, this.breadcrumbs.length - 1, ...breadcrumbs)
  }
}

export default getModule<Breadcrumb>(Breadcrumb);
