perf: 优化刷新界面后任务进度显示不及时的问题

This commit is contained in:
jmal 2024-12-16 11:37:44 +08:00
parent eaa086de9f
commit 20961e86e0
2 changed files with 16 additions and 9 deletions

View File

@ -30,6 +30,10 @@ export default {
monitor: {
type: Boolean,
default: false
},
taskCount: {
type: Boolean,
default: false
}
},
computed: {
@ -46,17 +50,18 @@ export default {
]
}
},
mounted() {
getTaskProgress().then(res => {
this.dataList = res.data
this.$emit('update:task-count', this.dataList.length > 0)
})
},
watch: {
data(val) {
if (val) {
this.dataList = val
}
},
mounted() {
getTaskProgress().then(res => {
this.dataList = res.data
})
},
message(msg) {
if (this.monitor && msg.event === 'msg/taskCountChange') {
this.dataList = msg.data

View File

@ -8,8 +8,8 @@
placement="bottom"
width="600"
trigger="hover">
<TaskProgress/>
<div slot="reference" class="right-content-button" v-show="showTaskProgress > 0">
<TaskProgress :task-count.sync="taskCount"/>
<div slot="reference" class="right-content-button" v-show="showTaskProgress > 0 || taskCount > 0">
<svg-icon icon-class="gengxinjindu" :class="progressExecuting ? 'rotate' : ''"></svg-icon>
{{ $t('app.taskProgress') }}
</div>
@ -76,6 +76,7 @@ export default {
imageUrl: `${process.env.VUE_APP_BASE_API}/view/thumbnail?jmal-token=${this.$store.state.user.token}&name=${this.$store.state.user.name}&id=`,
defaultAvatar: require('../../assets/img/default-avatar.png'),
showTaskProgress: false,
taskCount: 0,
progressExecuting: false,
delayedHidden: null
}
@ -120,11 +121,12 @@ export default {
if (msg.event === 'msg/taskCountChange') {
this.taskCountChange(msg.data.length)
}
},
taskCount(count) {
this.progressExecuting = count > 0;
}
},
methods: {
handleSelect(key, keyPath) {
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},