Skip to content

Commit

Permalink
perf: ♻️ Optimize autoConnect historical devices
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 16, 2023
1 parent a57b847 commit 755a130
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
20 changes: 19 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
:name="item.prop"
lazy
>
<component :is="item.prop" v-if="isRender(item)" :ref="item.prop" />
<component
:is="item.prop"
v-if="isRender(item)"
:ref="item.prop"
:re-render="reRender"
/>
</el-tab-pane>
</el-tabs>
</div>
Expand Down Expand Up @@ -44,6 +49,7 @@ export default {
activeTab: 'Device',
renderTab: '',
rendered: true,
renderSign: false,
}
},
created() {
Expand Down Expand Up @@ -88,12 +94,24 @@ export default {
this.renderTab = ''
},
reRenderPost() {
this.renderSign = true
},
async onTabChange(prop) {
if (!this.renderSign) {
return false
}
switch (prop) {
case 'Device':
this.reRender()
break
case 'Preference':
this.reRender()
break
}
this.renderSign = false
},
},
}
Expand Down
14 changes: 10 additions & 4 deletions src/components/Preference/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ export default {
this.$store.theme.update(value)
},
},
'preferenceData.adbPath': {
handler() {
this.handleDevices()
},
},
// 列表设备发生变化后如果没有匹配到则默认选中 global
'scopeList': {
handler(value) {
Expand All @@ -283,12 +288,13 @@ export default {
},
},
created() {
this.handleSave = debounce(this.handleSave, 1000, {
leading: false,
trailing: true,
})
this.handleSave = debounce(this.handleSave, 1000)
this.handleDevices = debounce(this.handleDevices, 1000)
},
methods: {
handleDevices() {
this.$root.reRenderPost()
},
subModel(item) {
const children = item?.children || {}
const value = {}
Expand Down

0 comments on commit 755a130

Please sign in to comment.