feat(SSR): 将关于我们页改为SSR
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<div v-if="content">
|
<div v-if="!pending">
|
||||||
<el-breadcrumb class="breadcrumb" separator="/">
|
<el-breadcrumb class="breadcrumb" separator="/">
|
||||||
<el-breadcrumb-item class="text-md opacity-50">
|
<el-breadcrumb-item class="text-md opacity-50">
|
||||||
<NuxtLink :to="$localePath('/')">
|
<NuxtLink :to="$localePath('/')">
|
||||||
@ -40,27 +40,19 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { findOne } = useStrapi();
|
const { findOne } = useStrapi();
|
||||||
const { getStrapiLocale } = useLocalizations();
|
const { getStrapiLocale } = useLocalizations();
|
||||||
|
|
||||||
const strapiLocale = getStrapiLocale();
|
const strapiLocale = getStrapiLocale();
|
||||||
|
|
||||||
const content = ref<string | null>(null);
|
const { data, pending, error } = useAsyncData('company-profile', () =>
|
||||||
|
findOne<StrapiCompanyProfile>('company-profile', undefined, {
|
||||||
onMounted(async () => {
|
|
||||||
try {
|
|
||||||
const response = await findOne<StrapiCompanyProfile>(
|
|
||||||
'company-profile',
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
locale: strapiLocale,
|
locale: strapiLocale,
|
||||||
}
|
})
|
||||||
);
|
);
|
||||||
if (response.data) {
|
|
||||||
content.value = response.data.content || '';
|
const content = computed(() => data.value?.data.content);
|
||||||
} else {
|
|
||||||
console.warn('No company profile data found');
|
watch(error, (value) => {
|
||||||
}
|
if (value) {
|
||||||
} catch (error) {
|
console.error('数据获取失败: ', value);
|
||||||
console.error('Failed to fetch company profile:', error);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user