perf: ♻️ Support interruption during waiting for wireless connection

This commit is contained in:
viarotel 2024-11-08 14:15:49 +08:00
parent 0f3d869d07
commit 344b385d33

View File

@ -56,15 +56,27 @@
> >
</el-input> </el-input>
<el-button <el-button-group>
type="primary" <el-button
:icon="loading ? '' : 'Connection'" type="primary"
:loading="loading" :icon="loading ? '' : 'Connection'"
class="flex-none" :loading="loading"
@click="handleConnect()" class="flex-none"
> @click="handleConnect()"
{{ $t('device.wireless.connect.name') }} >
</el-button> {{ $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" /> <PairDialog ref="pairDialog" @success="onPairSuccess" />
</div> </div>
@ -209,6 +221,10 @@ export default {
this.$message.warning(this.$t('device.wireless.connect.batch.error')) this.$message.warning(this.$t('device.wireless.connect.batch.error'))
}, },
handleUnConnect() {
this.loading = false
},
async handleConnect(params = this.formData) { async handleConnect(params = this.formData) {
if (!params.host) { if (!params.host) {
this.$message.warning( this.$message.warning(
@ -227,7 +243,9 @@ export default {
this.handleSave(params) this.handleSave(params)
} }
catch (error) { catch (error) {
this.handleError(error?.message || error?.cause?.message || error) if (this.loading) {
this.handleError(error?.message || error?.cause?.message || error)
}
} }
this.loading = false this.loading = false