ui库和web端产品库合并版本(还需修复细节)
This commit is contained in:
24
ui/packages/basic/AiEditor/models.js
Normal file
24
ui/packages/basic/AiEditor/models.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import {Loading} from "element-ui"
|
||||
|
||||
export class UploadAdapter {
|
||||
constructor(loader, instance, action, params) {
|
||||
this.instance = instance
|
||||
this.action = action
|
||||
this.loader = loader
|
||||
this.params = params
|
||||
}
|
||||
|
||||
async upload() {
|
||||
const formData = new FormData()
|
||||
formData.append('file', await this.loader.file)
|
||||
const loading = Loading.service({})
|
||||
return this.instance.post(this.action, formData, {...this.params, returnError: true}).then(res => {
|
||||
if (res?.data) {
|
||||
return res.data.map(m => m.split(";")?.[0])
|
||||
} else return this.loader.status = "aborted" && Promise.reject()
|
||||
}).finally(() => loading.close())
|
||||
}
|
||||
|
||||
abort() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user