Skip to content

Commit

Permalink
perf: ✅ Support batch screenshot and other performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Jul 11, 2024
1 parent 49ae541 commit db9e3e7
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 121 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
],
"cSpell.words": [
"bhsn"
]
],
"common-intellisense.ui": []
}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [1.20.1](https://github.com/viarotel-org/escrcpy/compare/v1.20.0...v1.20.1) (2024-07-04)


### Bug Fixes

* 🐛 Fix batch text spelling errors ([062c689](https://github.com/viarotel-org/escrcpy/commit/062c689755df5bcc5f8e38605c7f101762d7ada0))

## [1.20.0](https://github.com/viarotel-org/escrcpy/compare/v1.19.4...v1.20.0) (2024-07-04)


### Features

* ✨ Add batch installation application function ([37ce245](https://github.com/viarotel-org/escrcpy/commit/37ce2457bce9a1b661c6db7162023f53268833f5))


### Performance Improvements

* 🚀 Add mouse binding options ([7ee4ba4](https://github.com/viarotel-org/escrcpy/commit/7ee4ba4f2b177e6dbfce85036425b51bfa35ecff))

## [1.19.4](https://github.com/viarotel-org/escrcpy/compare/v1.19.3...v1.19.4) (2024-07-02)


Expand Down
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Windows 及 Linux 端内部集成了 Gnirehtet, 用于提供 PC 到安卓设
15. 支持批量连接历史设备功能 ✅
16. 支持使用内置终端执行自定义命令 ✅
17. 支持设备自动执行镜像 ✅
18. 添加批量安装应用功能
18. 支持常用批量功能
19. 支持更多批量处理功能 🚧
20. 支持对设备进行分组 🚧
21. 添加文件传输助手功能 🚧
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Refer to [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master
15. Support bulk connecting to historical devices ✅
16. Support to use built-in terminals to execute custom commands ✅
17. Supports automatic execution of mirror on devices ✅
18. Add batch installation application function ✅
18. Support common batch processing function ✅
19. Support more batch processing functions 🚧
20. Support the device to group 🚧
21. Add file transmission assistant function 🚧
Expand Down
32 changes: 0 additions & 32 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@ export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
About: typeof import('./src/components/About/index.vue')['default']
AppInstall: typeof import('./src/components/Device/components/BatchActions/AppInstall/index.vue')['default']
AppSearch: typeof import('./src/components/AppSearch/index.vue')['default']
AudioCodecSelect: typeof import('./src/components/Preference/components/AudioCodecSelect/index.vue')['default']
BatchActions: typeof import('./src/components/Device/components/BatchActions/index.vue')['default']
Camera: typeof import('./src/components/Device/components/MoreDropdown/components/Camera/index.vue')['default']
ControlBar: typeof import('./src/components/Device/components/ControlBar/index.vue')['default']
Device: typeof import('./src/components/Device/index.vue')['default']
DisplaySelect: typeof import('./src/components/Preference/components/DisplaySelect/index.vue')['default']
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
ElButton: typeof import('element-plus/es')['ElButton']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElCollapseTransition: typeof import('element-plus/es')['ElCollapseTransition']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
Expand All @@ -44,28 +34,6 @@ declare module 'vue' {
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
FileManage: typeof import('./src/components/Device/components/ControlBar/FileManage/index.vue')['default']
Gnirehtet: typeof import('./src/components/Device/components/ControlBar/Gnirehtet/index.vue')['default']
KeyboardInjectSelect: typeof import('./src/components/Preference/components/KeyboardInjectSelect/index.vue')['default']
LanguageSelect: typeof import('./src/components/Preference/components/LanguageSelect/index.vue')['default']
LoadingIcon: typeof import('./src/components/Device/components/LoadingIcon/index.vue')['default']
MirrorAction: typeof import('./src/components/Device/components/MirrorAction/index.vue')['default']
MirrorGroup: typeof import('./src/components/Device/components/ControlBar/MirrorGroup/index.vue')['default']
MoreDropdown: typeof import('./src/components/Device/components/MoreDropdown/index.vue')['default']
Otg: typeof import('./src/components/Device/components/MoreDropdown/components/Otg/index.vue')['default']
PairDialog: typeof import('./src/components/Device/components/Wireless/PairDialog/index.vue')['default']
PathInput: typeof import('./src/components/Preference/components/PathInput/index.vue')['default']
Preference: typeof import('./src/components/Preference/index.vue')['default']
Record: typeof import('./src/components/Device/components/MoreDropdown/components/Record/index.vue')['default']
Remark: typeof import('./src/components/Device/components/Remark/index.vue')['default']
Rotation: typeof import('./src/components/Device/components/ControlBar/Rotation/index.vue')['default']
Screenshot: typeof import('./src/components/Device/components/ControlBar/Screenshot/index.vue')['default']
TerminalAction: typeof import('./src/components/Device/components/TerminalAction/index.vue')['default']
TerminalDialog: typeof import('./src/components/Device/components/TerminalAction/components/TerminalDialog/index.vue')['default']
VideoCodecSelect: typeof import('./src/components/Preference/components/VideoCodecSelect/index.vue')['default']
Volume: typeof import('./src/components/Device/components/ControlBar/Volume/index.vue')['default']
Wireless: typeof import('./src/components/Device/components/Wireless/index.vue')['default']
WirelessAction: typeof import('./src/components/Device/components/WirelessAction/index.vue')['default']
}
export interface ComponentCustomProperties {
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
Expand Down
2 changes: 0 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ log.initialize({ preload: true })

const debug = !!appStore.get('common.debug')

log.info('Debug Status:', debug)

if (!debug) {
log.warn(
'Debug Tips:',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "escrcpy",
"type": "module",
"version": "1.19.4",
"version": "1.20.1",
"private": true,
"description": "Scrcpy Powered by Electron",
"author": "viarotel",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { ElMessageBox } from 'element-plus'
import Device from './components/Device/index.vue'
import Preference from './components/Preference/index.vue'
import About from './components/About/index.vue'
import AppSearch from './components/AppSearch/index.vue'
import AppSearch from './components/Search/index.vue'
import { useThemeStore } from '$/store/theme/index.js'
import { usePreferenceStore } from '$/store/preference/index.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<template>
<div class="" @click="handleClick">
<slot />
<AppInstallProxy ref="appInstallProxyRef" />
<ApplicationProxy ref="applicationProxyRef" />
</div>
</template>

<script>
import AppInstallProxy from '$/components/Device/components/ControlBar/AppInstall/index.vue'
import ApplicationProxy from '$/components/Device/components/ControlBar/Application/index.vue'
import { sleep } from '$/utils'
export default {
components: {
AppInstallProxy,
ApplicationProxy,
},
props: {
devices: {
Expand All @@ -23,7 +23,7 @@ export default {
async handleClick() {
for (let index = 0; index < this.devices.length; index++) {
const item = this.devices[index]
await this.$refs.appInstallProxyRef.handleInstall(item)
await this.$refs.applicationProxyRef.invoke(item)
await sleep(2 * 1000)
}
},
Expand Down
34 changes: 34 additions & 0 deletions src/components/Device/components/BatchActions/Screenshot/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<div class="" @click="handleClick">
<slot />
<ScreenshotProxy ref="screenshotProxyRef" />
</div>
</template>

<script>
import ScreenshotProxy from '$/components/Device/components/ControlBar/Screenshot/index.vue'
import { sleep } from '$/utils'
export default {
components: {
ScreenshotProxy,
},
props: {
devices: {
type: Array,
default: () => [],
},
},
methods: {
async handleClick() {
for (let index = 0; index < this.devices.length; index++) {
const item = this.devices[index]
await this.$refs.screenshotProxyRef.invoke(item)
await sleep(2 * 1000)
}
},
},
}
</script>

<style></style>
17 changes: 12 additions & 5 deletions src/components/Device/components/BatchActions/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex items-center">
<div class="flex items-center space-x-2">
<component
:is="item.component || 'div'"
v-for="(item, index) in actionModel"
Expand Down Expand Up @@ -31,19 +31,21 @@
<component :is="item.elIcon" />
</el-icon>
</template>
{{ $t('common.batch') }}{{ $t(item.label) }}
{{ $t('common.batch') }}-{{ $t(item.label) }}
</el-button>
</template>
</component>
</div>
</template>

<script>
import AppInstall from './AppInstall/index.vue'
import Application from './Application/index.vue'
import Screenshot from './Screenshot/index.vue'
export default {
components: {
AppInstall,
Application,
Screenshot,
},
props: {
devices: {
Expand All @@ -54,10 +56,15 @@ export default {
data() {
return {
actionModel: [
{
label: 'device.control.capture',
elIcon: 'Crop',
component: 'Screenshot',
},
{
label: 'device.control.install',
svgIcon: 'install',
component: 'AppInstall',
component: 'Application',
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
</template>

<script>
import LoadingIcon from '$/components/Device/components/LoadingIcon/index.vue'
export default {
props: {
device: {
Expand All @@ -18,6 +16,9 @@ export default {
return {}
},
methods: {
invoke(...args) {
return this.handleInstall(...args)
},
preferenceData(...args) {
return this.$store.preference.getData(...args)
},
Expand Down Expand Up @@ -46,13 +47,11 @@ export default {
return false
}
const messageEl = this.$message({
message: this.$t('device.control.install.progress', {
const messageEl = this.$message.loading(
this.$t('device.control.install.progress', {
deviceName: this.$store.device.getLabel(device),
}),
icon: LoadingIcon,
duration: 0,
})
)
let failCount = 0
Expand Down
50 changes: 16 additions & 34 deletions src/components/Device/components/ControlBar/Screenshot/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<template>
<div class="" @click="handleScreenCap(device)">
<div class="" @click="handleCapture(device)">
<slot />
</div>
</template>

<script>
import LoadingIcon from '$/components/Device/components/LoadingIcon/index.vue'
export default {
props: {
device: {
Expand All @@ -18,29 +16,30 @@ export default {
return {}
},
methods: {
invoke(...args) {
return this.handleCapture(...args)
},
preferenceData(...args) {
return this.$store.preference.getData(...args)
},
async handleScreenCap(device) {
const messageEl = this.$message({
message: this.$t('device.control.capture.progress', {
async handleCapture(device) {
const messageEl = this.$message.loading(
this.$t('device.control.capture.progress', {
deviceName: this.$store.device.getLabel(device),
}),
icon: LoadingIcon,
duration: 0,
})
)
const fileName = this.$store.device.getLabel(
device,
({ time }) => `screenshot-${time}.png`,
({ time }) => `screenshot-${time}.jpg`,
)
const deviceConfig = this.preferenceData(device.id)
const savePath = this.$path.resolve(deviceConfig.savePath, fileName)
try {
await this.$adb.screencap(device.id, { savePath })
this.handleScreencapSuccess(savePath)
await this.handleSuccess(savePath)
}
catch (error) {
if (error.message) {
Expand All @@ -50,29 +49,12 @@ export default {
messageEl.close()
},
async handleScreencapSuccess(savePath) {
try {
await this.$confirm(
this.$t('device.control.capture.success.message'),
this.$t('device.control.capture.success.message.title'),
{
confirmButtonText: this.$t('common.confirm'),
cancelButtonText: this.$t('common.cancel'),
closeOnClickModal: false,
type: 'success',
},
)
await this.$electron.ipcRenderer.invoke(
'show-item-in-folder',
savePath,
)
}
catch (error) {
if (error.message) {
this.$message.warning(error.message)
}
}
async handleSuccess(savePath) {
return this.$message.success(
`${this.$t(
'device.control.capture.success.message.title',
)}: ${savePath}`,
)
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Device/components/ControlBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<script>
import Screenshot from './Screenshot/index.vue'
import AppInstall from './AppInstall/index.vue'
import Application from './Application/index.vue'
import Gnirehtet from './Gnirehtet/index.vue'
import MirrorGroup from './MirrorGroup/index.vue'
import Rotation from './Rotation/index.vue'
Expand All @@ -76,7 +76,7 @@ import FileManage from './FileManage/index.vue'
export default {
components: {
Screenshot,
AppInstall,
Application,
Gnirehtet,
MirrorGroup,
Rotation,
Expand Down Expand Up @@ -142,7 +142,7 @@ export default {
{
label: 'device.control.install',
svgIcon: 'install',
component: 'AppInstall',
component: 'Application',
},
{
label: 'device.control.file.name',
Expand Down
Loading

0 comments on commit db9e3e7

Please sign in to comment.