diff --git a/nezha-fronted/src/components/cli/fileDirectory.vue b/nezha-fronted/src/components/cli/fileDirectory.vue index 11d220cd4..20c90db63 100644 --- a/nezha-fronted/src/components/cli/fileDirectory.vue +++ b/nezha-fronted/src/components/cli/fileDirectory.vue @@ -9,7 +9,7 @@
-
{{$t('terminal.back')}}
+
{{$t('terminal.back')}}
@@ -58,7 +58,16 @@ export default { fileList: [], newFolderBoxShow: false, folder: '', - fileDirectoryLoading: false + fileDirectoryLoading: false, + timer: '' + } + }, + computed: { + updateUuid () { + return this.$store.getters.getUpdateUuid + }, + updateIndex () { + return this.$store.getters.getUpdateIndex } }, mounted () { @@ -69,6 +78,17 @@ export default { if (n) { this.init() } + }, + updateIndex (n) { + if (this.updateUuid == this.uuid) { + if (this.timer) { + clearTimeout(this.timer) + } + this.timer = setTimeout(() => { + this.getSftpPath(this.fileDirectory) + this.timer = null + }, 200) + } } }, methods: { @@ -169,6 +189,7 @@ export default { if (res.code == 200) { this.getSftpPath(this.fileDirectory) } else { + this.getSftpPath(this.fileDirectory) this.$message.error(res.msg) } }) diff --git a/nezha-fronted/src/components/cli/fileListState.vue b/nezha-fronted/src/components/cli/fileListState.vue index d30636bc1..4e2efbc61 100644 --- a/nezha-fronted/src/components/cli/fileListState.vue +++ b/nezha-fronted/src/components/cli/fileListState.vue @@ -177,12 +177,14 @@ export default { item.cancel.cancel('operation canceled by the user.') if (item.done || (item.fileLength === item.total)) { // 取消 上传 50-100 clearInterval(item.timer) - this.$delete('/terminal/sftp/cancel/' + item.tid).then(res => { - if (res.code === 200) { - } else { - this.$message.error(res.msg) - } - }) + if (item.tid) { + this.$delete('/terminal/sftp/cancel/' + item.tid).then(res => { + if (res.code === 200) { + } else { + this.$message.error(res.msg) + } + }) + } } } this.$store.dispatch('dispatchDelFileList', item) @@ -234,6 +236,7 @@ export default { item.isFinish = true clearInterval(item.timer) // todo 上传成功后 刷新对应terminal + this.$store.dispatch('upDateConsole', item.uuid) } }) }, 200) diff --git a/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue b/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue index 67c14d354..20565e158 100644 --- a/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue +++ b/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue @@ -101,7 +101,7 @@ export default { const vars = this.$store.getters.getVariablesArr.map(item => { return { name: item.name, - value: item.checked.join('|') + values: item.checked } }) const params = { diff --git a/nezha-fronted/src/store/terminalFile.js b/nezha-fronted/src/store/terminalFile.js index b9021080c..95826d404 100644 --- a/nezha-fronted/src/store/terminalFile.js +++ b/nezha-fronted/src/store/terminalFile.js @@ -1,7 +1,9 @@ const terminalFile = { state: { fileList: [], - uploadItem: {} + uploadItem: {}, + updateUuid: '', // 根据uuid的变化 判断页面是否需要刷新 + updateIndex: 1 }, mutations: { setFileList (state, arr) { @@ -15,6 +17,13 @@ const terminalFile = { }, setUploadItem (state, item) { state.uploadItem = item + }, + setUpdateUuid (state, uuid) { + state.updateUuid = uuid + state.updateIndex++ + if (state.updateIndex == 10) { + state.updateIndex = 1 + } } }, getters: { @@ -23,6 +32,12 @@ const terminalFile = { }, getUploadItem (state) { return state.uploadItem + }, + getUpdateUuid (state) { + return state.updateUuid + }, + getUpdateIndex (state) { + return state.updateIndex } }, actions: { @@ -37,6 +52,9 @@ const terminalFile = { }, uploadFile (store, item) { store.commit('setUploadItem', item) + }, + upDateConsole (store, uuid) { + store.commit('setUpdateUuid', uuid) } } }