diff --git a/README.md b/README.md index 8f4868b..076f96c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ ## 特点 - 🏃 同步:得益于 Web 技术,将更快速的与 Scrcpy 保持同步 +- 💡 定制化:支持对多个设备偏好进行独立配置,并且能够添加备注以及导入导出所有配置的功能 - 😎 轻巧度:本机支持,仅显示设备屏幕 - ⚡️ 性能:30~120 帧每秒,取决于设备 - 🌟 质量:1920×1080 或更高 @@ -113,12 +114,13 @@ 2. 内置的软件更新功能 ✅ 3. 录制和保存音视频 ✅ 4. 添加设备快捷交互控制栏 ✅ -5. 支持自定义设备名称,以及用户配置的导出及导入 ✅ -6. 支持自定义 Adb 及 Scrcpy 依赖 ✅ -7. 支持精简版本(不包含 Adb 及 Scrcpy 依赖)和完整版本以满足不同用户需求 🚧 -8. 添加 macOS 及 linux 操作系统的支持 🚧 -9. 支持语言国际化功能 🚧 -10. 添加对游戏的增强功能,如游戏键位映射 🚧 +5. 支持自定义 Adb 及 Scrcpy 依赖 ✅ +6. 支持自定义设备名称,以及偏好设置的导出及导入 ✅ +7. 定制化,支持对单个设备进行独立配置 ✅ +8. 支持精简版本(不包含 Adb 及 Scrcpy 依赖)和完整版本以满足不同用户需求 🚧 +9. 添加 macOS 及 linux 操作系统的支持 🚧 +10. 支持语言国际化功能 🚧 +11. 添加对游戏的增强功能,如游戏键位映射 🚧 ## 常见问题 diff --git a/electron/configs/index.js b/electron/configs/index.js index 1302784..94cd64b 100644 --- a/electron/configs/index.js +++ b/electron/configs/index.js @@ -2,6 +2,8 @@ import { resolve } from 'node:path' import { buildResolve, extraResolve } from '@electron/helpers/index.js' +export const desktopPath = process.env.DESKTOP_PATH + export const devPublishPath = resolve('dev-publish.yml') export const logoPath = buildResolve('logo.png') diff --git a/electron/exposes/adbkit/index.js b/electron/exposes/adbkit/index.js index 78e1a84..b2960a3 100644 --- a/electron/exposes/adbkit/index.js +++ b/electron/exposes/adbkit/index.js @@ -17,12 +17,26 @@ window.addEventListener('beforeunload', () => { } }) -appStore.onDidChange('scrcpy.adbPath', async (value) => { - console.log('onDidChange.scrcpy.adbPath.value', value) +appStore.onDidChange('scrcpy.global.adbPath', async (value, oldValue) => { + console.log('onDidChange.scrcpy.global.adbPath', value) + + if (!value) { + return false + } + + if (value === oldValue) { + return false + } + + if (value === client?.options?.bin) { + return false + } + if (client) { await client.kill().catch(e => console.warn(e)) client = null } + client = Adb.createClient({ bin: value }) }) @@ -108,7 +122,12 @@ const watch = async (callback) => { } export default () => { - client = Adb.createClient({ bin: appStore.get('scrcpy.adbPath') || adbPath }) + const binPath = appStore.get('scrcpy.global.adbPath') || adbPath + + client = Adb.createClient({ + bin: binPath, + }) + console.log('client', client) return { diff --git a/electron/exposes/scrcpy/index.js b/electron/exposes/scrcpy/index.js index 4ca4670..7a2cd9d 100644 --- a/electron/exposes/scrcpy/index.js +++ b/electron/exposes/scrcpy/index.js @@ -3,15 +3,13 @@ import appStore from '@electron/helpers/store.js' import { adbPath, scrcpyPath } from '@electron/configs/index.js' const shell = async (command, { stdout, stderr } = {}) => { + const spawnPath = appStore.get('scrcpy.global.scrcpyPath') || scrcpyPath const args = command.split(' ') - const scrcpyProcess = spawn( - appStore.get('scrcpy.scrcpyPath') || scrcpyPath, - args, - { - env: { ...process.env, ADB: adbPath }, - shell: true, - }, - ) + + const scrcpyProcess = spawn(spawnPath, args, { + env: { ...process.env, ADB: adbPath }, + shell: true, + }) scrcpyProcess.stdout.on('data', (data) => { const stringData = data.toString() diff --git a/electron/helpers/packaged.js b/electron/helpers/process.js similarity index 56% rename from electron/helpers/packaged.js rename to electron/helpers/process.js index 18a738c..c233812 100644 --- a/electron/helpers/packaged.js +++ b/electron/helpers/process.js @@ -1,6 +1,8 @@ -/** 在主进程中获取项目打包状态并将该值存储到环境变量中,从而在预加载脚本中及渲染进程中使用 */ +/** 在主进程中获取关键信息存储到环境变量中,从而在预加载脚本中及渲染进程中使用 */ /** 注意: app.isPackaged 可能被被某些方法改变所以请将该文件放到 main.js 必须位于非依赖项的顶部 */ import { app } from 'electron' process.env.IS_PACKAGED = JSON.stringify(app.isPackaged) + +process.env.DESKTOP_PATH = app.getPath('desktop') diff --git a/electron/helpers/store.js b/electron/helpers/store.js index 34a47d1..9a5ac21 100644 --- a/electron/helpers/store.js +++ b/electron/helpers/store.js @@ -3,8 +3,8 @@ import { createProxy } from './index.js' const appStore = new Store() -appStore.onDidAnyChange(() => { - console.log('appStore.onDidAnyChange', appStore.store) +appStore.onDidAnyChange((value) => { + console.log('appStore.onDidAnyChange.value', value) }) export default { diff --git a/electron/main.js b/electron/main.js index 74e8dbe..4013c71 100644 --- a/electron/main.js +++ b/electron/main.js @@ -2,8 +2,8 @@ import path from 'node:path' import { BrowserWindow, app, shell } from 'electron' import { electronApp, optimizer } from '@electron-toolkit/utils' -// packaged.js 必须位于非依赖项的顶部 -import './helpers/packaged.js' +// process.js 必须位于非依赖项的顶部 +import './helpers/process.js' import './helpers/store.js' import { icnsLogoPath, icoLogoPath, logoPath } from './configs/index.js' diff --git a/public/screenshot/about.jpg b/public/screenshot/about.jpg new file mode 100644 index 0000000..f5cd3f9 Binary files /dev/null and b/public/screenshot/about.jpg differ diff --git a/public/screenshot/about.png b/public/screenshot/about.png deleted file mode 100644 index b23f4b5..0000000 Binary files a/public/screenshot/about.png and /dev/null differ diff --git a/public/screenshot/preferences.jpg b/public/screenshot/preferences.jpg new file mode 100644 index 0000000..a766933 Binary files /dev/null and b/public/screenshot/preferences.jpg differ diff --git a/public/screenshot/preferences.png b/public/screenshot/preferences.png deleted file mode 100644 index b164cf4..0000000 Binary files a/public/screenshot/preferences.png and /dev/null differ diff --git a/src/components/Device/ControlBar/index.vue b/src/components/Device/ControlBar/index.vue index ccdd660..09071d6 100644 --- a/src/components/Device/ControlBar/index.vue +++ b/src/components/Device/ControlBar/index.vue @@ -83,12 +83,11 @@ export default { ], } }, - computed: { - scrcpyConfig() { - return this.$store.scrcpy.config - }, - }, + computed: {}, methods: { + scrcpyConfig(...args) { + return this.$store.scrcpy.getConfig(...args) + }, async handleInstall(device) { let files = null @@ -109,7 +108,7 @@ export default { } const messageEl = this.$message({ - message: ` 正在为 ${device.name} 安装应用中...`, + message: ` 正在为 ${device.$name} 安装应用中...`, icon: LoadingIcon, duration: 0, }) @@ -132,11 +131,11 @@ export default { if (successCount) { if (totalCount > 1) { this.$message.success( - `已成功将应用安装到 ${device.name} 中,共 ${totalCount}个,成功 ${successCount}个,失败 ${failCount}个`, + `已成功将应用安装到 ${device.$name} 中,共 ${totalCount}个,成功 ${successCount}个,失败 ${failCount}个`, ) } else { - this.$message.success(`已成功将应用安装到 ${device.name} 中`) + this.$message.success(`已成功将应用安装到 ${device.$name} 中`) } return } @@ -156,15 +155,19 @@ export default { }, async handleScreenCap(device) { const messageEl = this.$message({ - message: ` 正在截取 ${device.name} 的屏幕快照...`, + message: ` 正在截取 ${device.$name} 的屏幕快照...`, icon: LoadingIcon, duration: 0, }) - const fileName = `${device.name}-screencap-${dayjs().format( + const fileName = `${device.$remark ? `${device.$remark}-` : ''}${ + device.$name + }-${this.$replaceIP(device.id)}-screencap-${dayjs().format( 'YYYY-MM-DD-HH-mm-ss', )}.png` - const savePath = this.$path.resolve(this.scrcpyConfig.savePath, fileName) + + const deviceConfig = this.scrcpyConfig(device.id) + const savePath = this.$path.resolve(deviceConfig.savePath, fileName) try { await this.$adb.screencap(device.id, { savePath }) diff --git a/src/components/Device/index.vue b/src/components/Device/index.vue index 5fc0a90..b7e2f54 100644 --- a/src/components/Device/index.vue +++ b/src/components/Device/index.vue @@ -65,12 +65,7 @@ align="left" width="200" /> - +