Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 7, 2023
1 parent f651733 commit 2371b26
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 24 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
### WIFI 连接

> 注意:需同时开启无线调试功能,并在无线调试页面中获取你的当前设备的无线地址(通常为你连接WIFI时分配的IP地址)及端口号(默认为 5555)
> 注意: 第一次无线连接可能需要插入 USB 以保证与电脑建立连接即授权成功后方可使用
1. 同 USB 连接中的 1-2 步骤
2. 将获取到的设备 IP 地址及端口号填写到 Escrcpy 中,然后点击连接设备
Expand Down Expand Up @@ -80,12 +81,11 @@
> 优先级从高到低
1. 用户界面进行优化,制作合适的 Logo ✅
2. 添加更多的高级功能 如: 屏幕录像 🚧
2. 添加外部控制栏 🚧
3. 添加 macOS 及 linux 操作系统的支持 🚧
4. 内置的软件更新功能 🚧
5. 支持语言国际化功能 🚧
6. 添加侧边控制栏 🚧
7. 添加对游戏的增强功能 如游戏键位映射 🚧
6. 添加对游戏的增强功能 如游戏键位映射 🚧

## 常见问题

Expand All @@ -110,6 +110,10 @@
1. 在高级设置中开启 设备控制 => 虚拟控制栏 (如果该配置不起作用则需要在设备上手动开启)
2. 通过快捷键,请参阅 [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master/doc/shortcuts.md)

### 无线连接提示: 目标计算机积极拒绝访问

第一次无线连接可能需要插入 USB 以保证与电脑建立连接即授权成功后方可使用

## 获得帮助

> 因为是开源项目 全靠爱发电 所以支持有限 更新节奏不固定
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"@vitejs/plugin-vue": "^4.3.1",
"@vue/eslint-config-prettier": "^8.0.0",
"electron": "^25.6.0",
"electron-builder": "^24.6.3",
"electron-vite": "^1.0.27",
"eslint": "^8.49.0",
"electron-builder": "^24.6.4",
"electron-vite": "^1.0.28",
"eslint": "8.49.0",
"eslint-plugin-vue": "^9.17.0",
"less": "^4.2.0",
"prettier": "^3.0.2",
Expand Down
21 changes: 10 additions & 11 deletions pnpm-lock.yaml

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

13 changes: 9 additions & 4 deletions src/preload/plugins/adbkit/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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)

let client = null

window.addEventListener('beforeunload', () => {
Expand All @@ -11,26 +14,27 @@ window.addEventListener('beforeunload', () => {

const getDevices = async () => await client.listDevicesWithPaths()
const shell = async (id, command) => await client.getDevice(id).shell(command)
const rawShell = async command => exec(`${adbPath} ${command}`)
const kill = async (...params) => await client.kill(...params)
const connect = async (...params) => await client.connect(...params)
const disconnect = async (...params) => await client.disconnect(...params)

const watch = async (callback) => {
const tracker = await client.trackDevices()
tracker.on('add', (device) => {
callback(device)
callback('add', device)
})

tracker.on('remove', (device) => {
callback(device)
callback('remove', device)
})

tracker.on('end', (ret) => {
callback(ret)
callback('end', ret)
})

tracker.on('error', (err) => {
callback(err)
callback('error', err)
})

const close = () => tracker.end()
Expand All @@ -45,6 +49,7 @@ export default () => {
return {
getDevices,
shell,
rawShell,
kill,
connect,
disconnect,
Expand Down
31 changes: 28 additions & 3 deletions src/renderer/src/components/Devices/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,48 @@ export default {
handleReset() {
this.$electron.ipcRenderer.send('restart-app')
},
async handleConnect() {
async handleConnect({ pairCode = '' } = {}) {
if (!this.formData.host) {
this.$message.warning('无线调试地址不能为空')
return false
}
this.connectLoading = true
try {
await this.$adb.connect(this.formData.host, this.formData.port || 5555)
await this.$adb.connect(this.formData.host, this.formData.port || 5555, pairCode)
this.$message.success('连接设备成功')
storage.set('adbCache', this.formData)
}
catch (error) {
if (error.message)
if (error.message) {
this.$message.warning(error.message)
}
if (error.message.includes('10060')) {
this.handlePair()
}
}
this.connectLoading = false
},
async handlePair() {
try {
const { value } = await this.$prompt('', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'number',
inputPlaceholder: '请输入配对码',
closeOnClickModal: false,
})
await this.$adb.rawShell(
`pair ${this.formData.host}:${this.formData.port || 5555} ${this.value}`,
)
this.handleConnect({ pairCode: value })
}
catch (error) {
console.warn(error.message)
}
},
async handleStop(row) {
row.$stopLoading = true
const [host, port] = row.id.split(':')
Expand Down

0 comments on commit 2371b26

Please sign in to comment.