Skip to content

Commit

Permalink
feat: 🚀 初步添加对 Linux 以及 MacOS 的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 20, 2023
1 parent 4003cbd commit 569ed2e
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
5. 支持自定义 Adb 及 Scrcpy 依赖 ✅
6. 支持自定义设备名称,以及偏好设置的导出及导入 ✅
7. 定制化,支持对单个设备进行独立配置 ✅
8. 支持精简版本(不包含 Adb 及 Scrcpy 依赖)和完整版本以满足不同用户需求 🚧
9. 添加 macOS 及 linux 操作系统的支持 🚧
8. 添加 macOS 及 linux 操作系统的支持 🚧
10. 支持语言国际化功能 🚧
11. 添加对游戏的增强功能,如游戏键位映射 🚧

Expand Down
10 changes: 5 additions & 5 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -44,7 +40,11 @@
{
"target": "portable"
}
]
],
"extraResources": {
"from": "electron/resources/extra",
"to": "extra"
}
},
"nsis": {
"artifactName": "${productName}-${version}-win-setup.${ext}",
Expand Down
6 changes: 4 additions & 2 deletions electron/configs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
7 changes: 7 additions & 0 deletions electron/exposes/adbkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -141,6 +146,8 @@ export default () => {
tcpip,
screencap,
install,
version,
which,
watch,
}
}
8 changes: 6 additions & 2 deletions electron/exposes/scrcpy/index.js
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -17,7 +18,7 @@ const shell = async (command, { stdout, stderr } = {}) => {
console.log('scrcpyProcess.stdout.data:', stringData)

if (stdout) {
stdout(stringData)
stdout(stringData, scrcpyProcess)
}
})

Expand All @@ -27,7 +28,7 @@ const shell = async (command, { stdout, stderr } = {}) => {
console.error('scrcpyProcess.stderr.data:', stringData)

if (stderr) {
stderr(stringData)
stderr(stringData, scrcpyProcess)
}
})

Expand All @@ -47,6 +48,9 @@ const shell = async (command, { stdout, stderr } = {}) => {
})
}

const which = async () => _which('scrcpy')

export default () => ({
shell,
which,
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }, '*')
Expand Down
2 changes: 1 addition & 1 deletion src/store/scrcpy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 569ed2e

Please sign in to comment.