Merge branch 'dev'

This commit is contained in:
viarotel 2024-07-14 16:33:39 +08:00
commit aa581d5166
2 changed files with 56 additions and 60 deletions

View File

@ -1,51 +1,50 @@
<template> <template>
<TemplatePromise v-slot="{ resolve, reject }"> <el-dialog
<el-dialog v-model="visible"
v-model="visible" :title="$t('device.actions.more.custom.name')"
:title="$t('device.actions.more.custom.name')" class="!w-[98%] el-dialog-flex el-dialog-beautify"
class="!w-[98%] el-dialog-flex el-dialog-beautify" append-to-body
append-to-body destroy-on-close
destroy-on-close @closed="onClosed"
@close="close(reject)" >
> <div class="h-full overflow-auto -mx-2 pr-2">
<div class="h-full overflow-auto -mx-2 pr-2"> <PreferenceForm
<PreferenceForm ref="preferenceFormRef"
ref="preferenceFormRef" v-model="preferenceData"
v-model="preferenceData" tag="el-collapse-item"
tag="el-collapse-item" v-bind="{
v-bind="{ collapseProps: { accordion: true },
collapseProps: { accordion: true }, excludes: ['common'],
excludes: ['common'], }"
}" />
/> </div>
</div>
<template #footer> <template #footer>
<el-button @click="close(reject)"> <el-button @click="close">
{{ $t('common.cancel') }} {{ $t('common.cancel') }}
</el-button> </el-button>
<el-button type="primary" @click="submit(resolve)"> <el-button type="primary" :loading @click="submit">
{{ $t('common.confirm') }} {{ $t('common.confirm') }}
</el-button> </el-button>
</template> </template>
</el-dialog> </el-dialog>
</TemplatePromise>
</template> </template>
<script setup> <script setup>
import { createTemplatePromise } from '@vueuse/core'
import { nextTick } from 'vue'
import { usePreferenceStore } from '$/store/index.js' import { usePreferenceStore } from '$/store/index.js'
import PreferenceForm from '$/components/Preference/components/PreferenceForm/index.vue' import PreferenceForm from '$/components/Preference/components/PreferenceForm/index.vue'
const TemplatePromise = createTemplatePromise() import { sleep } from '$/utils'
const emit = defineEmits(['success'])
const preferenceStore = usePreferenceStore() const preferenceStore = usePreferenceStore()
const visible = ref(false) const visible = ref(false)
const loading = ref(false)
const preferenceFormRef = ref(null) const preferenceFormRef = ref(null)
const preferenceData = ref({ const preferenceData = ref({
@ -56,29 +55,32 @@ const collapseValue = ref([])
const device = ref(null) const device = ref(null)
async function open(row) { async function open(args = {}) {
device.value = row device.value = args.row
visible.value = true visible.value = true
return TemplatePromise.start()
} }
async function submit(resolve) { async function close() {
const data = await preferenceFormRef.value.generateCommand()
visible.value = false visible.value = false
resolve(data)
} }
async function close(reject) { async function submit() {
loading.value = true
const command = await preferenceFormRef.value.generateCommand()
emit('success', command)
await sleep()
loading.value = false
visible.value = false visible.value = false
}
await nextTick() function onClosed() {
preferenceData.value = { ...getDefaultData() } preferenceData.value = { ...getDefaultData() }
reject(new Error('User cancel operation'))
} }
function getDefaultData() { function getDefaultData() {

View File

@ -1,7 +1,7 @@
<template> <template>
<slot :loading="loading" :trigger="handleClick" /> <slot :loading="loading" :trigger="handleClick" />
<DeployDialog ref="deployDialogRef" /> <DeployDialog ref="deployDialogRef" @success="handleScrcpy" />
</template> </template>
<script> <script>
@ -31,19 +31,13 @@ export default {
async handleClick() { async handleClick() {
const row = this.row const row = this.row
this.$refs.deployDialogRef.open({ row })
},
async handleScrcpy(args) {
const row = this.row
this.loading = true this.loading = true
let args = ''
try {
args = await this.$refs.deployDialogRef.open(row)
}
catch (error) {
this.loading = false
this.$message.warning(error.message)
return false
}
/** TODO */ /** TODO */
const isCamera = ['--camera-facing'].some(key => args.includes(key)) const isCamera = ['--camera-facing'].some(key => args.includes(key))
if (isCamera) { if (isCamera) {