mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
feat: 更新配置和文件上传逻辑, 迁移数据库结构(前端也得改
- 移除不再使用的 vite-plugin-monaco-editor - 更新 package.json 和 vite.config.mts 文件 - 修改用户配置 API 逻辑,支持上传和下载配置 - 添加对文件上传的支持,优化文件处理逻辑 - 更新多个组件以支持新文件上传功能 - 删除不必要的 VTsuruTypes.ts 文件,整合到 VTsuruConfigTypes.ts 中
This commit is contained in:
@@ -7,13 +7,14 @@ import { cookie } from './account';
|
||||
export async function QueryPostAPI<T>(
|
||||
urlString: string,
|
||||
body?: unknown,
|
||||
headers?: [string, string][]
|
||||
headers?: [string, string][],
|
||||
contentType?: string
|
||||
): Promise<APIRoot<T>> {
|
||||
return await QueryPostAPIWithParams<T>(
|
||||
urlString,
|
||||
undefined,
|
||||
body,
|
||||
'application/json',
|
||||
contentType || 'application/json',
|
||||
headers
|
||||
)
|
||||
}
|
||||
@@ -59,11 +60,15 @@ async function QueryPostAPIWithParamsInternal<T>(
|
||||
})
|
||||
if (cookie.value.cookie) h['Authorization'] = `Bearer ${cookie.value.cookie}`
|
||||
|
||||
h['Content-Type'] = contentType
|
||||
// 当使用FormData时,不手动设置Content-Type,让浏览器自动添加boundary
|
||||
if (!(body instanceof FormData)) {
|
||||
h['Content-Type'] = contentType
|
||||
}
|
||||
|
||||
return await QueryAPIInternal<T>(url, {
|
||||
method: 'post',
|
||||
headers: h,
|
||||
body: typeof body === 'string' ? body : JSON.stringify(body)
|
||||
body: body instanceof FormData ? body : typeof body === 'string' ? body : JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
async function QueryAPIInternal<T>(url: URL, init: RequestInit) {
|
||||
|
||||
Reference in New Issue
Block a user