mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 08:57:19 +08:00
fix: 修复直接通过浏览器地址栏打开演示环境标签详情页,tag未加载的情况
This commit is contained in:
parent
f4c419d44a
commit
9ca764b2a6
@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { useRoute } from "vue-router";
|
||||
const route = useRoute();
|
||||
const index = route.query?.id ?? -1;
|
||||
import { useDetail } from "./hooks";
|
||||
const { initToDetail, id } = useDetail();
|
||||
initToDetail();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>{{ index }} - 详情页内容在此</div>
|
||||
<div>{{ id }} - 详情页内容在此</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
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 };
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from "vue";
|
||||
import { transformI18n } from "/@/plugins/i18n";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { TreeSelect } from "@pureadmin/components";
|
||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||
|
||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||
import {
|
||||
deleteChildren,
|
||||
appendFieldByUniqueId,
|
||||
getNodeByUniqueId
|
||||
} from "/@/utils/tree";
|
||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||
import { useDetail } from "./hooks";
|
||||
const { toDetail } = useDetail();
|
||||
|
||||
let treeData = computed(() => {
|
||||
return appendFieldByUniqueId(
|
||||
@ -20,26 +20,8 @@ let treeData = computed(() => {
|
||||
);
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const value = ref<string[]>([]);
|
||||
|
||||
function toDetail(index: 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 onCloseTags() {
|
||||
value.value.forEach(uniqueId => {
|
||||
let currentPath =
|
||||
|
Loading…
x
Reference in New Issue
Block a user