perf: 优化消息Load效果

This commit is contained in:
kuaifan 2024-01-07 14:25:35 +08:00
parent 5f7d528d9d
commit 3631f511d4
3 changed files with 23 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<template>
<ETooltip :disabled="$isEEUiApp || windowTouch || content == ''" :content="content">
<ETooltip v-if="visible" :disabled="$isEEUiApp || windowTouch || content == ''" :content="content">
<svg v-if="type === 'svg'" viewBox="25 25 50 50" class="common-loading">
<circle cx="50" cy="50" r="20" fill="none" stroke-width="5" stroke-miterlimit="10" class="common-path"></circle>
</svg>
@ -19,6 +19,26 @@
type: [String, Number],
default: ''
},
delay: {
type: Number,
default: 0
}
},
data() {
return {
visible: this.delay === 0,
timer: null,
}
},
mounted() {
if (this.delay > 0) {
this.timer = setTimeout(_ => {
this.visible = true
}, this.delay)
}
},
beforeDestroy() {
this.timer && clearTimeout(this.timer)
}
}
</script>

View File

@ -215,7 +215,7 @@
<div v-if="msgData.error === true" class="error" @click="onError">
<Icon type="ios-alert" />
</div>
<Loading v-else-if="isLoading"/>
<Loading v-else-if="isLoading" :delay="300"/>
<template v-else>
<!--时间-->
<div v-if="timeShow" class="time" @click="timeShow=false">{{msgData.created_at}}</div>

View File

@ -7,7 +7,7 @@ export default {
isLoad(state) {
return function (key) {
const load = state.loads.find(item => item.key === key);
return load && load.num > 0
return !!(load && load.num > 0)
}
},