兰宝车间质量管理系统-前端
LiuHao
2023-06-20 a8ed066d8d02a42a0d997801a6b72ad0cd5806ae
update 修改删除tag方法 增加无参refreshPage
已修改2个文件
32 ■■■■ 文件已修改
src/plugins/tab.ts 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/tagsView.ts 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/plugins/tab.ts
@@ -3,8 +3,11 @@
import { TagView, RouteLocationRaw } from 'vue-router';
export default {
  // 刷新当前tab页签
  async refreshPage(obj: TagView): Promise<void> {
  /**
   * 刷新当前tab页签
   * @param obj 标签对象
   */
  async refreshPage(obj?: TagView): Promise<void> {
    const { path, query, matched } = router.currentRoute.value;
    if (obj === undefined) {
      matched.forEach((m) => {
@@ -15,11 +18,16 @@
        }
      });
    }
    // prettier-ignore
    await useTagsViewStore().delCachedView(obj)
    let query1: undefined | {} = {};
    let path1: undefined | string = '';
    if (obj) {
      query1 = obj.query;
      path1 = obj.path;
    }
    await useTagsViewStore().delCachedView(obj);
    await router.replace({
      path: '/redirect' + obj.path,
      query: obj.query
      path: '/redirect' + path1,
      query: query1
    });
  },
  // 关闭当前tab页签,打开新页签
@@ -68,7 +76,10 @@
    const obj = { path: url, query: { ...query, title } };
    return router.push(obj);
  },
  // 修改tab页签
  /**
   * 修改tab页签
   * @param obj 标签对象
   */
  updatePage(obj: TagView) {
    return useTagsViewStore().updateVisitedView(obj);
  }
src/store/modules/tagsView.ts
@@ -54,8 +54,11 @@
      resolve([...visitedViews.value]);
    });
  };
  const delCachedView = (view: TagView): Promise<string[]> => {
    const viewName = view.name as string;
  const delCachedView = (view?: TagView): Promise<string[]> => {
    let viewName = '';
    if (view) {
      viewName = view.name as string;
    }
    return new Promise((resolve) => {
      const index = cachedViews.value.indexOf(viewName);
      index > -1 && cachedViews.value.splice(index, 1);