Skip to content

Commit

Permalink
perf: ♻️ Supports automatic execution of mirrors on devices
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Mar 21, 2024
1 parent 39bfd02 commit 11e0884
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 30 deletions.
10 changes: 6 additions & 4 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
## 特点

- 🏃 同步:得益于 Web 技术,将更快速的与 Scrcpy 保持同步
- 🤖 自动化:允许自动连接到历史设备并自动执行镜像。
- 💡 定制化:支持对多个设备偏好进行独立配置,并且能够添加备注以及导入导出所有配置的功能
- 🔗 反向供网:集成了 Gnirehtet 反向供网功能
- 🎨 主题:支持浅色模式和深色模式,跟随系统切换
Expand Down Expand Up @@ -197,10 +198,11 @@ Windows 及 Linux 端内部集成了 Gnirehtet, 用于提供 PC 到安卓设
14. 设备交互栏添加更多功能:文件推送、旋转屏幕、音频控制等功能 ✅
15. 支持批量连接历史设备功能 ✅
16. 支持使用内置终端执行自定义命令 ✅
17. 添加独立的剪切板同步功能 🚧
18. 支持通过界面从设备下载选中的文件 🚧
19. 支持对设备进行分组,以及按组进行批量操作 🚧
20. 添加对游戏的增强功能,如游戏键位映射 🚧
17. 支持设备自动执行镜像 ✅
18. 添加文件传输助手功能 🚧
19. 支持通过界面从设备下载选中的文件 🚧
20. 支持对设备进行分组,以及按组进行批量操作 🚧
21. 添加对游戏的增强功能,如游戏键位映射 🚧

## 常见问题

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
## Features

