|
17 | 17 | <div class="mb-4" v-if="type === 'website'">
|
18 | 18 | <el-alert :closable="false" type="warning" :title="$t('website.websiteBackupWarn')"></el-alert>
|
19 | 19 | </div>
|
20 |
| - <el-upload ref="uploadRef" drag :on-change="fileOnChange" class="upload-demo" :auto-upload="false"> |
| 20 | + <el-upload |
| 21 | + :limit="1" |
| 22 | + ref="uploadRef" |
| 23 | + drag |
| 24 | + :on-exceed="handleExceed" |
| 25 | + :on-change="fileOnChange" |
| 26 | + class="upload-demo" |
| 27 | + :auto-upload="false" |
| 28 | + > |
21 | 29 | <el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
22 | 30 | <div class="el-upload__text">
|
23 | 31 | {{ $t('database.dropHelper') }}
|
|
48 | 56 | </div>
|
49 | 57 | </template>
|
50 | 58 | </el-upload>
|
51 |
| - <el-button :disabled="isUpload" v-if="uploaderFiles.length === 1" icon="Upload" @click="onSubmit"> |
| 59 | + <el-button :disabled="isUpload || uploaderFiles.length !== 1" icon="Upload" @click="onSubmit"> |
52 | 60 | {{ $t('commons.button.upload') }}
|
53 | 61 | </el-button>
|
54 | 62 |
|
|
128 | 136 | import { reactive, ref } from 'vue';
|
129 | 137 | import { computeSize } from '@/utils/util';
|
130 | 138 | import i18n from '@/lang';
|
131 |
| -import { UploadFile, UploadFiles, UploadInstance } from 'element-plus'; |
| 139 | +import { UploadFile, UploadFiles, UploadInstance, genFileId } from 'element-plus'; |
132 | 140 | import { File } from '@/api/interface/file';
|
133 | 141 | import DrawerHeader from '@/components/drawer-header/index.vue';
|
134 | 142 | import { BatchDeleteFile, CheckFile, ChunkUploadFileData, GetUploadList } from '@/api/modules/files';
|
@@ -280,6 +288,13 @@ const handleClose = () => {
|
280 | 288 | upVisible.value = false;
|
281 | 289 | };
|
282 | 290 |
|
| 291 | +const handleExceed: UploadProps['onExceed'] = (files) => { |
| 292 | + uploadRef.value!.clearFiles(); |
| 293 | + const file = files[0] as UploadRawFile; |
| 294 | + file.uid = genFileId(); |
| 295 | + uploadRef.value!.handleStart(file); |
| 296 | +}; |
| 297 | +
|
283 | 298 | const onSubmit = async () => {
|
284 | 299 | if (uploaderFiles.value.length !== 1) {
|
285 | 300 | return;
|
|
0 commit comments