Skip to content

Commit

Permalink
feat: ✨ Support to close the device screen when controlling
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 23, 2024
1 parent 10d0370 commit a84c775
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 14 deletions.
5 changes: 3 additions & 2 deletions control/electron/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export function initControlWindow(mainWindow) {

const controlWindow = new BrowserWindow({
icon: getLogoPath(),
width: 500,
minWidth: 500,
parent: mainWindow,
width: 700,
minWidth: 700,
height: 28,
maxHeight: 28,
frame: false,
Expand Down
17 changes: 13 additions & 4 deletions src/components/Device/components/ControlBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export default {
elIcon: 'Back',
command: 'input keyevent 4',
},
{
label: 'device.control.turnScreenOff',
elIcon: 'TurnOff',
scrcpyCommand: '--turn-screen-off',
tips: 'device.control.turnScreenOff.tips',
},
{
label: 'device.control.notification',
elIcon: 'Notification',
Expand Down Expand Up @@ -203,13 +209,16 @@ export default {
this.$refs.scrollableRef.scrollForward()
},
handleClick(row, trigger) {
if (row?.command) {
this.$adb.deviceShell(this.device.id, row.command)
if (trigger) {
trigger(row)
return false
}
if (trigger) {
trigger(row)
if (row?.command) {
this.$adb.deviceShell(this.device.id, row.command)
}
else if (row?.scrcpyCommand) {
this.$scrcpy.control(this.device.id, { command: row.scrcpyCommand })
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<el-table-column
v-slot="{ row, $index }"
:label="$t('device.control.name')"
min-width="300"
min-width="250"
align="left"
>
<MirrorAction
Expand Down
8 changes: 5 additions & 3 deletions src/locales/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"device.task.extra.shell": "Select Script",

"device.wireless.name": "Wireless",
"device.wireless.mode": "Wireless Mode",
"device.wireless.mode": "Wireless",
"device.wireless.mode.error": "Do not get the local area network connection address, please check the network",
"device.wireless.connect.name": "Connect",
"device.wireless.connect.error.title": "Connect failed",
Expand Down Expand Up @@ -121,11 +121,11 @@
"device.refresh.name": "Refresh",
"device.restart.name": "Restart",
"device.log.name": "Logs",
"device.mirror.start": "Mirror",
"device.mirror.start": "Connect",
"device.record.progress": "Recording",
"device.record.success.title": "Record Success",
"device.record.success.message": "Open record location?",
"device.actions.more.name": "More Operation",
"device.actions.more.name": "Extra",
"device.actions.more.record.name": "Start Recording",
"device.actions.more.camera.name": "Startup Camera",
"device.actions.more.recordCamera.name": "Record Camera",
Expand Down Expand Up @@ -166,6 +166,8 @@
"device.control.capture.success.message": "Open screenshot location?",
"device.control.capture.success.message.title": "Screenshot Success",
"device.control.reboot": "Reboot",
"device.control.turnScreenOff": "Turn screen off",
"device.control.turnScreenOff.tips": "Turn off the screen without affecting control",
"device.control.power": "Power",
"device.control.power.tips": "Turn screen on/off",
"device.control.notification": "Notification",
Expand Down
6 changes: 4 additions & 2 deletions src/locales/languages/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"device.task.extra.shell": "Выберите скрипт",

"device.wireless.name": "По WiFi",
"device.wireless.mode": "Режим беспроводного подключения",
"device.wireless.mode": "беспроводной",
"device.wireless.mode.error": "Не удалось получить адрес подключения локальной сети, проверьте сеть",
"device.wireless.connect.name": "Подключиться",
"device.wireless.connect.error.title": "Не удалось подключиться",
Expand Down Expand Up @@ -125,7 +125,7 @@
"device.record.progress": "Запись",
"device.record.success.title": "Запись успешна",
"device.record.success.message": "Открыть место сохранения записи?",
"device.actions.more.name": "Дополнительные действия",
"device.actions.more.name": "дополнительный",
"device.actions.more.record.name": "Начать запись",
"device.actions.more.camera.name": "Запустить камеры",
"device.actions.more.recordCamera.name": "Запись камеры",
Expand Down Expand Up @@ -166,6 +166,8 @@
"device.control.capture.success.message": "Открыть место сохранения скриншота?",
"device.control.capture.success.message.title": "Скриншот успешно создан",
"device.control.reboot": "Перезагрузить",
"device.control.turnScreenOff": "Выключить экран",
"device.control.turnScreenOff.tips": "Выключить экран без потери управления",
"device.control.power": "Питание",
"device.control.power.tips": "Включить/выключить экран",
"device.control.notification": "Уведомление",
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 @@ -166,6 +166,8 @@
"device.control.capture.success.message": "是否前往截屏位置进行查看?",
"device.control.capture.success.message.title": "截屏成功",
"device.control.reboot": "重启设备",
"device.control.turnScreenOff": "关闭屏幕",
"device.control.turnScreenOff.tips": "关闭屏幕而不影响控制",
"device.control.power": "电源键",
"device.control.power.tips": "可以用来开启或关闭屏幕",
"device.control.notification": "通知栏",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/languages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
"device.control.capture.success.message": "是否前往截圖位置進行檢視?",
"device.control.capture.success.message.title": "截圖成功",
"device.control.reboot": "重啟裝置",
"device.control.turnScreenOff": "關閉螢幕",
"device.control.turnScreenOff.tips": "關閉螢幕而不影響控制",
"device.control.power": "電源鍵",
"device.control.power.tips": "可以用來開啟或關閉螢幕",
"device.control.notification": "通知欄",
Expand Down
7 changes: 5 additions & 2 deletions src/utils/command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
* @returns {string} The formatted command line arguments string
*/
function stringify(options) {
if (typeof options === 'string') {
return options
}

if (!options || typeof options !== 'object' || Array.isArray(options)) {
console.warn('Options must be a plain object')
return ''
throw new TypeError('Options must be a plain object')
}

const args = []
Expand Down

0 comments on commit a84c775

Please sign in to comment.