feat: 🚀 初步添加对 Linux 以及 MacOS 的支持

This commit is contained in:
viarotel 2023-10-20 18:17:58 +08:00
parent 4003cbdfb4
commit 569ed2e2fa
11 changed files with 76 additions and 15 deletions

View File

@ -11,8 +11,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Check out Git repository

View File

@ -117,8 +117,7 @@
5. 支持自定义 Adb 及 Scrcpy 依赖 ✅
6. 支持自定义设备名称,以及偏好设置的导出及导入 ✅
7. 定制化,支持对单个设备进行独立配置 ✅
8. 支持精简版本(不包含 Adb 及 Scrcpy 依赖)和完整版本以满足不同用户需求 🚧
9. 添加 macOS 及 linux 操作系统的支持 🚧
8. 添加 macOS 及 linux 操作系统的支持 🚧
10. 支持语言国际化功能 🚧
11. 添加对游戏的增强功能,如游戏键位映射 🚧

View File

@ -8,10 +8,6 @@
"buildResources": "electron/resources/build"
},
"files": ["dist", "dist-electron"],
"extraResources": {
"from": "electron/resources/extra",
"to": "extra"
},
"publish": {
"provider": "github",
"owner": "viarotel-org",
@ -44,7 +40,11 @@
{
"target": "portable"
}
]
],
"extraResources": {
"from": "electron/resources/extra",
"to": "extra"
}
},
"nsis": {
"artifactName": "${productName}-${version}-win-setup.${ext}",

View File

@ -10,6 +10,8 @@ export const logoPath = buildResolve('logo.png')
export const icoLogoPath = buildResolve('logo.ico')
export const icnsLogoPath = buildResolve('logo.icns')
export const adbPath = extraResolve('core/adb.exe')
export const adbPath
= process.platform === 'win32' ? extraResolve('core/adb.exe') : 'adb'
export const scrcpyPath = extraResolve('core/scrcpy.exe')
export const scrcpyPath
= process.platform === 'win32' ? extraResolve('core/scrcpy.exe') : 'scrcpy'

View File

@ -4,6 +4,7 @@ import path from 'node:path'
import fs from 'node:fs'
import dayjs from 'dayjs'
import { Adb } from '@devicefarmer/adbkit'
import _which from 'which'
import appStore from '@electron/helpers/store.js'
import { adbPath } from '@electron/configs/index.js'
@ -97,6 +98,10 @@ const screencap = async (deviceId, options = {}) => {
const install = async (id, path) => client.getDevice(id).install(path)
const version = async () => client.version()
const which = async () => _which('adb')
const watch = async (callback) => {
const tracker = await client.trackDevices()
tracker.on('add', async (ret) => {
@ -141,6 +146,8 @@ export default () => {
tcpip,
screencap,
install,
version,
which,
watch,
}
}

View File

@ -1,4 +1,5 @@
import { spawn } from 'node:child_process'
import _which from 'which'
import appStore from '@electron/helpers/store.js'
import { adbPath, scrcpyPath } from '@electron/configs/index.js'
@ -17,7 +18,7 @@ const shell = async (command, { stdout, stderr } = {}) => {
console.log('scrcpyProcess.stdout.data:', stringData)
if (stdout) {
stdout(stringData)
stdout(stringData, scrcpyProcess)
}
})
@ -27,7 +28,7 @@ const shell = async (command, { stdout, stderr } = {}) => {
console.error('scrcpyProcess.stderr.data:', stringData)
if (stderr) {
stderr(stringData)
stderr(stringData, scrcpyProcess)
}
})
@ -47,6 +48,9 @@ const shell = async (command, { stdout, stderr } = {}) => {
})
}
const which = async () => _which('scrcpy')
export default () => ({
shell,
which,
})

View File

@ -44,6 +44,7 @@
"vite-plugin-electron-renderer": "^0.14.5",
"vite-plugin-eslint": "^1.8.1",
"vite-svg-loader": "^4.0.0",
"vue-tsc": "^1.8.8"
"vue-tsc": "^1.8.8",
"which": "^4.0.0"
}
}

View File

@ -82,6 +82,9 @@ devDependencies:
vue-tsc:
specifier: ^1.8.8
version: 1.8.19(typescript@5.2.2)
which:
specifier: ^4.0.0
version: 4.0.0
packages:
@ -3608,6 +3611,11 @@ packages:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
dev: true
/isexe@3.1.1:
resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==}
engines: {node: '>=16'}
dev: true
/jake@10.8.7:
resolution: {integrity: sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==}
engines: {node: '>=10'}
@ -5301,6 +5309,14 @@ packages:
isexe: 2.0.0
dev: true
/which@4.0.0:
resolution: {integrity: sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==}
engines: {node: ^16.13.0 || >=18.0.0}
hasBin: true
dependencies:
isexe: 3.1.1
dev: true
/wrap-ansi@7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}

View File

@ -47,8 +47,39 @@ export default {
},
created() {
this.$store.scrcpy.init()
this.showTips()
},
methods: {
async showTips() {
if (this.$electron.process.platform === 'win32') {
return false
}
try {
const adbWhichPath = await this.$adb.which()
console.log('adbWhichPath', adbWhichPath)
const scrcpyWhichPath = await this.$scrcpy.which()
console.log('scrcpyWhichPath', scrcpyWhichPath)
return false
}
catch (error) {
console.warn(error?.message || error?.cause?.message)
}
this.$alert(
`<div>该软件依赖与
<a class="hover:underline text-primary-500" href="https://developer.android.com/studio/releases/platform-tools?hl=zh-cn" target="_blank">adb</a>
以及
<a class="hover:underline text-primary-500" href="https://github.com/Genymobile/scrcpy" target="_blank">scrcpy</a>
请确保已正确安装所述依赖项或者在偏好设置中手动配置依赖项所在位置
<div>`,
'注意事项',
{
dangerouslyUseHTMLString: true,
confirmButtonText: '确定',
},
)
},
isRender(item) {
if (this.activeTab === item.prop) {
return this.rendered

View File

@ -26,6 +26,8 @@ app.config.globalProperties.$appStore = window.appStore
app.config.globalProperties.$replaceIP = replaceIP
console.log('electron', window.electron)
app.mount('#app').$nextTick(() => {
// Remove Preload scripts loading
postMessage({ payload: 'removeLoading' }, '*')

View File

@ -70,7 +70,7 @@ export const useScrcpyStore = defineStore({
if (scope !== 'global') {
const scopeConfig = $appStore.get(`scrcpy.${replaceIP(scope)}`) || {}
tempConfig = mergeConfig(tempConfig, scopeConfig, { debug: true })
tempConfig = mergeConfig(tempConfig, scopeConfig)
}
this.config = tempConfig