diff --git a/src/main/scrcpy/index.ts b/src/main/scrcpy/index.ts index 15789f6..9dbe19a 100644 --- a/src/main/scrcpy/index.ts +++ b/src/main/scrcpy/index.ts @@ -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() { @@ -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 }) diff --git a/src/main/tray/index.ts b/src/main/tray/index.ts index 12f3e91..aae836b 100644 --- a/src/main/tray/index.ts +++ b/src/main/tray/index.ts @@ -103,12 +103,15 @@ function showInputBox() { ` ) - 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) }) }