perf: ♻️ Improved device connection stability

This commit is contained in:
viarotel 2024-11-27 19:29:33 +08:00
parent 88a03564a5
commit 1d603abb3e
3 changed files with 22 additions and 7 deletions

View File

@ -43,6 +43,10 @@ export default {
type: Function,
default: () => () => false,
},
handleRefresh: {
type: Function,
default: () => () => false,
},
},
data() {
return {
@ -90,6 +94,8 @@ export default {
this.$message.warning(error.message)
}
this.handleRefresh()
this.stopLoading = false
},
},

View File

@ -83,6 +83,7 @@
</template>
<script>
import { sleep } from '$/utils'
import PairDialog from './PairDialog/index.vue'
export default {
@ -90,7 +91,7 @@ export default {
PairDialog,
},
props: {
reload: {
handleRefresh: {
type: Function,
default: () => () => false,
},
@ -117,7 +118,7 @@ export default {
const autoConnect = this.$store.preference.data.autoConnect
if (autoConnect) {
await this.handleBatch()
this.reload()
this.handleRefresh()
}
},
methods: {
@ -237,6 +238,7 @@ export default {
try {
await this.$adb.connect(params.host, params.port || 5555)
await sleep()
this.$message.success(this.$t('device.wireless.connect.success'))
@ -248,6 +250,8 @@ export default {
}
}
this.handleRefresh()
this.loading = false
},
handleSave(params) {

View File

@ -2,7 +2,7 @@
<div class="h-full flex flex-col">
<div class="flex-none flex items-center py-1 overflow-x-auto">
<div class="flex-none">
<WirelessGroup ref="wirelessGroupRef" :reload="getDeviceData" />
<WirelessGroup ref="wirelessGroupRef" v-bind="{ handleRefresh }" />
</div>
<div class="w-px h-7 !mx-4 bg-gray-200 dark:bg-gray-600 flex-none"></div>
@ -96,7 +96,7 @@
<MoreDropdown v-bind="{ row, toggleRowExpansion, handleReset }" />
<WirelessAction v-bind="{ row, handleConnect }" />
<WirelessAction v-bind="{ row, handleConnect, handleRefresh }" />
</el-table-column>
<el-table-column type="expand">
<template #header>
@ -215,7 +215,7 @@ export default {
async handleRefresh() {
this.loading = true
await sleep(500)
await sleep()
this.getDeviceData({ resetResolve: true, unloading: true })
},
@ -262,11 +262,16 @@ export default {
this.deviceList = data
}
catch (error) {
const message = error?.message || error?.cause?.message
const message = error?.message || error?.cause?.message || ''
console.warn(message)
if (message && !message.includes('daemon not running')) {
if (message.includes('daemon not running')) {
this.getDeviceData()
return false
}
if (message) {
this.$message.warning(message)
}