ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
```js import * as request from '@/common/request' export default { getList(map = {}) { map.storage = map.storage || ''; return new Promise((resolve, reject) => { request.fly.get('/image', map).then(response => { resolve(response) }) }) }, delete(id) { return new Promise((resolve, reject) => { request.fly.delete('/image/' + id).then(response => { resolve(response) }) }) }, async upload(f, data = {}) { const response = await request.fly.get("/config/storage"); const storageType = response.data.name; // console.log(storageType); switch (storageType) { case "local": { return this.uploadLocal(f, data); } case "qiniu": //有安全问题,七牛的配置文件必须写到客户端或者从服务器读取到客户端 { //return this.uploadQiniu(f, data); } } }, uploadLocal(f, data = {}) { const formData = Object.assign({}, data, { "storage": "local" }); return new Promise((resolve, reject) => { uni.uploadFile({ url: request.config.uploadUrl, filePath: f, name: 'file', //单一文件上传必须使用file作为key header: {}, formData: formData, success: (uploadFileRes) => { // console.log(uploadFileRes.data); let res_data=uploadFileRes.data; resolve( JSON.parse(res_data)) }, fail: () => { resolve(false); } }); }); }, }; ```