refactor(frontend): move detail view state initialization to server plugin

Remove top-level await from useAsyncData in detail views
Remove manual state initialization blocks in components
Introduce 03-detail-seo.server.ts to handle SEO and state
This commit is contained in:
2026-05-06 17:40:44 +08:00
parent 4dc73d42cb
commit 5ef1f4ecc9
5 changed files with 80 additions and 25 deletions

View File

@@ -34,7 +34,7 @@ const detailTabs = computed<TabOption[]>(() => [
{ value: 'history', label: t('history.editHistory') }
]);
const { data: initialHabitat } = await useAsyncData<HabitatDetail | null>(
const { data: initialHabitat } = useAsyncData<HabitatDetail | null>(
`habitat-detail:${activeHabitatRouteId() ?? 'none'}:${locale.value}`,
async () => {
const routeId = activeHabitatRouteId();
@@ -52,11 +52,6 @@ const { data: initialHabitat } = await 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({