-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: ✨ Support for custom startup mirroring
- Loading branch information
Showing
32 changed files
with
602 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...onents/Device/components/MoreDropdown/components/Custom/components/DeployDialog/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<TemplatePromise v-slot="{ resolve, reject }"> | ||
<el-dialog | ||
v-model="visible" | ||
:title="$t('device.actions.more.custom.name')" | ||
class="w-11/12 el-dialog-flex el-dialog-beautify" | ||
append-to-body | ||
destroy-on-close | ||
@close="close(reject)" | ||
> | ||
<div class="h-full overflow-auto -mx-2 pr-2"> | ||
<PreferenceForm | ||
ref="preferenceFormRef" | ||
v-model="preferenceData" | ||
tag="el-collapse-item" | ||
v-bind="{ | ||
collapseProps: { accordion: true }, | ||
excludes: ['common'], | ||
}" | ||
/> | ||
</div> | ||
|
||
<template #footer> | ||
<el-button @click="close(reject)"> | ||
取消 | ||
</el-button> | ||
<el-button type="primary" @click="submit(resolve)"> | ||
确定 | ||
</el-button> | ||
</template> | ||
</el-dialog> | ||
</TemplatePromise> | ||
</template> | ||
|
||
<script setup> | ||
import { createTemplatePromise } from '@vueuse/core' | ||
import { nextTick } from 'vue' | ||
import { usePreferenceStore } from '$/store/index.js' | ||
import PreferenceForm from '$/components/Preference/components/PreferenceForm/index.vue' | ||
const TemplatePromise = createTemplatePromise() | ||
const preferenceStore = usePreferenceStore() | ||
const visible = ref(false) | ||
const preferenceFormRef = ref(null) | ||
const preferenceData = ref({ | ||
...getDefaultData(), | ||
}) | ||
const collapseValue = ref([]) | ||
const device = ref(null) | ||
async function open(row) { | ||
device.value = row | ||
visible.value = true | ||
return TemplatePromise.start() | ||
} | ||
async function submit(resolve) { | ||
const data = await preferenceFormRef.value.generateCommand() | ||
visible.value = false | ||
resolve(data) | ||
} | ||
async function close(reject) { | ||
visible.value = false | ||
await nextTick() | ||
preferenceData.value = { ...getDefaultData() } | ||
reject(new Error('User cancel operation')) | ||
} | ||
function getDefaultData() { | ||
return preferenceStore.getDefaultData('global', () => void 0) | ||
} | ||
defineExpose({ | ||
open, | ||
close, | ||
}) | ||
</script> | ||
|
||
<style></style> |
84 changes: 84 additions & 0 deletions
84
src/components/Device/components/MoreDropdown/components/Custom/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<slot :loading="loading" :trigger="handleClick" /> | ||
|
||
<DeployDialog ref="deployDialogRef" /> | ||
</template> | ||
|
||
<script> | ||
import DeployDialog from './components/DeployDialog/index.vue' | ||
import { sleep } from '$/utils' | ||
export default { | ||
components: { | ||
DeployDialog, | ||
}, | ||
props: { | ||
row: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
toggleRowExpansion: { | ||
type: Function, | ||
default: () => () => false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
loading: false, | ||
} | ||
}, | ||
methods: { | ||
async handleClick() { | ||
const row = this.row | ||
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 */ | ||
const isCamera = ['--camera-facing'].some(key => args.includes(key)) | ||
if (isCamera) { | ||
args += ' --video-source=camera' | ||
} | ||
this.toggleRowExpansion(row, true) | ||
try { | ||
const mirroring = this.$scrcpy.mirror(row.id, { | ||
title: this.$store.device.getLabel(row), | ||
args, | ||
stdout: this.onStdout, | ||
stderr: this.onStderr, | ||
}) | ||
await sleep(1 * 1000) | ||
this.loading = false | ||
await mirroring | ||
} | ||
catch (error) { | ||
console.error('mirror.args', args) | ||
console.error('mirror.error', error) | ||
if (error.message) { | ||
this.$message.warning(error.message) | ||
} | ||
} | ||
}, | ||
onStdout() {}, | ||
onStderr() {}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/components/Preference/components/PreferenceForm/components/Input/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<el-input | ||
class="!w-full" | ||
v-bind="{ | ||
clearable: true, | ||
...(data.props || {}), | ||
}" | ||
> | ||
<template v-if="data.append" #append> | ||
{{ data.append }} | ||
</template> | ||
</el-input> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
data: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
27 changes: 27 additions & 0 deletions
27
src/components/Preference/components/PreferenceForm/components/InputNumber/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<el-input | ||
class="!w-full" | ||
v-bind="{ | ||
type: 'number', | ||
clearable: true, | ||
...(data.props || {}), | ||
}" | ||
> | ||
<template v-if="data.append" #append> | ||
{{ data.append }} | ||
</template> | ||
</el-input> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
data: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
8 changes: 4 additions & 4 deletions
8
...Preference/components/PathInput/index.vue → ...erenceForm/components/InputPath/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/components/Preference/components/PreferenceForm/components/Select/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<el-select | ||
v-bind="{ | ||
clearable: true, | ||
...(data.props || {}), | ||
}" | ||
class="!w-full" | ||
> | ||
<el-option | ||
v-for="(item, index) in data.options" | ||
:key="index" | ||
:label="$t(item.label)" | ||
:value="item.value" | ||
:title="$t(item.placeholder || item.label)" | ||
> | ||
</el-option> | ||
</el-select> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
data: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
4 changes: 1 addition & 3 deletions
4
...nce/components/AudioCodecSelect/index.vue → ...orm/components/SelectAudioCodec/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.