Skip to content

Commit

Permalink
fix: 修复scrcpy参数缺失问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lei1248276 committed Aug 13, 2024
1 parent df91c61 commit 75d34b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/scrcpy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { spawn } from 'node:child_process'
import EventEmitter from 'node:stream'
import { ipcMain, Notification } from 'electron'
import { updateTray } from '../tray'
import { appStore } from '../store/appStore'

const Noti = {
get error() {
Expand Down Expand Up @@ -70,7 +71,7 @@ const Scrcpy = {
}
}

ipcMain.on('scrcpy', (_, ip: string, options: string[]) => {
ipcMain.on('scrcpy', (_, ip: string, options: string[] = appStore.get('scrcpyOptions')) => {
if (ip) {
Scrcpy.start(['--tcpip=' + ip, ...options])
updateTray({ label: ip, checked: true })
Expand Down
7 changes: 5 additions & 2 deletions src/main/tray/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ function showInputBox() {
</html>`
)

win.webContents.once('ipc-message', (_, _ip) => {
win.webContents.once('ipc-message', (_, _ip: string) => {
console.log('输入的内容:', _ip)
win.close()

const _ips = appStore.get('ips')
!_ips.includes(_ip) && ipcMain.emit('setStoreIps', undefined, [_ip].concat(_ips))
if (!_ips.includes(_ip)) {
_ips.unshift(_ip)
ipcMain.emit('setStoreIps', undefined, _ips)
}
ipcMain.emit('scrcpy', undefined, _ip)
})
}
Expand Down

0 comments on commit 75d34b3

Please sign in to comment.