企业🤖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); } }); }); }, }; ```