fix: 💄 Optimize wireless connection user interface

This commit is contained in:
viarotel 2024-07-25 10:28:28 +08:00
parent d72202b311
commit 50ae7426c0
6 changed files with 248 additions and 200 deletions

1
.npmrc
View File

@ -1,5 +1,6 @@
registry=https://registry.npmmirror.com/ registry=https://registry.npmmirror.com/
shamefully-hoist=true shamefully-hoist=true
virtual-store-dir-max-length=70
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_CUSTOM_DIR="{{ version }}" ELECTRON_CUSTOM_DIR="{{ version }}"

View File

@ -49,7 +49,7 @@
"electron-store": "^9.0.0", "electron-store": "^9.0.0",
"electron-updater": "^6.1.8", "electron-updater": "^6.1.8",
"element-plus": "^2.7.2", "element-plus": "^2.7.2",
"eslint": "^9.2.0", "eslint": "^8.57.0",
"fix-path": "^4.0.0", "fix-path": "^4.0.0",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"hono": "^4.3.2", "hono": "^4.3.2",

View File

@ -8,143 +8,147 @@
destroy-on-close destroy-on-close
@closed="onClosed" @closed="onClosed"
> >
<ele-form-row <div class="pr-24 pt-4">
ref="formRef" <ele-form-row
:model="model" ref="formRef"
:rules="rules" :model="model"
label-width="180px" :rules="rules"
class="!pr-24 !pt-4" label-width="180px"
> class=""
<ele-form-item-col
:label="$t('device.task.type')"
:span="24"
prop="taskType"
> >
<el-select <ele-form-item-col
v-model="model.taskType" :label="$t('device.task.type')"
:placeholder="$t('common.select.please')" :span="24"
clearable prop="taskType"
filterable
@change="onTaskChange"
> >
<el-option <el-select
v-for="item in taskModel" v-model="model.taskType"
:key="item.value" :placeholder="$t('common.select.please')"
:label="$t(item.label)" clearable
:value="item.value" filterable
@change="onTaskChange"
> >
</el-option> <el-option
</el-select> v-for="item in taskModel"
</ele-form-item-col> :key="item.value"
<ele-form-item-col :label="$t(item.label)"
:label="$t('device.task.frequency')" :value="item.value"
:span="24"
prop="timerType"
>
<el-radio-group v-model="model.timerType">
<el-radio
v-for="(item, index) of timerModel"
:key="index"
:value="item.value"
>
{{ $t(item.label) }}
</el-radio>
</el-radio-group>
</ele-form-item-col>
<ele-form-item-col
v-if="['timeout'].includes(model.timerType)"
:label="$t('device.task.timeout')"
:span="24"
prop="timeout"
>
<el-date-picker
v-model="model.timeout"
type="datetime"
placeholder="0000-00-00 00:00:00"
clearable
v-bind="{ disabledDate, defaultTime }"
></el-date-picker>
</ele-form-item-col>
<ele-form-item-col
v-if="['interval'].includes(model.timerType)"
:label="$t('device.task.interval')"
:span="24"
prop="interval"
>
<el-input
v-model="model.interval"
type="number"
placeholder="0"
clearable
>
<template #append>
<el-select
v-model="model.intervalType"
:placeholder="$t('common.select.please')"
filterable
class="!w-36"
> >
<el-option </el-option>
v-for="(item, index) of intervalModel" </el-select>
:key="index" </ele-form-item-col>
:label="$t(item.label)" <ele-form-item-col
:value="item.value" :label="$t('device.task.frequency')"
/> :span="24"
</el-select> prop="timerType"
</template> >
</el-input> <el-radio-group v-model="model.timerType">
</ele-form-item-col> <el-radio
v-for="(item, index) of timerModel"
:key="index"
:value="item.value"
>
{{ $t(item.label) }}
</el-radio>
</el-radio-group>
</ele-form-item-col>
<ele-form-item-col <ele-form-item-col
v-if="['install'].includes(model.taskType)" v-if="['timeout'].includes(model.timerType)"
:label="$t('device.task.extra.app')" :label="$t('device.task.timeout')"
:span="24" :span="24"
prop="extra" prop="timeout"
> >
<InputPath <el-date-picker
v-model="model.extra" v-model="model.timeout"
:placeholder="$t('device.control.install.placeholder')" type="datetime"
:data="{ placeholder="0000-00-00 00:00:00"
properties: ['openFile', 'multiSelections'], clearable
filters: [ v-bind="{ disabledDate, defaultTime }"
{ ></el-date-picker>
name: $t('device.control.install.placeholder'), </ele-form-item-col>
extensions: ['apk'],
},
],
}"
/>
</ele-form-item-col>
<ele-form-item-col <ele-form-item-col
v-if="['shell'].includes(model.taskType)" v-if="['interval'].includes(model.timerType)"
:label="$t('device.task.extra.shell')" :label="$t('device.task.interval')"
:span="24" :span="24"
prop="extra" prop="interval"
> >
<InputPath <el-input
v-model="model.extra" v-model="model.interval"
:placeholder="$t('device.control.shell.select')" type="number"
:data="{ placeholder="0"
properties: ['openFile'], clearable
filters: [ >
{ <template #append>
name: $t('device.control.shell.select'), <el-select
extensions: ['sh'], v-model="model.intervalType"
}, :placeholder="$t('common.select.please')"
], filterable
}" class="!w-36"
/> >
</ele-form-item-col> <el-option
v-for="(item, index) of intervalModel"
:key="index"
:label="$t(item.label)"
:value="item.value"
/>
</el-select>
</template>
</el-input>
</ele-form-item-col>
<ele-form-item-col :span="24" label=""> <ele-form-item-col
<div class="text-red-200 hover:text-red-500 transition-colors"> v-if="['install'].includes(model.taskType)"
{{ $t('device.task.tips') }} :label="$t('device.task.extra.app')"
</div> :span="24"
</ele-form-item-col> prop="extra"
</ele-form-row> >
<InputPath
v-model="model.extra"
:placeholder="$t('device.control.install.placeholder')"
:data="{
properties: ['openFile', 'multiSelections'],
filters: [
{
name: $t('device.control.install.placeholder'),
extensions: ['apk'],
},
],
}"
/>
</ele-form-item-col>
<ele-form-item-col
v-if="['shell'].includes(model.taskType)"
:label="$t('device.task.extra.shell')"
:span="24"
prop="extra"
>
<InputPath
v-model="model.extra"
:placeholder="$t('device.control.shell.select')"
:data="{
properties: ['openFile'],
filters: [
{
name: $t('device.control.shell.select'),
extensions: ['sh'],
},
],
}"
/>
</ele-form-item-col>
<ele-form-item-col :span="24" label="">
<div
class="text-red-200 dark:text-red-900 !hover:text-red-500 transition-colors"
>
{{ $t('device.task.tips') }}
</div>
</ele-form-item-col>
</ele-form-row>
</div>
<template #footer> <template #footer>
<el-button @click="close"> <el-button @click="close">

