perf: 优化远程应用上传弹窗

This commit is contained in:
halo
2023-05-08 21:41:17 +08:00
committed by Jiangjie.Bai
parent a99a5a6312
commit 7e6d78d223
4 changed files with 17 additions and 1 deletions

View File

@@ -1330,6 +1330,7 @@
},
"terminal": {
"Author": "Author",
"Uploading": "File uploading",
"UploadSucceed": "Upload succeed",
"UploadFailed": "Upload failed",
"Applets": "Remote apps",

View File

@@ -1325,6 +1325,7 @@
},
"terminal": {
"Author": "作者",
"Uploading": "ファイルのアップロード",
"UploadSucceed": "アップロード成功",
"UploadFailed": "アップロードに失敗しました",
"Applets": "リモートアプリケーション",

View File

@@ -1320,6 +1320,7 @@
"Author": "作者",
"BasePort": "监听端口",
"DatabasePort": "数据库协议端口",
"Uploading": "文件上传中",
"UploadSucceed": "上传成功",
"UploadFailed": "上传失败",
"Applets": "远程应用",

View File

@@ -2,6 +2,8 @@
<Dialog
:show-cancel="false"
:title="$tc('common.OfflineUpload')"
:before-close="handleClose"
:loading-status="!isFinished"
v-bind="$attrs"
@cancel="onCancel"
@confirm="onSubmit"
@@ -53,7 +55,8 @@ export default {
return {
hasFileFormatOrSizeError: false,
renderError: '',
file: null
file: null,
isFinished: true
}
},
methods: {
@@ -65,6 +68,13 @@ export default {
},
beforeUpload(file) {
},
handleClose(done) {
if (this.isFinished) {
done()
} else {
this.$message.warning(this.$tc('terminal.Uploading'))
}
},
onCancel() {
this.$emit('update:visible', false)
},
@@ -72,6 +82,7 @@ export default {
if (!this.file) {
return
}
this.isFinished = false
const form = new FormData()
form.append('file', this.file.raw)
this.$axios.post(
@@ -82,10 +93,12 @@ export default {
disableFlashErrorMsg: true
}
).then(res => {
this.isFinished = true
this.$message.success(this.$tc('terminal.UploadSucceed'))
this.$emit('update:visible', false)
this.$emit('upload-event', res)
}).catch(err => {
this.isFinished = true
const error = err.response.data
const msg = error?.message || error?.detail || error?.error || JSON.stringify(error)
this.$message.error(msg)