diff --git a/src/views/tabs/detail.vue b/src/views/tabs/detail.vue index fa5acaacf..ddd400247 100644 --- a/src/views/tabs/detail.vue +++ b/src/views/tabs/detail.vue @@ -1,11 +1,9 @@ - - diff --git a/src/views/tabs/hooks.ts b/src/views/tabs/hooks.ts new file mode 100644 index 000000000..51f4e3167 --- /dev/null +++ b/src/views/tabs/hooks.ts @@ -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 }; +} diff --git a/src/views/tabs/index.vue b/src/views/tabs/index.vue index 1dbdb1324..37eec26c3 100644 --- a/src/views/tabs/index.vue +++ b/src/views/tabs/index.vue @@ -1,16 +1,16 @@