fix(frontend): await useAsyncData and initialize state in detail views

Restore await for useAsyncData to ensure data is fetched during SSR
Assign initial data to local refs to prevent empty states on load
This commit is contained in:
2026-05-06 17:26:49 +08:00
parent fa656a8d02
commit 4dc73d42cb
4 changed files with 25 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ const detailTabs = computed<TabOption[]>(() => [
{ value: 'history', label: t('history.editHistory') }
]);
const { data: initialHabitat } = useAsyncData<HabitatDetail | null>(
const { data: initialHabitat } = await useAsyncData<HabitatDetail | null>(
`habitat-detail:${activeHabitatRouteId() ?? 'none'}:${locale.value}`,
async () => {
const routeId = activeHabitatRouteId();
@@ -52,6 +52,11 @@ const { data: initialHabitat } = useAsyncData<HabitatDetail | null>(
);
const initialHabitatLoaded = ref(false);
if (initialHabitat.value) {
habitat.value = initialHabitat.value;
initialHabitatLoaded.value = true;
}
const habitatSeo = computed(() =>
habitat.value && route.meta.editorModal !== true
? resolveSeo({