View File

@ -2,72 +2,85 @@
<el-dialog <el-dialog
v-model="visible" v-model="visible"
:title="$t('device.wireless.pair')" :title="$t('device.wireless.pair')"
width="600" width="80%"
append-to-body append-to-body
destroy-on-close destroy-on-close
> >
<div class="text-red-500 text-sm pb-8 pl-4"> <div class="pt-4 pr-24">
{{ $t("device.wireless.pair.tips") }} <el-form ref="elForm" :model="formData" label-width="160px" class="">
<el-form-item
:label="$t('device.wireless.pair.address')"
prop="host"
:rules="[
{
required: true,
message: $t('device.wireless.pair.address.message'),
},
]"
>
<el-input
v-model="formData.host"
:placeholder="$t('common.input.placeholder')"
class=""
clearable
>
</el-input>
</el-form-item>
<el-form-item
:label="$t('device.wireless.pair.port')"
prop="port"
:rules="[
{
required: true,
message: $t('device.wireless.pair.port.message'),
},
]"
>
<el-input
v-model.number="formData.port"
type="number"
:placeholder="$t('common.input.placeholder')"
:min="0"
clearable
class=""
>
</el-input>
</el-form-item>
<el-form-item
:label="$t('device.wireless.pair.code')"
prop="pair"
:rules="[
{
required: true,
message: $t('device.wireless.pair.code.message'),
},
]"
>
<el-input
v-model="formData.pair"
:placeholder="$t('common.input.placeholder')"
clearable
class=""
>
</el-input>
</el-form-item>
<el-form-item label="">
<div
class="text-red-200 dark:text-red-900 !hover:text-red-500 transition-colors"
>
{{ $t('device.wireless.pair.tips') }}
</div>
</el-form-item>
</el-form>
</div> </div>
<el-form ref="elForm" :model="formData" label-width="100px">
<el-form-item
:label="$t('device.wireless.pair.address')"
prop="host"
:rules="[
{
required: true,
message: $t('device.wireless.pair.address.message'),
},
]"
>
<el-input
v-model="formData.host"
:placeholder="$t('common.input.placeholder')"
class=""
clearable
>
</el-input>
</el-form-item>
<el-form-item
:label="$t('device.wireless.pair.port')"
prop="port"
:rules="[
{ required: true, message: $t('device.wireless.pair.port.message') },
]"
>
<el-input
v-model.number="formData.port"
type="number"
:placeholder="$t('common.input.placeholder')"
:min="0"
clearable
class=""
>
</el-input>
</el-form-item>
<el-form-item
:label="$t('device.wireless.pair.code')"
prop="pair"
:rules="[
{ required: true, message: $t('device.wireless.pair.code.message') },
]"
>
<el-input
v-model="formData.pair"
:placeholder="$t('common.input.placeholder')"
clearable
class=""
>
</el-input>
</el-form-item>
</el-form>
<template #footer> <template #footer>
<el-button @click="handleClose"> <el-button @click="handleClose">
{{ $t("common.cancel") }} {{ $t('common.cancel') }}
</el-button> </el-button>
<el-button type="primary" @click="handleSubmit"> <el-button type="primary" @click="handleSubmit">
{{ $t("common.confirm") }} {{ $t('common.confirm') }}
</el-button> </el-button>
</template> </template>
</el-dialog> </el-dialog>