- 🏃 Synchronous: Benefit from web technologies to synchronize with Scrcpy faster
- 🤖 Automation: Enables automatic connection to historical devices and automatic execution of mirror.
- 💡 Customizable: Support independent configuration for multiple devices and ability to add notes and import/export all configurations
- 🎨 Theme: Supports light mode and dark mode, system-wide switching
- 🔗 Gnirehtet: Integrated Gnirehtet's reverse tethering functionality
Expand Down Expand Up @@ -195,10 +196,11 @@ Refer to [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master
14. Add more features to device interaction bar: file push, screen rotation, audio control etc ✅
15. Support bulk connecting to historical devices ✅
16. Support to use built-in terminals to execute custom commands ✅
17. Add standalone clipboard sync feature 🚧
18. Support GUI-based selective file downloads from devices 🚧
19. Support grouping devices and bulk operations by group 🚧
20. Add game enhancement features such as game keyboard mapping 🚧
17. Supports automatic execution of mirror on devices. ✅
18. Add file transmission assistant function 🚧
19. Support GUI-based selective file downloads from devices 🚧
20. Support grouping devices and bulk operations by group 🚧
21. Add game enhancement features such as game keyboard mapping 🚧

## FAQ

Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/components/MirrorAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
}
},
methods: {
async handleClick(row) {
async handleClick(row = this.row) {
this.loading = true
this.toggleRowExpansion(row, true)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/components/WirelessAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-if="!row.$wifi"
type="primary"
text
:disabled="row.$unauthorized || row.$loading || row.$recordLoading"
:disabled="row.$unauthorized"
@click="handleWifi(row)"
>
<template #icon>
Expand Down
70 changes: 52 additions & 18 deletions src/components/Device/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@
</template>
</el-table-column>
<el-table-column
v-slot="{ row }"
v-slot="{ row, $index }"
:label="$t('device.control.name')"
width="450"
align="left"
>
<MirrorAction v-bind="{ row, toggleRowExpansion, handleReset }" />
<MirrorAction
:ref="(value) => getMirrorActionRefs(value, $index)"
v-bind="{ row, toggleRowExpansion, handleReset }"
/>

<MoreDropdown v-bind="{ row, toggleRowExpansion, handleReset }" />

Expand Down Expand Up @@ -133,13 +136,18 @@ export default {
return {
loading: false,
deviceList: [],
mirrorActionRefs: [],
}
},
computed: {},
async created() {
this.getDeviceData()
this.unAdbWatch = await this.$adb.watch(async (type, ret) => {
this.unAdbWatch = await this.$adb.watch(this.onAdbWatch)
},
beforeUnmount() {
this?.unAdbWatch?.()
},
methods: {
async onAdbWatch(type, ret) {
if (ret && ret.id) {
this.getDeviceData()
}
Expand All @@ -150,12 +158,41 @@ export default {
host: ret.$host,
}
}
})
},
beforeUnmount() {
this?.unAdbWatch?.()
},
methods: {
if (type === 'remove') {
this.mirrorActionRefs = this.mirrorActionRefs.filter(
item => item.row.id !== ret.id,
)
}
},
async getMirrorActionRefs(ref, index) {
await this.$nextTick()
if (!ref?.row?.id) {
return false
}
const someFlag = this.mirrorActionRefs.some(
item => item.row.id === ref.row.id,
)
if (someFlag) {
return false
}
this.mirrorActionRefs.push(ref)
const secondNum = index
await sleep(secondNum * 2000)
const autoMirror = this.$store.preference.data.autoMirror
if (autoMirror) {
ref.handleClick(ref.row)
}
},
toggleRowExpansion(...args) {
this.$refs.elTable.toggleRowExpansion(...args)
},
Expand Down Expand Up @@ -208,16 +245,13 @@ export default {
async getDeviceData({ resetResolve = false } = {}) {
this.loading = true
await sleep(500)
try {
const data = await this.$store.device.getList()
this.deviceList
= data?.map(item => ({
...item,
$loading: false,
$recordLoading: false,
$stopLoading: false,
})) || []
this.deviceList = data
}
catch (error) {
console.warn(error)
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 @@ -183,6 +183,8 @@
"preferences.common.language.english": "English",
"preferences.common.auto-connect.name": "Auto Connect",
"preferences.common.auto-connect.placeholder": "When enabled, the software will attempt to automatically connect to historical devices upon startup.",
"preferences.common.auto-mirror.name": "Auto Mirror",
"preferences.common.auto-mirror.placeholder": "When enabled, devices in the device list will automatically execution the mirror.",

"preferences.video.name": "Video",
"preferences.video.disable-video.name": "Disable Video Forwarding",
Expand Down
6 changes: 4 additions & 2 deletions src/locales/languages/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@
"preferences.common.language.placeholder": "选择你需要的语言",
"preferences.common.language.chinese": "中文",
"preferences.common.language.english": "English",
"preferences.common.auto-connect.name": "自动连接历史设备",
"preferences.common.auto-connect.placeholder": "启用后,该软件将在启动时尝试自动连接到历史设备",
"preferences.common.auto-connect.name": "自动连接设备",
"preferences.common.auto-connect.placeholder": "启用后,该软件将在启动时尝试自动连接到历史无线设备",
"preferences.common.auto-mirror.name": "自动执行镜像",
"preferences.common.auto-mirror.placeholder": "启用后,设备列表中的设备将自动运行镜像",

"preferences.video.name": "视频控制",
"preferences.video.disable-video.name": "禁用视频转发",
Expand Down
7 changes: 7 additions & 0 deletions src/store/preference/model/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ export default {
value: undefined,
placeholder: 'preferences.common.auto-connect.placeholder',
},
autoMirror: {
label: 'preferences.common.auto-mirror.name',
field: 'autoMirror',
type: 'Switch',
value: undefined,
placeholder: 'preferences.common.auto-mirror.placeholder',
},
gnirehtetFix: {
label: 'preferences.common.gnirehtet.fix.name',
field: 'gnirehtetFix',
Expand Down

0 comments on commit 11e0884

Please sign in to comment.