This commit is contained in:
Your Name
2026-03-23 18:02:16 +08:00
parent 18fee2e8f8
commit 250d173c2f
525 changed files with 10659 additions and 793 deletions
+26
View File
@@ -1,5 +1,31 @@
import config from '@/config'
import { RequestCodeEnum } from '@/enums/requestEnums'
import useAppStore from '@/stores/modules/app'
import { getToken } from '@/utils/auth'
import request from '@/utils/request'
/** 本地上传图片(与素材库「本地上传」同一接口),返回 data 含 url 相对路径 */
export async function uploadImageBlob(file: Blob, filename = 'screenshot.jpg') {
const appStore = useAppStore()
const formData = new FormData()
formData.append('file', file, filename)
formData.append('cid', '0')
const url = `${config.baseUrl}${config.urlPrefix}/upload/image`
const res = await fetch(url, {
method: 'POST',
headers: {
token: getToken() || '',
version: appStore.config.version || ''
},
body: formData
})
const json = await res.json()
if (json.code !== RequestCodeEnum.SUCCESS) {
throw new Error(json.msg || '上传失败')
}
return json.data as { id: number; uri: string; url: string }
}
export function fileCateAdd(params: Record<string, any>) {
return request.post({ url: '/file/addCate', params })
}