diff --git a/fe/src/components/Post/renderers/list/RendererList.vue b/fe/src/components/Post/renderers/list/RendererList.vue index 332d58c6..fde8e6f1 100644 --- a/fe/src/components/Post/renderers/list/RendererList.vue +++ b/fe/src/components/Post/renderers/list/RendererList.vue @@ -10,23 +10,32 @@ import ThreadItem from './ThreadItem.vue'; import { baseGetUser, baseRenderUsername } from '../common'; import type { ApiPosts } from '@/api/index.d'; import type { Reply, SubReply, Thread } from '@/api/post'; -import type { BaiduUserID } from '@/api/user'; import { compareRouteIsNewQuery, setComponentCustomScrollBehaviour } from '@/router'; import type { Modify } from '@/shared'; -import { convertRemToPixels, isElementNode } from '@/shared'; import { initialTippy } from '@/shared/tippy'; -import { computed, nextTick, onMounted } from 'vue'; +import { computed, onMounted, provide } from 'vue'; import type { RouterScrollBehavior } from 'vue-router'; import * as _ from 'lodash-es'; const props = defineProps<{ initialPosts: ApiPosts['response'] }>(); const getUser = baseGetUser(props.initialPosts.users); const renderUsername = baseRenderUsername(getUser); -const userRoute = (uid: BaiduUserID) => ({ name: 'user/uid', params: { uid } }); +const userProvision = { getUser, renderUsername }; + +// export type UserProvision = typeof userProvision; +// will trigger @typescript-eslint/no-unsafe-assignment when `inject('userProvision')` +export interface UserProvision { + getUser: ReturnType, + renderUsername: ReturnType +} +provide('userProvision', userProvision); + +export type ThreadWithGroupedSubReplies = + Thread & { replies: Array }> }; const posts = computed(() => { - const newPosts = _.cloneDeep(props.initialPosts) as Modify }> }> - }>; + // https://github.com/microsoft/TypeScript/issues/33591 + const newPosts = _.cloneDeep(props.initialPosts) as + Modify> }>; newPosts.threads = newPosts.threads.map(thread => { thread.replies = thread.replies.map(reply => { // eslint-disable-next-line unicorn/no-array-reduce @@ -55,9 +64,7 @@ const posts = computed(() => { return thread; }); - return newPosts as Modify }> - }>; + return newPosts as Modify; }); onMounted(initialTippy); diff --git a/fe/src/components/Post/renderers/list/ReplyItem.vue b/fe/src/components/Post/renderers/list/ReplyItem.vue index 875d7f46..3784960b 100644 --- a/fe/src/components/Post/renderers/list/ReplyItem.vue +++ b/fe/src/components/Post/renderers/list/ReplyItem.vue @@ -22,20 +22,21 @@
+ class="reply row shadow-sm bs-callout bs-callout-info">
- +

{{ author.name }}

{{ author.displayName }}

- +
@@ -43,21 +44,30 @@ \ No newline at end of file + diff --git a/fe/src/components/Post/renderers/list/SubReplyGroup.vue b/fe/src/components/Post/renderers/list/SubReplyGroup.vue index 5c8e98b7..fa576912 100644 --- a/fe/src/components/Post/renderers/list/SubReplyGroup.vue +++ b/fe/src/components/Post/renderers/list/SubReplyGroup.vue @@ -6,7 +6,7 @@ @mouseleave="() => { hoveringSubReplyID = 0 }" class="sub-reply-item list-group-item"> @@ -59,4 +63,4 @@ const hoveringSubReplyID = ref(0); .sub-reply-author { font-size: .9rem; } - \ No newline at end of file + diff --git a/fe/src/components/Post/renderers/list/ThreadItem.vue b/fe/src/components/Post/renderers/list/ThreadItem.vue index 48df97f6..11e856a1 100644 --- a/fe/src/components/Post/renderers/list/ThreadItem.vue +++ b/fe/src/components/Post/renderers/list/ThreadItem.vue @@ -45,7 +45,7 @@
- + 楼主: 楼主兼最后回复: @@ -58,7 +58,7 @@ 未知用户 \ No newline at end of file + diff --git a/fe/src/shared/index.ts b/fe/src/shared/index.ts index 801c128a..e09af62c 100644 --- a/fe/src/shared/index.ts +++ b/fe/src/shared/index.ts @@ -1,6 +1,7 @@ import type { Cursor } from '@/api/index.d'; -import type { User } from '@/api/user'; +import type { BaiduUserID, User } from '@/api/user'; import { computed } from 'vue'; +import type { LocationAsRelativeRaw } from 'vue-router'; import Noty from 'noty'; import * as _ from 'lodash-es'; @@ -51,6 +52,8 @@ export const toUserProfileUrl = (user: Partial>) : `https://tieba.baidu.com/home/main?id=${user.portrait}`); export const toUserPortraitImageUrl = (portrait: string) => `https://himg.bdimg.com/sys/portrait/item/${portrait}.jpg`; // use /sys/portraith for high-res image +export const toUserRoute = (uid: BaiduUserID): LocationAsRelativeRaw => + ({ name: 'user/uid', params: { uid: uid.toString() } }); export const removeStart = (s: string, remove: string) => (s.startsWith(remove) ? s.slice(remove.length) : s); export const removeEnd = (s: string, remove: string) => (s.endsWith(remove) ? s.slice(0, -remove.length) : s);