From c1ffbef56562cc8d98d39046196b4c5e2d77d063 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:07:55 +0700 Subject: [PATCH] feat: auto go into first entry if only one --- src/pages/00_manual/MainPage.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/00_manual/MainPage.vue b/src/pages/00_manual/MainPage.vue index a0b85ef8..33a19ebe 100644 --- a/src/pages/00_manual/MainPage.vue +++ b/src/pages/00_manual/MainPage.vue @@ -10,10 +10,11 @@ import { onMounted, watch } from 'vue'; import { useManualStore } from 'src/stores/manual'; import { useNavigator } from 'src/stores/navigator'; import { Icon } from '@iconify/vue/dist/iconify.js'; -import { useRoute } from 'vue-router'; +import { useRoute, useRouter } from 'vue-router'; // NOTE: Variable const route = useRoute(); +const router = useRouter(); const manualStore = useManualStore(); const navigatorStore = useNavigator(); const { dataManual, dataTroubleshooting } = storeToRefs(manualStore); @@ -33,6 +34,16 @@ watch( if (route.name === 'Troubleshooting') { const res = await manualStore.getTroubleshooting(); dataTroubleshooting.value = res ? res : []; + if ( + res.length && + res.length === 1 && + res[0].page && + res[0].page.length === 1 + ) { + router.replace( + `/troubleshooting/${res[0].category}/${res[0].page[0].name}`, + ); + } } }, { immediate: true },