fix: 🔨 修复无线配对时表单验证错误

This commit is contained in:
viarotel 2023-10-11 19:06:12 +08:00
parent 8de04e0d6a
commit 7cd9ea3ae5
4 changed files with 39 additions and 13 deletions

View File

@ -48,3 +48,4 @@ publish:
provider: github provider: github
owner: viarotel-org owner: viarotel-org
repo: escrcpy repo: escrcpy
updaterCacheDirName: escrcpy-updater

View File

@ -1,6 +1,6 @@
{ {
"name": "escrcpy", "name": "escrcpy",
"version": "1.3.2", "version": "1.3.3",
"description": "Scrcpy Powered by Electron", "description": "Scrcpy Powered by Electron",
"author": "viarotel", "author": "viarotel",
"homepage": "https://github.com/viarotel-org/escrcpy", "homepage": "https://github.com/viarotel-org/escrcpy",

View File

@ -1,15 +1,23 @@
<template> <template>
<el-dialog v-model="visible" title="无线配对" width="600" append-to-body> <el-dialog v-model="visible" title="无线配对" width="600" append-to-body destroy-on-close>
<div class="text-red-500 text-sm pb-8 pl-4"> <div class="text-red-500 text-sm pb-8 pl-4">
注意可以在 开发者选项 -> 无线调试(可以点进去) -> 使用配对码配对设备 中获取以下信息 注意可以在 开发者选项 -> 无线调试(可以点进去) -> 使用配对码配对设备 中获取以下信息
</div> </div>
<el-form :model="formData" label-width="100px"> <el-form ref="elForm" :model="formData" label-width="100px">
<el-form-item label="配对IP地址" prop="host"> <el-form-item
label="配对IP地址"
prop="host"
:rules="[{ required: true, message: '配对码不能为空' }]"
>
<el-input v-model="formData.host" placeholder="请输入配对IP地址" class="" clearable> <el-input v-model="formData.host" placeholder="请输入配对IP地址" class="" clearable>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="配对端口号" prop="port"> <el-form-item
label="配对端口号"
prop="port"
:rules="[{ required: true, message: '配对码不能为空' }]"
>
<el-input <el-input
v-model.number="formData.port" v-model.number="formData.port"
type="number" type="number"
@ -73,15 +81,18 @@ export default {
}, },
async handleSubmit() { async handleSubmit() {
try { try {
await this.$refs.elForm.validate()
const command = `pair ${this.formData.host}:${this.formData.port} ${this.formData.pair}` const command = `pair ${this.formData.host}:${this.formData.port} ${this.formData.pair}`
// console.log(command) // console.log(command)
await this.$adb.rawShell(command) await this.$adb.shell(command)
this.$emit('success') this.$emit('success')
this.handleClose() this.handleClose()
} }
catch (error) { catch (error) {
if (error.message) {
this.$message.warning(error.message) this.$message.warning(error.message)
} }
}
}, },
}, },
} }

View File

@ -65,19 +65,30 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" width="350" align="left"> <el-table-column label="操作" width="350" align="left">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" :loading="row.$loading" @click="handleMirror(row)"> <el-button
type="primary"
:loading="row.$loading"
:disabled="row.$unauthorized"
@click="handleMirror(row)"
>
{{ row.$loading ? '镜像中' : '开始镜像' }} {{ row.$loading ? '镜像中' : '开始镜像' }}
</el-button> </el-button>
<el-button v-if="!row.$wireless" type="primary" @click="handleWifi(row)"> <el-button
v-if="!row.$wireless"
type="primary"
:disabled="row.$unauthorized"
@click="handleWifi(row)"
>
无线模式 无线模式
</el-button> </el-button>
<el-button type="default" @click="handleScreenUp(row)"> <el-button type="default" :disabled="row.$unauthorized" @click="handleScreenUp(row)">
点亮屏幕 点亮屏幕
</el-button> </el-button>
<el-button <el-button
v-if="row.$wireless" v-if="row.$wireless"
type="danger" type="danger"
:loading="row.$stopLoading" :loading="row.$stopLoading"
:disabled="row.$unauthorized"
@click="handleStop(row)" @click="handleStop(row)"
> >
{{ row.$stopLoading ? '断开中' : '断开连接' }} {{ row.$stopLoading ? '断开中' : '断开连接' }}
@ -182,7 +193,7 @@ export default {
'连接设备失败', '连接设备失败',
{ {
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
confirmButtonText: '配对', confirmButtonText: '无线配对',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}, },
@ -215,8 +226,10 @@ export default {
) )
} }
catch (error) { catch (error) {
if (error.message) {
this.$message.warning(error.message) this.$message.warning(error.message)
} }
}
row.$loading = false row.$loading = false
}, },
addScrcpyConfigs() { addScrcpyConfigs() {
@ -257,8 +270,9 @@ export default {
console.log('getDeviceData.data', this.deviceList) console.log('getDeviceData.data', this.deviceList)
} }
catch (error) { catch (error) {
if (error.message) if (error.message) {
this.$message.warning(error.message) this.$message.warning(error.message)
}
this.deviceList = [] this.deviceList = []
} }
this.loading = false this.loading = false