|
5 | 5 | <el-button size="mini" plain class="filter-item" type="primary" icon="el-icon-refresh" @click="handleFilter">
|
6 | 6 | 刷新
|
7 | 7 | </el-button>
|
8 |
| - <el-button size="mini" plain class="filter-item" type="primary" icon="el-icon-upload" @click="dialogFormVisible = true"> |
9 |
| - 上传文件 |
10 |
| - </el-button> |
11 |
| - <el-button size="mini" plain class="filter-item" type="default" icon="el-icon-new" @click="createDirectory"> |
| 8 | + <el-dropdown trigger="click" size="mini" class="filter-item" style="margin-left: 10px; margin-right: 10px;" @command="handleUploadCommand"> |
| 9 | + <el-button size="mini" plain type="primary"> |
| 10 | + <i class="el-icon-upload el-icon--left"></i>上传<i class="el-icon-arrow-down el-icon--right"></i> |
| 11 | + </el-button> |
| 12 | + <el-dropdown-menu slot="dropdown"> |
| 13 | + <el-dropdown-item command="uploadFile">上传文件</el-dropdown-item> |
| 14 | + <el-dropdown-item command="uploadFolder">上传文件夹</el-dropdown-item> |
| 15 | + </el-dropdown-menu> |
| 16 | + </el-dropdown> |
| 17 | + <el-button size="mini" plain class="filter-item" type="primary" icon="el-icon-new" @click="createDirectory"> |
12 | 18 | 新建文件夹
|
13 | 19 | </el-button>
|
14 | 20 | <div class="filter-item" style="margin-left: 20px;">
|
|
94 | 100 | <el-upload
|
95 | 101 | v-if="bucketDetail.credentials"
|
96 | 102 | drag
|
| 103 | + multiple |
97 | 104 | action=""
|
98 | 105 | :auto-upload="true"
|
99 | 106 | :http-request="uploadFile"
|
@@ -238,9 +245,21 @@ export default {
|
238 | 245 | assert(file && file.Key, 'invalid file or filename')
|
239 | 246 | return file.Key.split('/').at(-1)
|
240 | 247 | },
|
| 248 | + handleUploadCommand (command) { |
| 249 | + this.dialogFormVisible = true |
| 250 | + if (command === 'uploadFolder') { |
| 251 | + this.$nextTick(() => { |
| 252 | + document.getElementsByClassName('el-upload__input')[0].webkitdirectory = true |
| 253 | + }) |
| 254 | + } else { |
| 255 | + this.$nextTick(() => { |
| 256 | + document.getElementsByClassName('el-upload__input')[0].webkitdirectory = false |
| 257 | + }) |
| 258 | + } |
| 259 | + }, |
241 | 260 | async uploadFile(param) {
|
242 | 261 | const file = param.file
|
243 |
| - const key = this.currentPath + file.name |
| 262 | + const key = this.currentPath + (file.webkitRelativePath ? file.webkitRelativePath : file.name) |
244 | 263 | const res = await oss.uploadAppFile(this.bucket, key, file, this.bucketDetail.credentials, { contentType: file.type })
|
245 | 264 | if (res.$response?.httpResponse?.statusCode !== 200) {
|
246 | 265 | return showError('文件上传失败:' + key)
|
|
0 commit comments