mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
1007
This commit is contained in:
@@ -90,5 +90,8 @@ export interface QAInfo {
|
||||
question: { message: string; image?: string }
|
||||
answer?: { message: string; image?: string }
|
||||
isReaded?: boolean
|
||||
isSenderRegisted: boolean
|
||||
isPublic: boolean
|
||||
isFavorite:boolean
|
||||
sendAt: number
|
||||
}
|
||||
|
||||
@@ -3,22 +3,23 @@ import { BASE_API, USER_API_URL } from '@/data/constants'
|
||||
import { APIRoot, UserInfo } from './api-models'
|
||||
import { ref } from 'vue'
|
||||
import { useRouteParams } from '@vueuse/router'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
export const USERS = ref<{ [uId: number]: UserInfo }>({})
|
||||
|
||||
export async function useUser() {
|
||||
const uId = useRouteParams('id', '-1', { transform: Number }).value
|
||||
if (uId) {
|
||||
if (!USERS.value[uId]) {
|
||||
const result = await GetInfo(uId)
|
||||
export async function useUser(id: number | undefined = undefined) {
|
||||
const route = useRoute()
|
||||
id ??= Number(route.params.id)
|
||||
if (id) {
|
||||
if (!USERS.value[id]) {
|
||||
const result = await GetInfo(id)
|
||||
if (result.code == 200) {
|
||||
USERS.value[uId] = result.data
|
||||
USERS.value[id] = result.data
|
||||
}
|
||||
}
|
||||
return USERS.value[uId]
|
||||
}
|
||||
else {
|
||||
console.error('指定uId: ' + uId + ' 无效');
|
||||
return USERS.value[id]
|
||||
} else {
|
||||
console.error('指定id: ' + id + ' 无效')
|
||||
}
|
||||
}
|
||||
export async function useUserWithUId(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user