fix: 修复上传大量文件传输进度条卡住的问题
This commit is contained in:
parent
2944bfca05
commit
e3f50a1072
@ -16,11 +16,11 @@ export default {
|
||||
})
|
||||
},
|
||||
// 检查文件是否存在
|
||||
checkExist: function (params) {
|
||||
checkExist: function (data) {
|
||||
return request({
|
||||
url: "checkExist",
|
||||
method: "post",
|
||||
params
|
||||
data
|
||||
})
|
||||
},
|
||||
// 上传文件夹
|
||||
|
||||
@ -1490,6 +1490,9 @@ export default {
|
||||
this.path = ''
|
||||
}
|
||||
if (fileDoc) {
|
||||
if (this.$store.state.uploaderState) {
|
||||
return
|
||||
}
|
||||
if (fileDoc.$set) {
|
||||
let path = fileDoc.$set.path
|
||||
path = path.replace(/\\/g, '/')
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
>
|
||||
<uploader-unsupport></uploader-unsupport>
|
||||
|
||||
<uploader-drop v-if="dragover && enableDragUplaod" class="uploader-drop">
|
||||
<uploader-drop v-if="dragover && enableDragUpload" class="uploader-drop">
|
||||
<span>上传文件到当前目录下</span>
|
||||
</uploader-drop>
|
||||
|
||||
@ -190,7 +190,7 @@ export default {
|
||||
fileListScrollTop: 0,
|
||||
dragoverLoop: null,
|
||||
successMsg: null,
|
||||
enableDragUplaod: false,// 是否启用拖拽上传
|
||||
enableDragUpload: false,// 是否启用拖拽上传
|
||||
uploader: null,
|
||||
}
|
||||
},
|
||||
@ -200,7 +200,7 @@ export default {
|
||||
watch: {
|
||||
$route(route) {
|
||||
// 只有首页才启用拖拽上传
|
||||
this.enableDragUplaod = route.path === '/'
|
||||
this.enableDragUpload = route.path === '/'
|
||||
},
|
||||
message(msg) {
|
||||
switch (msg.event) {
|
||||
@ -234,12 +234,12 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.enableDragUplaod = this.$route.path === '/'
|
||||
this.enableDragUpload = this.$route.path === '/'
|
||||
let that = this
|
||||
let dropbox = document.body
|
||||
|
||||
document.body.ondragstart = function (e) {
|
||||
if (that.enableDragUplaod) {
|
||||
if (that.enableDragUpload) {
|
||||
if (e.target.slot === 'jmal') {
|
||||
that.isDragStart = true
|
||||
}
|
||||
@ -357,6 +357,10 @@ export default {
|
||||
this.doUploadBefore(files)
|
||||
}
|
||||
},
|
||||
displayPanel(display) {
|
||||
this.panelShow = display
|
||||
this.$store.dispatch('updateUploaderState', display)
|
||||
},
|
||||
doUploadBefore(files) {
|
||||
this.fileListLength = this.uploader.fileList.length
|
||||
const filePaths = this.uploader.filePaths
|
||||
@ -382,7 +386,7 @@ export default {
|
||||
}
|
||||
if (window.pc) {
|
||||
this.pc = true
|
||||
this.panelShow = true
|
||||
this.displayPanel(true)
|
||||
} else {
|
||||
this.pc = false
|
||||
this.shrink()
|
||||
@ -490,7 +494,7 @@ export default {
|
||||
}
|
||||
if (this.process === -10 || this.process === 100 || this.fileListLength === 0) {
|
||||
this.uploader.cancel()
|
||||
this.panelShow = false
|
||||
this.displayPanel(false)
|
||||
}
|
||||
},
|
||||
onFileError(rootFile, file, response) {
|
||||
@ -641,7 +645,7 @@ export default {
|
||||
close() {
|
||||
if (this.process === -10 || this.process === 100 || this.fileListLength === 0) {
|
||||
this.uploader.cancel()
|
||||
this.panelShow = false
|
||||
this.displayPanel(false)
|
||||
} else {
|
||||
this.$confirm('还有文件正在上传, 确定要关闭吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@ -649,7 +653,7 @@ export default {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.uploader.cancel()
|
||||
this.panelShow = false
|
||||
this.displayPanel(false)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@ -16,16 +16,23 @@ const store = new Vuex.Store({
|
||||
getters,
|
||||
state: {
|
||||
message: null,
|
||||
uploaderState: null,
|
||||
},
|
||||
mutations: {
|
||||
setMessage(state, message) {
|
||||
state.message = message;
|
||||
},
|
||||
setUploaderState(state, uploaderState) {
|
||||
state.uploaderState = uploaderState;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
updateMessage({ commit }, message) {
|
||||
commit('setMessage', message);
|
||||
},
|
||||
updateUploaderState({ commit }, uploaderState) {
|
||||
commit('setUploaderState', uploaderState);
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user