mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update
This commit is contained in:
@@ -6,6 +6,7 @@ import { useLocalStorage } from '@vueuse/core'
|
||||
import { createDiscreteApi } from 'naive-ui'
|
||||
|
||||
export const ACCOUNT = ref<AccountInfo>()
|
||||
export const isLoadingAccount = ref(true)
|
||||
|
||||
const { message } = createDiscreteApi(['message'])
|
||||
const cookie = useLocalStorage('JWT_Token', '')
|
||||
@@ -15,6 +16,7 @@ export async function GetSelfAccount() {
|
||||
const result = await Self()
|
||||
if (result.code == 200) {
|
||||
ACCOUNT.value = result.data
|
||||
isLoadingAccount.value = false
|
||||
console.log('[vtsuru] 已获取账户信息')
|
||||
return result.data
|
||||
} else if (result.code == 401) {
|
||||
@@ -27,6 +29,7 @@ export async function GetSelfAccount() {
|
||||
message.error(result.message)
|
||||
}
|
||||
}
|
||||
isLoadingAccount.value = false
|
||||
}
|
||||
export function useAccount() {
|
||||
return ACCOUNT
|
||||
|
||||
@@ -13,6 +13,9 @@ export interface PaginationResponse<T> {
|
||||
export enum IndexTypes {
|
||||
Default,
|
||||
}
|
||||
export enum SongListTypes {
|
||||
Default,
|
||||
}
|
||||
export interface UserInfo {
|
||||
name: string
|
||||
id: number
|
||||
@@ -20,26 +23,33 @@ export interface UserInfo {
|
||||
biliId?: number
|
||||
biliRoomId?: number
|
||||
indexType: IndexTypes
|
||||
songListType: SongListTypes
|
||||
enableFunctions: FunctionTypes[]
|
||||
}
|
||||
export interface AccountInfo extends UserInfo {
|
||||
isEmailVerified: boolean
|
||||
isBiliVerified: boolean
|
||||
enableFunctions: string[]
|
||||
biliVerifyCode?: string
|
||||
emailVerifyUrl?: string
|
||||
bindEmail?: string
|
||||
settings: UserSetting
|
||||
|
||||
nextSendEmailTime?: number
|
||||
}
|
||||
export interface Setting_SendEmail {
|
||||
recieveQA: boolean
|
||||
recieveQAReply: boolean
|
||||
}
|
||||
export interface Setting_QuestionBox {
|
||||
allowUnregistedUser: boolean
|
||||
}
|
||||
export interface UserSetting {
|
||||
sendEmail: Setting_SendEmail
|
||||
questionBox: Setting_QuestionBox
|
||||
enableFunctions: FunctionTypes[]
|
||||
}
|
||||
export enum FunctionTypes {
|
||||
SongList = 'SongList',
|
||||
QuestionBox = 'QuestionBox',
|
||||
SongList,
|
||||
QuestionBox,
|
||||
}
|
||||
export interface SongAuthorInfo {
|
||||
name: string
|
||||
@@ -61,6 +71,8 @@ export interface SongsInfo {
|
||||
language: SongLanguage[]
|
||||
description?: string
|
||||
tags?: string[]
|
||||
createTime: number
|
||||
updateTime: number
|
||||
}
|
||||
export enum SongLanguage {
|
||||
Chinese, // 中文
|
||||
@@ -92,7 +104,7 @@ export interface QAInfo {
|
||||
isReaded?: boolean
|
||||
isSenderRegisted: boolean
|
||||
isPublic: boolean
|
||||
isFavorite:boolean
|
||||
isFavorite: boolean
|
||||
sendAt: number
|
||||
}
|
||||
export interface LotteryUserInfo {
|
||||
@@ -112,3 +124,8 @@ export interface LotteryUserCardInfo {
|
||||
isGuard: boolean
|
||||
isCharge: boolean
|
||||
}
|
||||
export enum ThemeType {
|
||||
Auto = 'auto',
|
||||
Light = 'light',
|
||||
Dark = 'dark',
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
/* eslint-disable indent */
|
||||
import { useLocalStorage } from '@vueuse/core'
|
||||
import { APIRoot, PaginationResponse } from './api-models'
|
||||
import { Cookies20Regular } from '@vicons/fluent'
|
||||
|
||||
const cookie = useLocalStorage('JWT_Token', '')
|
||||
|
||||
export async function QueryPostAPI<T>(url: string, body?: unknown, headers?: [string, string][]): Promise<APIRoot<T>> {
|
||||
headers ??= []
|
||||
headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||
headers?.push(['Content-Type', 'application/json'])
|
||||
|
||||
const data = await fetch(url, {
|
||||
method: 'post',
|
||||
headers: headers,
|
||||
body: JSON.stringify(body),
|
||||
body: typeof body === 'string' ? body : JSON.stringify(body),
|
||||
}) // 不处理异常, 在页面处理
|
||||
return (await data.json()) as APIRoot<T>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user