Skip to content

Commit

Permalink
perf: ♻️ Interactive logic optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Mar 5, 2024
1 parent 389ac33 commit 193f80a
Show file tree
Hide file tree
Showing 18 changed files with 241 additions and 707 deletions.
17 changes: 10 additions & 7 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ Windows 及 Linux 端内部集成了 Gnirehtet, 用于提供 PC 到安卓设

请参阅 [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master/doc/shortcuts.md)

## 设备交互栏
## 设备操作

### 控制模式

- 镜像
- 录制
- OTG
- 摄像

### 设备交互栏

- 切换键
- 主屏幕
Expand Down Expand Up @@ -160,12 +169,6 @@ Windows 及 Linux 端内部集成了 Gnirehtet, 用于提供 PC 到安卓设
- 键盘模式
- 键盘注入方式

### OTG

- 启用 OTG
- 仅键盘
- 仅鼠标

### 摄像控制

- 启用摄像
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ Gnirehtet is built into the Windows and Linux apps to provide reverse tethering

Refer to [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master/doc/shortcuts.md)

## Device Interaction Bar
## Device Operation

### Control Model

- Mirror
- Recording
- OTG
- Camera

### Device Interaction Bar

- Switch
- Home
Expand Down Expand Up @@ -158,12 +167,6 @@ Refer to [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master
- Keyboard mode
- Keyboard injection method

### OTG

- Enable OTG
- Keyboard only
- Mouse only

### Camera Control

- Enable camera
Expand Down
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,10 @@ export default {
}
</script>
<style></style>
<style lang="postcss" scoped>
:deep() {
.el-tabs__header {
@apply !mb-3;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<template>
<el-dropdown-item class="" :disabled="loading" @click="handleClick">
<template v-if="loading">
<el-icon class="is-loading">
<Loading />
</el-icon>
运行中
</template>
<template v-else>
默认模式
</template>
</el-dropdown-item>
<el-button
type="primary"
text
:disabled="row.$unauthorized"
:loading="loading"
:icon="loading ? '' : 'Monitor'"
@click="handleClick(row)"
>
{{ loading ? $t('common.progress') : $t('device.mirror.start') }}
</el-button>
</template>

<script>
import { sleep } from '@/utils'
export default {
props: {
deviceInfo: {
row: {
type: Object,
default: () => ({}),
},
Expand All @@ -30,9 +31,7 @@ export default {
}
},
methods: {
async handleClick() {
const row = this.deviceInfo
async handleClick(row) {
this.loading = true
this.toggleRowExpansion(row, true)
Expand All @@ -42,12 +41,18 @@ export default {
})
try {
await this.$scrcpy.mirror(row.id, {
const mirroring = this.$scrcpy.mirror(row.id, {
title: this.$store.device.getLabel(row),
args,
stdout: this.onStdout,
stderr: this.onStderr,
})
await sleep(1 * 1000)
this.loading = false
await mirroring
}
catch (error) {
console.warn(error)
Expand All @@ -57,7 +62,6 @@ export default {
this.handleReset()
}
this.loading = false
},
onStdout() {},
onStderr() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<template>
<el-dropdown-item class="" :disabled="loading" @click="handleClick">
<template v-if="loading">
<el-icon class="is-loading">
<Loading />
</el-icon>
摄像中
</template>
<template v-else>
摄像模式
</template>
</el-dropdown-item>
<slot :loading="loading" :trigger="handleClick" />
</template>

<script>
import { sleep } from '@/utils'
export default {
props: {
deviceInfo: {
row: {
type: Object,
default: () => ({}),
},
Expand All @@ -31,7 +23,7 @@ export default {
},
methods: {
async handleClick() {
const row = this.deviceInfo
const row = this.row
this.loading = true
Expand All @@ -46,12 +38,18 @@ export default {
)}`
try {
await this.$scrcpy.mirror(row.id, {
const mirroring = this.$scrcpy.mirror(row.id, {
title: this.$store.device.getLabel(row),
args,
stdout: this.onStdout,
stderr: this.onStderr,
})
await sleep(1 * 1000)
this.loading = false
await mirroring
}
catch (error) {
console.warn(error)
Expand All @@ -62,8 +60,6 @@ export default {
this.handleReset()
}
this.loading = false
},
onStdout() {},
onStderr() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<template>
<el-dropdown-item class="" :disabled="loading" @click="handleClick">
<template v-if="loading">
<el-icon class="is-loading">
<Loading />
</el-icon>
控制中
</template>
<template v-else>
OTG模式
</template>
</el-dropdown-item>
<slot :loading="loading" :trigger="handleClick" />
</template>

<script>
import { sleep } from '@/utils'
export default {
props: {
deviceInfo: {
row: {
type: Object,
default: () => ({}),
},
Expand All @@ -31,7 +23,7 @@ export default {
},
methods: {
async handleClick() {
const row = this.deviceInfo
const row = this.row
this.loading = true
Expand All @@ -43,12 +35,18 @@ export default {
})}`
try {
await this.$scrcpy.mirror(row.id, {
const mirroring = this.$scrcpy.mirror(row.id, {
title: this.$store.device.getLabel(row),
args,
stdout: this.onStdout,
stderr: this.onStderr,
})
await sleep(1 * 1000)
this.loading = false
await mirroring
}
catch (error) {
console.warn(error)
Expand All @@ -59,8 +57,6 @@ export default {
this.handleReset()
}
this.loading = false
},
onStdout() {},
onStderr() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<template>
<el-dropdown-item class="" :disabled="loading" @click="handleClick">
<template v-if="loading">
<el-icon class="is-loading">
<Loading />
</el-icon>
录制中
</template>
<template v-else>
录制模式
</template>
</el-dropdown-item>
<slot :loading="loading" :trigger="handleClick" />
</template>

<script>
import { sleep } from '@/utils'
export default {
props: {
deviceInfo: {
row: {
type: Object,
default: () => ({}),
},
Expand All @@ -31,7 +23,7 @@ export default {
},
methods: {
async handleClick() {
const row = this.deviceInfo
const row = this.row
this.loading = true
Expand All @@ -45,13 +37,20 @@ export default {
})
try {
await this.$scrcpy.record(row.id, {
const recording = this.$scrcpy.record(row.id, {
title: this.$store.device.getLabel(row, 'recording'),
savePath,
args,
stdout: this.onStdout,
stderr: this.onStderr,
})
await sleep(1 * 1000)
this.loading = false
await recording
this.onRecordSuccess(savePath)
}
catch (error) {
Expand All @@ -61,8 +60,6 @@ export default {
this.$message.warning(error.message)
}
}
this.loading = false
},
onStdout() {},
onStderr() {
Expand Down
Loading

0 comments on commit 193f80a

Please sign in to comment.