Skip to content

Commit

Permalink
perf: ♻️ Support interruption during waiting for wireless connection
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 8, 2024
1 parent 0f3d869 commit 344b385
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/components/Device/components/WirelessGroup/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,27 @@
>
</el-input>

<el-button
type="primary"
:icon="loading ? '' : 'Connection'"
:loading="loading"
class="flex-none"
@click="handleConnect()"
>
{{ $t('device.wireless.connect.name') }}
</el-button>
<el-button-group>
<el-button
type="primary"
:icon="loading ? '' : 'Connection'"
:loading="loading"
class="flex-none"
@click="handleConnect()"
>
{{ $t('device.wireless.connect.name') }}
</el-button>

<el-button
v-if="loading"
type="default"
plain
class="flex-none"
@click="handleUnConnect()"
>
{{ $t('common.cancel') }}
</el-button>
</el-button-group>

<PairDialog ref="pairDialog" @success="onPairSuccess" />
</div>
Expand Down Expand Up @@ -209,6 +221,10 @@ export default {
this.$message.warning(this.$t('device.wireless.connect.batch.error'))
},
handleUnConnect() {
this.loading = false
},
async handleConnect(params = this.formData) {
if (!params.host) {
this.$message.warning(
Expand All @@ -227,7 +243,9 @@ export default {
this.handleSave(params)
}
catch (error) {
this.handleError(error?.message || error?.cause?.message || error)
if (this.loading) {
this.handleError(error?.message || error?.cause?.message || error)
}
}
this.loading = false
Expand Down

0 comments on commit 344b385

Please sign in to comment.