Skip to content

Commit 59cab1f

Browse files
committed
* render fields of ApiResponseError that taken from <PlaceholderError> when useApiPosts() failed to fetch @ <OgImagePostTakumi>
@ fe
1 parent 643ea1a commit 59cab1f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

fe/src/components/OgImage/Post.takumi.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
<div class="flex flex-row gap-6 justify-between size-screen bg-white" style="font-family: 'Noto Sans SC', sans-serif;">
33
<div class="flex-1 flex-col basis-1/2 m-4">
44
<p>{{ useSiteConfig().name }} {{ routePath }}</p>
5+
<div v-if="error instanceof ApiResponseError">
6+
<p class="text-7xl">{{ error.errorCode }}</p>
7+
<template v-if="_.isString(error.errorInfo)">
8+
<p v-for="(info, _k) in error.errorInfo.split('\n')" :key="_k">{{ info }}</p>
9+
</template>
10+
<template v-else-if="_.isObject(error.errorInfo)">
11+
<p class="whitespace-pre">{{ JSON.stringify(error.errorInfo, null, 4) }}</p>
12+
</template>
13+
</div>
514
<h2 v-if="firstPostPageForumName !== undefined">{{ firstPostPageForumName }}吧</h2>
615
<p v-if="firstImageBase64 !== null">右侧为查询结果中第一张图片(不一定来自第一条帖子)</p>
716
<p v-if="currentQueryType !== 'postID'" class="m-0">下方为查询结果中第一条主题帖/回复帖/楼中楼</p>
@@ -24,14 +33,15 @@
2433

2534
<script setup lang="ts">
2635
import type { UnwrapRef } from 'vue';
36+
import _ from 'lodash';
2737
2838
const { currentQueryType, queryParam, initialPageCursor } = defineProps<{
2939
routePath: string,
3040
currentQueryType: UnwrapRef<QueryFormDeps['currentQueryType']>,
3141
queryParam: ApiPosts['queryParam'] | undefined,
3242
initialPageCursor?: string
3343
}>();
34-
const { data } = useApiPosts(ref(queryParam), { initialPageParam: initialPageCursor });
44+
const { data, error } = useApiPosts(ref(queryParam), { initialPageParam: initialPageCursor });
3545
3646
const { firstPostPage, firstPostPageForumName, firstThread } = useFirstPost(data);
3747
const firstThreadTitle = computed(() => firstThread.value?.title);

0 commit comments

Comments
 (0)