From b0c0ef55aba4b7a87eae62275d9e648ac0b35e21 Mon Sep 17 00:00:00 2001 From: n0099 Date: Wed, 14 Feb 2024 16:31:09 +0800 Subject: [PATCH] * suffix all old references to types now extending `Api` with `['response']` or `['queryParam']` * exporting type `ApiErrorClass` and classes that it referring @ index.ts * fix extending `CursorPagination['pages']` in type `ApiPosts` @ index.d.ts @ api * change type of prop `error` to `ApiErrorClass` @ `` * rename prop `isFetchingPosts` to `isLoading`, partial revert d3eb4e2d7ce10804aada8751425fcf9629056bd6 @ `` @ fe --- fe/src/api/index.d.ts | 9 +++++---- fe/src/api/index.ts | 6 +++--- fe/src/components/Post/PostNav.vue | 2 +- fe/src/components/Post/PostPage.vue | 2 +- fe/src/components/Post/queryForm/QueryForm.vue | 6 +++--- fe/src/components/Post/renderers/RendererList.vue | 6 +++--- fe/src/components/Post/renderers/RendererTable.vue | 6 +++--- fe/src/components/User/UserPage.vue | 2 +- fe/src/components/placeholders/PlaceholderError.vue | 10 +++++++--- fe/src/views/Post.vue | 2 +- fe/src/views/Stats.vue | 4 ++-- fe/src/views/Status.vue | 6 +++--- fe/src/views/User.vue | 2 +- 13 files changed, 34 insertions(+), 29 deletions(-) diff --git a/fe/src/api/index.d.ts b/fe/src/api/index.d.ts index 180e49e3..bd1ddb2b 100644 --- a/fe/src/api/index.d.ts +++ b/fe/src/api/index.d.ts @@ -59,10 +59,11 @@ export type ApiUsers = Api< >; export type JsonString = string; -export type ApiPosts = Api]: UInt } -}> & { +export type ApiPosts = Api]: UInt } + }, type: 'index' | 'search', forum: Pick, threads: Array | string @@ -13,7 +13,7 @@ class ApiResponseError extends Error { super(JSON.stringify({ errorCode, errorInfo })); } } -class FetchResponseError extends Error { +export class FetchResponseError extends Error { public constructor(public readonly response: Response) { super(JSON.stringify(response)); } @@ -74,7 +74,7 @@ const getRequesterWithReCAPTCHA = { ...queryParam as TQueryParam, ...await reCAPTCHACheck(action) } )(queryContext); -type ApiErrorClass = ApiResponseError | FetchResponseError; +export type ApiErrorClass = ApiResponseError | FetchResponseError; type ReqesuterGetter = typeof getRequester | typeof getRequesterWithReCAPTCHA; const useApi = < TApi extends Api, diff --git a/fe/src/components/Post/PostNav.vue b/fe/src/components/Post/PostNav.vue index dc9bd676..ae3958de 100644 --- a/fe/src/components/Post/PostNav.vue +++ b/fe/src/components/Post/PostNav.vue @@ -58,7 +58,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import scrollIntoView from 'scroll-into-view-if-needed'; import * as _ from 'lodash-es'; -const props = defineProps<{ postPages: ApiPosts[] }>(); +const props = defineProps<{ postPages: Array }>(); const route = useRoute(); const router = useRouter(); const elementRefsStore = useElementRefsStore(); diff --git a/fe/src/components/Post/PostPage.vue b/fe/src/components/Post/PostPage.vue index 7a17dd4a..fbcd1122 100644 --- a/fe/src/components/Post/PostPage.vue +++ b/fe/src/components/Post/PostPage.vue @@ -16,7 +16,7 @@ import type { ApiPosts } from '@/api/index.d'; import type { RouteLocationNormalized } from 'vue-router'; const props = defineProps<{ - posts: ApiPosts, + posts: ApiPosts['response'], renderType: PostRenderer, currentRoute: RouteLocationNormalized, isLoadingNewPage: boolean, diff --git a/fe/src/components/Post/queryForm/QueryForm.vue b/fe/src/components/Post/queryForm/QueryForm.vue index cc7bea93..7fe55773 100644 --- a/fe/src/components/Post/queryForm/QueryForm.vue +++ b/fe/src/components/Post/queryForm/QueryForm.vue @@ -154,8 +154,8 @@
- {{ currentQueryTypeDescription }}
@@ -185,7 +185,7 @@ import { RangePicker } from 'ant-design-vue'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import * as _ from 'lodash-es'; -defineProps<{ isFetchingPosts: boolean }>(); +defineProps<{ isLoading: boolean }>(); const router = useRouter(); const { uniqueParams, diff --git a/fe/src/components/Post/renderers/RendererList.vue b/fe/src/components/Post/renderers/RendererList.vue index 9e31cc44..7cfd4f8b 100644 --- a/fe/src/components/Post/renderers/RendererList.vue +++ b/fe/src/components/Post/renderers/RendererList.vue @@ -176,7 +176,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import { DateTime } from 'luxon'; import * as _ from 'lodash-es'; -const props = defineProps<{ initialPosts: ApiPosts }>(); +const props = defineProps<{ initialPosts: ApiPosts['response'] }>(); const elementRefsStore = useElementRefsStore(); const replyElements = ref([]); const hoveringSubReplyID = ref(0); @@ -184,7 +184,7 @@ const getUser = baseGetUser(props.initialPosts.users); const renderUsername = baseRenderUsername(getUser); const userRoute = (uid: BaiduUserID) => ({ name: 'user/uid', params: { uid } }); const posts = computed(() => { - const newPosts = props.initialPosts as Modify }> }> }>; newPosts.threads = newPosts.threads.map(thread => { @@ -215,7 +215,7 @@ const posts = computed(() => { return thread; }); - return newPosts as Modify }> }>; }); diff --git a/fe/src/components/Post/renderers/RendererTable.vue b/fe/src/components/Post/renderers/RendererTable.vue index e146e9a9..6a18dd4e 100644 --- a/fe/src/components/Post/renderers/RendererTable.vue +++ b/fe/src/components/Post/renderers/RendererTable.vue @@ -97,9 +97,9 @@ import { Table } from 'ant-design-vue'; import type { ColumnType } from 'ant-design-vue/es/table/interface'; import * as _ from 'lodash-es'; -const props = defineProps<{ posts: ApiPosts }>(); -const threads = ref(); -const repliesKeyByTid = ref>([]); +const props = defineProps<{ posts: ApiPosts['response'] }>(); +const threads = ref(); +const repliesKeyByTid = ref>([]); const subRepliesKeyByPid = ref>([]); const threadColumns = ref([ { title: 'tid', dataIndex: 'tid' }, diff --git a/fe/src/components/User/UserPage.vue b/fe/src/components/User/UserPage.vue index a6c5724a..0a23e32a 100644 --- a/fe/src/components/User/UserPage.vue +++ b/fe/src/components/User/UserPage.vue @@ -26,7 +26,7 @@ import type { UserGender } from '@/api/user'; import { toUserPortraitImageUrl } from '@/shared'; const props = defineProps<{ - users: ApiUsers, + users: ApiUsers['response'], isLoadingNewPage: boolean, isLastPageInPages: boolean }>(); diff --git a/fe/src/components/placeholders/PlaceholderError.vue b/fe/src/components/placeholders/PlaceholderError.vue index db3d5123..6235cce0 100644 --- a/fe/src/components/placeholders/PlaceholderError.vue +++ b/fe/src/components/placeholders/PlaceholderError.vue @@ -3,7 +3,10 @@ -