wx-chant/api/upload.js
邹方成 38c440bd23 refactor: 移除注释并更新API基础URL
更新了多个文件中的API基础URL,并移除了冗余的注释和未使用的代码
清理了代码结构,提高了可读性
2025-11-06 20:25:33 +08:00

28 lines
814 B
JavaScript

function uploadFile(filePath) {
return new Promise((resolve, reject) => {
if (!filePath) {
const err = new Error('uploadFile requires a filePath parameter');
console.error('上传失败:未提供文件路径', err);
return reject(err);
}
wx.uploadFile({
filePath: filePath,
name: 'file',
url: 'https://dsjhd9s.tbmw.cn/api/admin/upload/image',
success: (res) => {
const data = JSON.parse(res.data);
resolve('https://dsjhd9s.tbmw.cn/' + data.preview_image_url);
},
fail: (err) => {
console.error('上传失败', err);
reject(err);
}
});
})
}
module.exports = uploadFile;