feat: refs #8242 remove teleport
This commit is contained in:
parent
ae0681a045
commit
1c4b5aa720
|
@ -1,10 +1,9 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount } from 'vue';
|
import { onBeforeMount } from 'vue';
|
||||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
import { useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
import LeftMenu from 'components/LeftMenu.vue';
|
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -27,7 +26,13 @@ const arrayData = useArrayData(props.dataKey, {
|
||||||
oneRecord: true,
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onBeforeRouteLeave((to, from) => {
|
||||||
|
stateStore.cardDescriptorChangeValue(null);
|
||||||
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
|
stateStore.cardDescriptorChangeValue(props.descriptor);
|
||||||
|
|
||||||
const route = router.currentRoute.value;
|
const route = router.currentRoute.value;
|
||||||
try {
|
try {
|
||||||
await fetch(route.params.id);
|
await fetch(route.params.id);
|
||||||
|
@ -39,6 +44,9 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
|
// if (to.matched.length < from.matched.length) {
|
||||||
|
// stateStore.cardDescriptorChangeValue(null);
|
||||||
|
// }
|
||||||
if (hasRouteParam(to.params)) {
|
if (hasRouteParam(to.params)) {
|
||||||
const { matched } = router.currentRoute.value;
|
const { matched } = router.currentRoute.value;
|
||||||
const { name } = matched.at(-3);
|
const { name } = matched.at(-3);
|
||||||
|
@ -62,11 +70,6 @@ function hasRouteParam(params, valueToCheck = ':addressId') {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
|
||||||
<component :is="descriptor" />
|
|
||||||
<QSeparator />
|
|
||||||
<LeftMenu source="card" />
|
|
||||||
</Teleport>
|
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="$route.path" />
|
<RouterView :key="$route.path" />
|
||||||
|
|
Loading…
Reference in New Issue