mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update
This commit is contained in:
@@ -10,12 +10,16 @@ export interface PaginationResponse<T> {
|
||||
hasMore: boolean
|
||||
datas: T
|
||||
}
|
||||
export enum IndexTypes {
|
||||
Default,
|
||||
}
|
||||
export interface UserInfo {
|
||||
name: string
|
||||
id: number
|
||||
createAt: number
|
||||
biliId?: number
|
||||
biliRoomId?: number
|
||||
indexType: IndexTypes
|
||||
}
|
||||
export interface AccountInfo extends UserInfo {
|
||||
isEmailVerified: boolean
|
||||
@@ -23,6 +27,19 @@ export interface AccountInfo extends UserInfo {
|
||||
enableFunctions: string[]
|
||||
biliVerifyCode?: string
|
||||
emailVerifyUrl?: string
|
||||
settings: UserSetting
|
||||
}
|
||||
export interface Setting_SendEmail {
|
||||
recieveQA: boolean
|
||||
recieveQAReply: boolean
|
||||
}
|
||||
export interface UserSetting {
|
||||
sendEmail: Setting_SendEmail
|
||||
enableFunctions: FunctionTypes[]
|
||||
}
|
||||
export enum FunctionTypes {
|
||||
SongList = 'SongList',
|
||||
QuestionBox = 'QuestionBox',
|
||||
}
|
||||
export interface SongAuthorInfo {
|
||||
name: string
|
||||
@@ -37,6 +54,7 @@ export interface SongsInfo {
|
||||
id: number
|
||||
key: string
|
||||
name: string
|
||||
translateName?: string
|
||||
author: string[]
|
||||
url: string
|
||||
from: SongFrom
|
||||
@@ -52,3 +70,25 @@ export enum SongLanguage {
|
||||
French, // 法文
|
||||
Other, //其他
|
||||
}
|
||||
export enum LevelTypes {
|
||||
Info,
|
||||
Success,
|
||||
Warn,
|
||||
Error,
|
||||
}
|
||||
export interface NotifactionInfo {
|
||||
id: string
|
||||
createTime: number
|
||||
title: string
|
||||
message: string
|
||||
type: LevelTypes
|
||||
}
|
||||
export interface QAInfo {
|
||||
id: number
|
||||
sender: UserInfo
|
||||
target: UserInfo
|
||||
question: { message: string; image?: string }
|
||||
answer?: { message: string; image?: string }
|
||||
isReaded?: boolean
|
||||
sendAt: number
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ export async function QueryGetAPI<T>(urlString: string, params?: any, headers?:
|
||||
export async function QueryPostPaginationAPI<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> {
|
||||
return await QueryPostAPI<PaginationResponse<T>>(url, body)
|
||||
}
|
||||
export async function QueryGetPaginationAPI<T>(urlString: string, params?: any): Promise<APIRoot<PaginationResponse<T>>> {
|
||||
export async function QueryGetPaginationAPI<T>(urlString: string, params?: unknown): Promise<APIRoot<PaginationResponse<T>>> {
|
||||
return await QueryGetAPI<PaginationResponse<T>>(urlString, params)
|
||||
}
|
||||
|
||||
@@ -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 { useRouteParams } from '@vueuse/router'
|
||||
|
||||
export const USERS = ref<{ [uId: number]: UserInfo }>({})
|
||||
|
||||
export async function useUser(uId: number) {
|
||||
if (!USERS.value[uId]) {
|
||||
const result = await GetInfo(uId)
|
||||
export async function useUser() {
|
||||
const uId = useRouteParams('id', '-1', { transform: Number }).value
|
||||
if (uId) {
|
||||
if (!USERS.value[uId]) {
|
||||
const result = await GetInfo(uId)
|
||||
if (result.code == 200) {
|
||||
USERS.value[uId] = result.data
|
||||
}
|
||||
}
|
||||
return USERS.value[uId]
|
||||
}
|
||||
else {
|
||||
console.error('指定uId: ' + uId + ' 无效');
|
||||
}
|
||||
}
|
||||
export async function useUserWithUId(id: number) {
|
||||
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]
|
||||
return USERS.value[id]
|
||||
}
|
||||
|
||||
export async function GetInfo(uId: number): Promise<APIRoot<UserInfo>> {
|
||||
export async function GetInfo(id: number): Promise<APIRoot<UserInfo>> {
|
||||
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
|
||||
uId: uId,
|
||||
id: id,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user