feat: 将解决方案页迁移至directus
- 将/solutions与/solutions/[slug]页现在由Directus作为CMS - 添加solution页的composable API
This commit is contained in:
@ -25,7 +25,7 @@
|
||||
<div class="solution-meta">
|
||||
<span class="solution-date">
|
||||
CreatedAt:
|
||||
{{ new Date(solution.createdAt).toLocaleDateString() }}
|
||||
{{ new Date(solution.createAt).toLocaleDateString() }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -57,23 +57,17 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
const route = useRoute();
|
||||
const { findOne } = useStrapi();
|
||||
const { getStrapiLocale } = useLocalizations();
|
||||
const strapiLocale = getStrapiLocale();
|
||||
|
||||
// 获取路由参数(documentId)
|
||||
const documentId = computed(() => route.params.slug as string);
|
||||
const id = computed(() => route.params.slug as string);
|
||||
|
||||
const { data, pending, error } = useAsyncData(
|
||||
() => `solution-${documentId.value}`,
|
||||
() =>
|
||||
findOne<Solution>('solutions', documentId.value, {
|
||||
populate: '*',
|
||||
locale: strapiLocale,
|
||||
})
|
||||
);
|
||||
const { data, pending, error } = await useSolution(id.value);
|
||||
|
||||
const solution = computed(() => data.value?.data ?? null);
|
||||
console.log('RawData: ', data.value);
|
||||
const process = toSolutionView(data.value);
|
||||
console.log('Processed Solution: ', process);
|
||||
|
||||
const solution = computed(() => toSolutionView(data.value));
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
|
||||
Reference in New Issue
Block a user