View File

@ -251,17 +251,24 @@ export default {
async handleError(message) { async handleError(message) {
try { try {
await this.$confirm( await this.$confirm(
` `<div class="pt-4 pl-4">
<div class="pb-4 text-sm text-red-500">${this.$t( <div class="text-sm text-red-500 pb-4">${this.$t(
'device.wireless.connect.error.detail', 'device.wireless.connect.error.detail',
)}${message}</div> )}${message}</div>
<div>${this.$t('device.wireless.connect.error.reasons[0]')}</div> <div>${this.$t('device.wireless.connect.error.reasons[0]')}</div>
<div>1. ${this.$t('device.wireless.connect.error.reasons[1]')} </div> <div>1. ${this.$t(
<div>2. ${this.$t('device.wireless.connect.error.reasons[2]')} </div> 'device.wireless.connect.error.reasons[1]',
<div>3. ${this.$t('device.wireless.connect.error.reasons[3]')} </div> )} </div>
<div>4. ${this.$t('device.wireless.connect.error.reasons[4]')} </div> <div>2. ${this.$t(
<div>5. ${this.$t('device.wireless.connect.error.reasons[5]')} </div> 'device.wireless.connect.error.reasons[2]',
`, )} </div>
<div>3. ${this.$t(
'device.wireless.connect.error.reasons[3]',
)} </div>
<div>4. ${this.$t(
'device.wireless.connect.error.reasons[4]',
)} </div>
</div>`,
this.$t('device.wireless.connect.error.title'), this.$t('device.wireless.connect.error.title'),
{ {
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,

View File

@ -30,7 +30,30 @@
:label="$t('device.task.type')" :label="$t('device.task.type')"
align="center" align="center"
> >
{{ $t(getDictLabel(taskModel, row.taskType)) }} <div class="h-full flex items-center justify-center">
<el-dropdown :key="row.id" trigger="hover" :disabled="!row.extra">
<span
:class="
row.extra
? 'text-primary hover:underline'
: 'text-[var(--el-table-text-color)]'
"
>
{{ $t(getDictLabel(taskModel, row.taskType)) }}
</span>
<template v-if="row.extra" #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-for="(item, index) of row.extra.split(',')"
:key="index"
>
{{ item }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</el-table-column> </el-table-column>
<el-table-column <el-table-column