import { Pane } from "../model/Pane";

interface BreadcrumbNavIns {
  remove(path: string, routeToPreviousPage?: boolean): void;
  add(pane: Pane, active?: boolean): void;
}

class BreadcrumbNavService {
  ins: { [key: string]: BreadcrumbNavIns } = {};

  constructor() {}

  /**
   * @description: 移除面包屑
   * @author ChenRui
   * @date 2021/2/8 14:35
   */
  remove(path: string, routeToPreviousPage = false): void {
    if (this.ins) {
      Object.values(this.ins).forEach((item) => {
        item.remove(path, routeToPreviousPage);
      });
    }
  }

  /**
   * @description: 新增面包屑
   * @author ChenRui
   * @date 2021/2/8 14:37
   */
  add(srcPane: Pane, active = true): void {
    if (this.ins) {
      Object.values(this.ins).forEach((item) => {
        item.add(srcPane, active);
      });
    }
  }
}
const breadcrumbNavService: BreadcrumbNavService = new BreadcrumbNavService();
export { BreadcrumbNavIns, BreadcrumbNavService, breadcrumbNavService };
