This commit is contained in:
2025-07-02 21:10:47 +08:00
parent 93d46459f9
commit 2fce6350c6
6 changed files with 72 additions and 35 deletions
+27 -27
View File
@@ -559,34 +559,34 @@
canvas.toBlob(resolve, 'image/jpeg', 0.9)
);
// post_file("/upload", blob, `avatar_${Date.now()}.jpg`, (c) => {
// if (c.statusCode == 200) {
// if (c.data.err_code == 0) {
// //save_json("cookie", c.data.return.cookie)
// banner_alert('success', "更换成功", 950)
// } else {
// banner_alert('warning', "服务错误", 3000)
// }
// } else {
// banner_alert('danger', "网络连接错误:" + c.statusCode, 3000)
// }
// })
const formData = new FormData();
formData.append('file', blob, `avatar_${Date.now()}.jpg`);
formData.append('meta', JSON.stringify({
width: canvas.width,
height: canvas.height,
scale: currentScale.toFixed(2)
}));
const response = await fetch('/api/v1/file/upload', {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest'
post_file("/upload", blob, `avatar_${Date.now()}.jpg`, (c) => {
if (c.statusCode == 200) {
if (c.data.err_code == 0) {
//save_json("cookie", c.data.return.cookie)
banner_alert('success', "更换成功", 950)
} else {
banner_alert('warning', "服务错误", 3000)
}
} else {
banner_alert('danger', "网络连接错误:" + c.statusCode, 3000)
}
});
})
// const formData = new FormData();
// formData.append('file', blob, `avatar_${Date.now()}.jpg`);
// formData.append('meta', JSON.stringify({
// width: canvas.width,
// height: canvas.height,
// scale: currentScale.toFixed(2)
// }));
// const response = await fetch('/file/upload', {
// method: 'POST',
// body: formData,
// headers: {
// 'X-Requested-With': 'XMLHttpRequest'
// }
// });
if (!response.ok) throw new Error(`服务器错误: ${response.status}`);