From b6986d14de2accee314dac1986f467fbd2893877 Mon Sep 17 00:00:00 2001 From: viarotel Date: Thu, 12 Oct 2023 17:35:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=9F=B3=E8=A7=86=E9=A2=91=E5=BD=95=E5=88=B6=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=9B=B4=E5=A4=9A=E7=9A=84=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release-assets.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 9 +- package.json | 6 +- pnpm-lock.yaml | 50 ++++++-- src/main/index.js | 7 +- src/main/ipcManage/handles/index.js | 41 +++++++ src/main/{ipc => ipcManage}/index.js | 8 +- src/main/{ipc => ipcManage}/updater/index.js | 3 +- src/preload/plugins/adbkit/index.js | 5 +- src/preload/plugins/index.js | 3 + src/preload/plugins/scrcpy/index.js | 5 +- src/renderer/src/App.vue | 19 ++- src/renderer/src/components/AboutUs/index.vue | 10 +- .../src/components/Advanced/index.vue | 104 ++++++++++------ src/renderer/src/components/Devices/index.vue | 112 ++++++++++++------ src/renderer/src/main.js | 5 + src/renderer/src/store/index.js | 15 +++ src/renderer/src/store/scrcpy/index.js | 80 +++++++++++++ .../scrcpy/model}/audio/index.js | 0 .../scrcpy/model}/device/index.js | 6 +- .../configs => store/scrcpy/model}/index.js | 1 + .../src/store/scrcpy/model/record/index.js | 28 +++++ .../scrcpy/model}/video/index.js | 91 ++++++++++---- .../scrcpy/model}/window/index.js | 0 25 files changed, 482 insertions(+), 130 deletions(-) create mode 100644 src/main/ipcManage/handles/index.js rename src/main/{ipc => ipcManage}/index.js (54%) rename src/main/{ipc => ipcManage}/updater/index.js (98%) create mode 100644 src/renderer/src/store/index.js create mode 100644 src/renderer/src/store/scrcpy/index.js rename src/renderer/src/{components/Advanced/configs => store/scrcpy/model}/audio/index.js (100%) rename src/renderer/src/{components/Advanced/configs => store/scrcpy/model}/device/index.js (75%) rename src/renderer/src/{components/Advanced/configs => store/scrcpy/model}/index.js (79%) create mode 100644 src/renderer/src/store/scrcpy/model/record/index.js rename src/renderer/src/{components/Advanced/configs => store/scrcpy/model}/video/index.js (56%) rename src/renderer/src/{components/Advanced/configs => store/scrcpy/model}/window/index.js (100%) diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml index c61bd912..058dc55f 100644 --- a/.github/workflows/release-assets.yml +++ b/.github/workflows/release-assets.yml @@ -21,7 +21,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - name: Install Dependencies run: npm install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8264725e..20997a66 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release-please +name: release on: push: diff --git a/README.md b/README.md index 3ec4e5a7..2a7b12ae 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,11 @@ 1. 用户界面进行优化,制作合适的 Logo ✅ 2. 内置的软件更新功能 ✅ -3. 添加 macOS 及 linux 操作系统的支持 🚧 -4. 添加外部控制栏 🚧 -5. 支持语言国际化功能 🚧 -6. 添加对游戏的增强功能 如游戏键位映射 🚧 +3. 录制和保存音视频 ✅ +4. 添加 macOS 及 linux 操作系统的支持 🚧 +5. 添加外部控制栏 🚧 +6. 支持语言国际化功能 🚧 +7. 添加对游戏的增强功能 如游戏键位映射 🚧 ## 常见问题 diff --git a/package.json b/package.json index b53e64e0..2698c8db 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,12 @@ "@electron-toolkit/preload": "^2.0.0", "@electron-toolkit/utils": "^2.0.0", "@viarotel-org/design": "^0.7.0", + "dayjs": "^1.11.10", "electron-updater": "^6.1.1", - "element-plus": "^2.3.14" + "element-plus": "^2.3.14", + "lodash-es": "^4.17.21", + "pinia": "^2.1.6", + "ufo": "^1.3.1" }, "devDependencies": { "@electron-toolkit/eslint-config": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84c0ac2c..8abc2ded 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,12 +17,24 @@ dependencies: '@viarotel-org/design': specifier: ^0.7.0 version: 0.7.0 + dayjs: + specifier: ^1.11.10 + version: 1.11.10 electron-updater: specifier: ^6.1.1 version: 6.1.4 element-plus: specifier: ^2.3.14 version: 2.3.14(vue@3.3.4) + lodash-es: + specifier: ^4.17.21 + version: 4.17.21 + pinia: + specifier: ^2.1.6 + version: 2.1.6(typescript@5.2.2)(vue@3.3.4) + ufo: + specifier: ^1.3.1 + version: 1.3.1 devDependencies: '@electron-toolkit/eslint-config': @@ -1595,6 +1607,10 @@ packages: '@vue/compiler-dom': 3.3.4 '@vue/shared': 3.3.4 + /@vue/devtools-api@6.5.1: + resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==} + dev: false + /@vue/eslint-config-prettier@8.0.0(eslint@8.49.0)(prettier@3.0.3): resolution: {integrity: sha512-55dPqtC4PM/yBjhAr+yEw6+7KzzdkBuLmnhBrDfp4I48+wy+Giqqj9yUr5T2uD/BkBROjjmqnLZmXRdOx/VtQg==} peerDependencies: @@ -2286,8 +2302,8 @@ packages: - ts-node dev: true - /dayjs@1.11.9: - resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==} + /dayjs@1.11.10: + resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} dev: false /debug@3.2.7: @@ -2604,7 +2620,7 @@ packages: '@types/lodash-es': 4.17.9 '@vueuse/core': 9.13.0(vue@3.3.4) async-validator: 4.2.5 - dayjs: 1.11.9 + dayjs: 1.11.10 escape-html: 1.0.3 lodash: 4.17.21 lodash-es: 4.17.21 @@ -4135,7 +4151,7 @@ packages: acorn: 8.10.0 pathe: 1.1.1 pkg-types: 1.0.3 - ufo: 1.3.0 + ufo: 1.3.1 dev: true /mrmime@1.0.1: @@ -4269,7 +4285,7 @@ packages: dependencies: destr: 2.0.1 node-fetch-native: 1.4.0 - ufo: 1.3.0 + ufo: 1.3.1 dev: true /once@1.4.0: @@ -4447,6 +4463,24 @@ packages: dev: true optional: true + /pinia@2.1.6(typescript@5.2.2)(vue@3.3.4): + resolution: {integrity: sha512-bIU6QuE5qZviMmct5XwCesXelb5VavdOWKWaB17ggk++NUwQWWbP5YnsONTk3b752QkW9sACiR81rorpeOMSvQ==} + peerDependencies: + '@vue/composition-api': ^1.4.0 + typescript: '>=4.4.4' + vue: ^2.6.14 || ^3.3.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + typescript: + optional: true + dependencies: + '@vue/devtools-api': 6.5.1 + typescript: 5.2.2 + vue: 3.3.4 + vue-demi: 0.14.6(vue@3.3.4) + dev: false + /pirates@4.0.6: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} @@ -5193,11 +5227,9 @@ packages: resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} engines: {node: '>=14.17'} hasBin: true - dev: true - /ufo@1.3.0: - resolution: {integrity: sha512-bRn3CsoojyNStCZe0BG0Mt4Nr/4KF+rhFlnNXybgqt5pXHNFRlqinSoQaTrGyzE4X8aHplSb+TorH+COin9Yxw==} - dev: true + /ufo@1.3.1: + resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} /unconfig@0.3.10: resolution: {integrity: sha512-tj317lhIq2iZF/NXrJnU1t2UaGUKKz1eL1sK2t63Oq66V9BxqvZV12m55fp/fpQJ+DDmVlLgo7cnLVOZkhlO/A==} diff --git a/src/main/index.js b/src/main/index.js index 0d44637e..a21a7aa2 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,10 +1,13 @@ import { join } from 'node:path' + import { BrowserWindow, app, shell } from 'electron' import { electronApp, is, optimizer } from '@electron-toolkit/utils' + import iconPath from '../../resources/icons/icon.png?asset' import winIconPath from '../../resources/icons/icon.ico?asset' import macIconPath from '../../resources/icons/icon.icns?asset' -import ipcEvent from './ipc/index.js' + +import ipcManage from './ipcManage/index.js' function createWindow() { let icon = iconPath @@ -46,7 +49,7 @@ function createWindow() { mainWindow.loadFile(join(__dirname, '../renderer/index.html')) } - ipcEvent(mainWindow) + ipcManage(mainWindow) } // This method will be called when Electron has finished diff --git a/src/main/ipcManage/handles/index.js b/src/main/ipcManage/handles/index.js new file mode 100644 index 00000000..f71d369e --- /dev/null +++ b/src/main/ipcManage/handles/index.js @@ -0,0 +1,41 @@ +import { dialog, ipcMain, shell } from 'electron' + +export default () => { + ipcMain.handle('show-open-dialog', async (event, params) => { + // console.log('params', params) + try { + const res = await dialog.showOpenDialog(params) + // console.log('showOpenDialog.res', res) + if (res.canceled) { + return false + } + return res.filePaths + } + catch (error) { + console.warn(error?.message || error) + return false + } + }) + + ipcMain.handle('open-path', async (event, pathValue) => { + try { + await shell.openPath(pathValue) + return true + } + catch (error) { + console.warn(error?.message || error) + return false + } + }) + + ipcMain.handle('show-item-in-folder', async (event, filePath) => { + try { + await shell.showItemInFolder(filePath) + return true + } + catch (error) { + console.warn(error?.message || error) + return false + } + }) +} diff --git a/src/main/ipc/index.js b/src/main/ipcManage/index.js similarity index 54% rename from src/main/ipc/index.js rename to src/main/ipcManage/index.js index 57dd18f5..0c592f58 100644 --- a/src/main/ipc/index.js +++ b/src/main/ipcManage/index.js @@ -1,10 +1,14 @@ import { app, ipcMain } from 'electron' -import updaterEvents from './updater/index.js' + +import updater from './updater/index.js' +import handles from './handles/index.js' export default (mainWindow) => { + handles(mainWindow) + updater(mainWindow) + ipcMain.on('restart-app', () => { app.relaunch() app.quit() }) - updaterEvents(mainWindow) } diff --git a/src/main/ipc/updater/index.js b/src/main/ipcManage/updater/index.js similarity index 98% rename from src/main/ipc/updater/index.js rename to src/main/ipcManage/updater/index.js index 7f8386a8..45892453 100644 --- a/src/main/ipc/updater/index.js +++ b/src/main/ipcManage/updater/index.js @@ -1,9 +1,8 @@ +import path from 'node:path' import { app, ipcMain } from 'electron' import { is } from '@electron-toolkit/utils' import { autoUpdater } from 'electron-updater' -const path = require('node:path') - export default (mainWindow) => { // dev-start, 这里是为了在本地做应用升级测试使用,正式环境请务必删除 if (is.dev && process.env.ELECTRON_RENDERER_URL) { diff --git a/src/preload/plugins/adbkit/index.js b/src/preload/plugins/adbkit/index.js index 8b37c247..672196e0 100644 --- a/src/preload/plugins/adbkit/index.js +++ b/src/preload/plugins/adbkit/index.js @@ -1,8 +1,9 @@ +import util from 'node:util' +import child_process from 'node:child_process' import { Adb } from '@devicefarmer/adbkit' import adbPath from '@resources/core/adb.exe?asset&asarUnpack' -const util = require('node:util') -const exec = util.promisify(require('node:child_process').exec) +const exec = util.promisify(child_process.exec) let client = null diff --git a/src/preload/plugins/index.js b/src/preload/plugins/index.js index 873497ef..89f699a9 100644 --- a/src/preload/plugins/index.js +++ b/src/preload/plugins/index.js @@ -1,9 +1,12 @@ +import path from 'node:path' import electron from './electron/index.js' import adbkit from './adbkit/index.js' import scrcpy from './scrcpy/index.js' export default { install(expose) { + expose('nodePath', path) + expose('electron', electron()) expose('adbkit', adbkit()) expose('scrcpy', scrcpy()) diff --git a/src/preload/plugins/scrcpy/index.js b/src/preload/plugins/scrcpy/index.js index afbf3e42..a62d11d6 100644 --- a/src/preload/plugins/scrcpy/index.js +++ b/src/preload/plugins/scrcpy/index.js @@ -1,8 +1,9 @@ +import util from 'node:util' +import child_process from 'node:child_process' import adbPath from '@resources/core/adb.exe?asset&asarUnpack' import scrcpyPath from '@resources/core/scrcpy.exe?asset&asarUnpack' -const util = require('node:util') -const exec = util.promisify(require('node:child_process').exec) +const exec = util.promisify(child_process.exec) const shell = command => exec(`${scrcpyPath} ${command}`, { env: { ...process.env, ADB: adbPath } }) diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 5d1177f8..8d69748c 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -1,6 +1,6 @@
- + + +