Skip to content

Commit

Permalink
Merge pull request #334 from jamebal/dev
Browse files Browse the repository at this point in the history
perf: 优化刷新界面后任务进度显示不及时的问题
  • Loading branch information
jamebal authored Dec 16, 2024
2 parents 758a439 + 20961e8 commit b4f146f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/components/TaskProgress/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default {
monitor: {
type: Boolean,
default: false
},
taskCount: {
type: Boolean,
default: false
}
},
computed: {
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/layout/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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')
},
Expand Down

0 comments on commit b4f146f

Please sign in to comment.