fix: 🐛 适配文件上传接口调整
This commit is contained in:
@@ -17,6 +17,22 @@ const FileAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
uploadFile(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
return request<any, FileInfo>({
|
||||
url: "/api/v1/files",
|
||||
method: "post",
|
||||
data: formData,
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
|
||||
@@ -67,7 +67,7 @@ const editorConfig = ref<Partial<IEditorConfig>>({
|
||||
uploadImage: {
|
||||
customUpload(file: File, insertFn: InsertFnType) {
|
||||
// 上传图片
|
||||
FileAPI.upload(file).then((res) => {
|
||||
FileAPI.uploadFile(file).then((res) => {
|
||||
// 插入图片
|
||||
insertFn(res.url, res.name, res.url);
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ const handleToFile = async () => {
|
||||
const file = dataURLtoFile(canvas.value.toDataURL(), "签名.png");
|
||||
|
||||
if (!file) return;
|
||||
const data = await FileAPI.upload(file);
|
||||
const data = await FileAPI.uploadFile(file);
|
||||
handleClearSign();
|
||||
imgUrl.value = data.url;
|
||||
};
|
||||
|
||||
@@ -458,7 +458,7 @@ const handleFileChange = async (event: Event) => {
|
||||
if (file) {
|
||||
// 调用文件上传API
|
||||
try {
|
||||
const data = await FileAPI.upload(file);
|
||||
const data = await FileAPI.uploadFile(file);
|
||||
// 更新用户头像
|
||||
userProfile.value.avatar = data.url;
|
||||
// 更新用户信息
|
||||
|
||||
Reference in New Issue
Block a user