mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-15 14:03:36 +08:00
fix: 修复直接通过浏览器地址栏打开演示环境标签详情页,tag未加载的情况
This commit is contained in:
32
src/views/tabs/hooks.ts
Normal file
32
src/views/tabs/hooks.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { onBeforeMount } from "vue";
|
||||
|
||||
export function useDetail() {
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const id = route.query?.id ?? -1;
|
||||
|
||||
function toDetail(index: number | string | string[] | number[]) {
|
||||
useMultiTagsStoreHook().handleTags("push", {
|
||||
path: `/tabs/detail`,
|
||||
parentPath: route.matched[0].path,
|
||||
name: "tabDetail",
|
||||
query: { id: String(index) },
|
||||
meta: {
|
||||
title: { zh: `No.${index} - 详情信息`, en: `No.${index} - DetailInfo` },
|
||||
showLink: false,
|
||||
dynamicLevel: 3
|
||||
}
|
||||
});
|
||||
router.push({ name: "tabDetail", query: { id: String(index) } });
|
||||
}
|
||||
|
||||
function initToDetail() {
|
||||
onBeforeMount(() => {
|
||||
if (id) toDetail(id);
|
||||
});
|
||||
}
|
||||
|
||||
return { toDetail, initToDetail, id };
|
||||
}
|
||||
Reference in New Issue
Block a user