Skip to content

Commit

Permalink
perf: ♻️ Optimize mirror group
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 10, 2023
1 parent 48f6f5b commit 81c007f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/Device/components/ControlBar/MirrorGroup/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<el-dropdown :disabled="loading" @command="handleMirror">
<el-dropdown :disabled="loading" @command="handleCommand">
<div class="">
<slot :loading="loading" />
</div>
Expand All @@ -8,6 +8,12 @@
<el-dropdown-item v-for="item of 4" :key="item" :command="item">
{{ $t("device.control.mirror-group.open", { num: item }) }}
</el-dropdown-item>

<el-dropdown-item command="close">
<span class="" :title="$t('device.control.mirror-group.close.tips')">
{{ $t("device.control.mirror-group.close") }}
</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
Expand All @@ -33,22 +39,27 @@ export default {
preferenceData(...args) {
return this.$store.preference.getData(...args)
},
async handleMirror(open) {
console.log('handleMirror.open', open)
async handleCommand(command) {
console.log('handleCommand.command', command)
if (command === 'close') {
this.$adb.clearOverlayDisplayDevices(this.device.id)
return false
}
this.loading = true
try {
const res = await this.$scrcpy.mirrorGroup(this.device.id, {
open,
open: command,
title: ({ displayId }) =>
`${this.$store.device.getLabel(
this.device,
)}-displayId-${displayId}`,
args: this.scrcpyArgs(this.device.id),
})
console.log('handleMirror.res', res)
console.log('handleCommand.res', res)
res.forEach((item) => {
if (item.status === 'rejected') {
Expand Down
2 changes: 2 additions & 0 deletions src/locales/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
"device.control.mirror-group.name": "Mirror Group",
"device.control.mirror-group.tips": "When enabled, can mirror multiple simulated secondary displays and achieve multi-screen collaboration by operating each mirrored window. Note this requires ROM support and desktop mode enabled.",
"device.control.mirror-group.open": "Open {num} windows",
"device.control.mirror-group.close": "Close auxiliary display devices",
"device.control.mirror-group.close.tips": "Used to solve the issue of automatic closure failure after certain devices exit all control windows.",
"device.control.volume.name": "Volume",
"device.control.volume-up.name": "Volume Up",
"device.control.volume-down.name": "Volume Down",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/languages/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
"device.control.mirror-group.name": "多屏协同",
"device.control.mirror-group.tips": "开启后,可以同时镜像多个模拟辅助显示设备,并通过操作各个镜像窗口实现多屏协同功能。请注意,此功能需要手机 ROM 支持,并且必须开启强制使用桌面模式选项。",
"device.control.mirror-group.open": "开启 {num} 个窗口",
"device.control.mirror-group.close": "关闭辅助显示设备",
"device.control.mirror-group.close.tips": "用于解决某些机型退出所有控制窗口后自动关闭失败的问题",
"device.control.volume.name": "音量控制",
"device.control.volume-up.name": "增加音量",
"device.control.volume-down.name": "减小音量",
Expand Down

0 comments on commit 81c007f

Please sign in to comment.