feat: 本次提交更新内容如下

编辑素材构建完成
This commit is contained in:
2025-07-15 14:51:02 +08:00
parent 3955821f42
commit 721feafa7d
3 changed files with 96 additions and 17 deletions

18
nkebao/src/api/upload.ts Normal file
View File

@@ -0,0 +1,18 @@
import { request } from './request';
import type { AxiosResponse } from 'axios';
// 上传图片,返回图片地址
export async function uploadImage(file: File): Promise<string> {
const formData = new FormData();
formData.append('file', file);
const response: AxiosResponse<any> = await request.post('/v1/attachment/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
const res = response.data || response;
if (res?.url) {
return res.url;
}
throw new Error(res?.msg || '图片上传失败');
}