mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
nothing
This commit is contained in:
@@ -2,21 +2,37 @@ import { QueryGetAPI } from '@/api/query'
|
||||
import { BASE_API, USER_API_URL } from '@/data/constants'
|
||||
import { APIRoot, UserInfo } from './api-models'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
export const USERS = ref<{ [uId: number]: UserInfo }>({})
|
||||
|
||||
export async function useUser(uId: number) {
|
||||
export async function useUserByUId(uId: number) {
|
||||
if (!USERS.value[uId]) {
|
||||
const result = await GetInfo(uId)
|
||||
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
uId: uId,
|
||||
})
|
||||
if (result.code == 200) {
|
||||
USERS.value[uId] = result.data
|
||||
}
|
||||
}
|
||||
return USERS.value[uId]
|
||||
}
|
||||
|
||||
export async function GetInfo(uId: number): Promise<APIRoot<UserInfo>> {
|
||||
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
uId: uId,
|
||||
})
|
||||
export async function useUser(id?: number) {
|
||||
try {
|
||||
if (!id) {
|
||||
id = Number(useRoute().params.id)
|
||||
}
|
||||
} catch { }
|
||||
if (id) {
|
||||
if (!USERS.value[id]) {
|
||||
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
id: id,
|
||||
})
|
||||
if (result.code == 200) {
|
||||
USERS.value[id] = result.data
|
||||
}
|
||||
}
|
||||
return USERS.value[id]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
import { NAvatar, NCard, NIcon, NLayout, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NSpace, NText, NButton, NEmpty, NResult, NPageHeader, NSwitch, useOsTheme } from 'naive-ui'
|
||||
import { computed, h, onMounted, ref } from 'vue'
|
||||
import { BookOutline as BookIcon, PersonOutline as PersonIcon, WineOutline as WineIcon } from '@vicons/ionicons5'
|
||||
import { GetInfo, useUser } from '@/api/user'
|
||||
import { useUser, useUserByUId } from '@/api/user'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { UserInfo } from '@/api/api-models'
|
||||
import { FETCH_API } from '@/data/constants'
|
||||
import { useAccount } from '@/api/account'
|
||||
|
||||
const route = useRoute()
|
||||
const uId = computed(() => {
|
||||
const id = computed(() => {
|
||||
return Number(route.params.id)
|
||||
})
|
||||
const theme = useOsTheme()
|
||||
@@ -35,7 +35,7 @@ const menuOptions = [
|
||||
},
|
||||
]
|
||||
async function RequestBiliUserData() {
|
||||
await fetch(FETCH_API + `https://account.bilibili.com/api/member/getCardByMid?mid=${uId.value}`)
|
||||
await fetch(FETCH_API + `https://account.bilibili.com/api/member/getCardByMid?mid=${id.value}`)
|
||||
.then(async (respone) => {
|
||||
let data = await respone.json()
|
||||
if (data.code == 0) {
|
||||
@@ -51,12 +51,12 @@ async function RequestBiliUserData() {
|
||||
|
||||
onMounted(async () => {
|
||||
await RequestBiliUserData()
|
||||
userInfo.value = await useUser(uId.value)
|
||||
userInfo.value = await useUser(id.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NResult v-if="!uId" status="error" title="输入的uId无效" description="再检查检查" />
|
||||
<NResult v-if="!id" status="error" title="输入的uId无效" description="再检查检查" />
|
||||
<NResult v-else-if="false" status="error" title="未找到指定 uId 的用户" description="或者是没有进行认证" />
|
||||
<NLayout v-else style="height: 100vh">
|
||||
<NLayoutHeader style="height: 50px; padding: 5px 15px 5px 15px">
|
||||
|
||||
Reference in New Issue
Block a user