This commit is contained in:
Viet An
2026-06-29 13:55:17 +07:00
parent 05f624b237
commit 34dd0413f3
2 changed files with 23 additions and 18 deletions

View File

@@ -90,10 +90,7 @@ provide("orders", {
</button> </button>
</div> </div>
</Teleport> </Teleport>
<div <div class="fixed-grid has-2-cols-mobile has-5-cols">
v-if="false"
class="fixed-grid has-2-cols-mobile has-5-cols"
>
<div class="grid"> <div class="grid">
<OrderHighlightCard <OrderHighlightCard
v-for="highlight in highlights" v-for="highlight in highlights"

View File

@@ -43,16 +43,11 @@
/> />
</p> </p>
</div> </div>
<div <div id="header-right-slot"></div>
id="header-right-slot"
:key="componentKey"
></div>
</div> </div>
<KeepAlive> <KeepAlive :exclude="exclude">
<component <component
v-if="componentKey"
:is="componentMap[vbind.component]" :is="componentMap[vbind.component]"
:key="componentKey"
v-bind="vbind" v-bind="vbind"
/> />
</KeepAlive> </KeepAlive>
@@ -60,9 +55,9 @@
</ClientOnly> </ClientOnly>
</template> </template>
<script setup> <script setup>
const { $createMeta, $store, $copy, $id } = useNuxtApp(); const { $createMeta, $filter, $copy, $store } = useNuxtApp();
const componentMap = {}; const componentMap = {};
const componentKey = ref(); const exclude = ref([]);
const vbind = ref({}); const vbind = ref({});
const tab = ref(); const tab = ref();
const subtab = ref(); const subtab = ref();
@@ -85,7 +80,6 @@ function changeTab(_tab, _subtab) {
$store.lang === "en" ? currentTab.value.detail_en || currentTab.value.detail : currentTab.value.detail; $store.lang === "en" ? currentTab.value.detail_en || currentTab.value.detail : currentTab.value.detail;
} }
componentMap[vbind.value.component] = vbind.value.base || toPascalCase(vbind.value.component); componentMap[vbind.value.component] = vbind.value.base || toPascalCase(vbind.value.component);
componentKey.value = vbind.value.component;
$store.commit("tabinfo", { $store.commit("tabinfo", {
tab: tab.value, tab: tab.value,
@@ -104,10 +98,24 @@ function changeTab(_tab, _subtab) {
useHead($createMeta(meta)); useHead($createMeta(meta));
} }
function refresh() { function changeToRandomTab(originalTabId) {
const copy = $copy(componentKey.value) + $id(); const topmenus = $filter($store.common, { category: "topmenu" });
componentKey.value = undefined; const otherTabs = topmenus.filter((m) => m.id !== originalTabId);
setTimeout(() => (componentKey.value = copy)); const randomTab = otherTabs[0];
changeTab(randomTab);
}
async function refresh() {
const oriTab = $copy(tab.value);
const oriSubTab = $copy(subtab.value);
const oriCurrentTab = $copy(currentTab.value);
const oriComp = oriCurrentTab.detail.base;
exclude.value.push(oriComp);
changeToRandomTab(oriCurrentTab.id);
await nextTick();
changeTab(oriTab, oriSubTab);
exclude.value.splice(0, 1);
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>