perf: 💄 Optimize device refresh mode

This commit is contained in:
viarotel 2024-10-29 14:37:24 +08:00
parent 4508758fb3
commit ea75615a46

View File

@ -29,7 +29,7 @@
<div class="pt-4 flex-1 h-0 overflow-hidden"> <div class="pt-4 flex-1 h-0 overflow-hidden">
<el-table <el-table
ref="elTable" ref="elTable"
v-loading="loading" v-loading="loading && !deviceList.length"
:element-loading-text="$t('common.loading')" :element-loading-text="$t('common.loading')"
:data="deviceList" :data="deviceList"
style="width: 100%" style="width: 100%"
@ -213,8 +213,10 @@ export default {
this.$refs.wirelessGroupRef.connect(...args) this.$refs.wirelessGroupRef.connect(...args)
}, },
handleRefresh() { async handleRefresh() {
this.getDeviceData({ resetResolve: true }) this.loading = true
await sleep(500)
this.getDeviceData({ resetResolve: true, unloading: true })
}, },
async handleReset() { async handleReset() {
@ -247,10 +249,12 @@ export default {
} }
}, },
async getDeviceData({ resetResolve = false } = {}) { async getDeviceData(options = {}) {
this.loading = true const { resetResolve = false, unloading = false } = options
await sleep(500) if (!unloading) {
this.loading = true
}
try { try {
const data = await this.$store.device.getList() const data = await this.$store.device.getList()