add music request

This commit is contained in:
2023-12-24 17:57:23 +08:00
parent 8419a18b22
commit e615154149
10 changed files with 1019 additions and 46 deletions

View File

@@ -98,25 +98,39 @@ export function downloadConfigDirect<T>(name: string) {
name: name,
})
}
export async function downloadConfig<T>(name: string) {
export async function DownloadConfig<T>(name: string) {
try {
const resp = await QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
name: name,
})
if (resp.code == 200) {
console.log('已获取配置文件: ' + name)
return JSON.parse(resp.data) as T
return {
msg: undefined,
data: JSON.parse(resp.data) as T,
}
} else if (resp.code == 404) {
console.error(`未找到名为 ${name} 的配置文件`)
return {
msg: `未找到名为 ${name} 的配置文件, 需要先上传`,
data: undefined,
}
} else {
console.error(`无法获取配置文件 [${name}]: ` + resp.message)
return {
msg: `无法获取配置文件 [${name}]: ` + resp.message,
data: undefined,
}
}
} catch (err) {
console.error(`无法获取配置文件 [${name}]: ` + err)
return {
msg: `无法获取配置文件 [${name}]: ` + err,
data: undefined,
}
}
return null
}
export async function uploadConfig(name: string, data: unknown) {
export async function UploadConfig(name: string, data: unknown) {
try {
const resp = await QueryPostAPI(VTSURU_API_URL + 'set-config', {
name: name,

View File

@@ -178,6 +178,7 @@ export enum SongFrom {
Custom,
Netease,
FiveSing,
Kugou
}
export interface SongsInfo {
id: number