mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2024-11-24 07:30:15 +01:00
perf: ♻️ Improve code robustness
This commit is contained in:
parent
3d4dc7c981
commit
2f389af834
@ -20,7 +20,6 @@
|
||||
:is="item.component"
|
||||
v-if="isRender(item)"
|
||||
:ref="item.prop"
|
||||
:re-render="reRender"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<script>
|
||||
import ApplicationProxy from '$/components/Device/components/ControlBar/Application/index.vue'
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -50,7 +50,7 @@ export default {
|
||||
|
||||
this.loading = true
|
||||
|
||||
await allSettled(this.devices, (item) => {
|
||||
await allSettledWrapper(this.devices, (item) => {
|
||||
return this.$refs.applicationProxyRef.invoke(item, { files })
|
||||
})
|
||||
|
||||
|
@ -21,7 +21,7 @@ import { ElMessage } from 'element-plus'
|
||||
import FileManageProxy from '$/components/Device/components/ControlBar/FileManage/index.vue'
|
||||
|
||||
import { selectAndSendFileToDevice } from '$/utils/device/index.js'
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
|
||||
const props = defineProps({
|
||||
devices: {
|
||||
@ -58,7 +58,7 @@ async function handlePush(devices) {
|
||||
|
||||
loading.value = true
|
||||
|
||||
await allSettled(devices, (item) => {
|
||||
await allSettledWrapper(devices, (item) => {
|
||||
return fileManageProxyRef.value.handlePush(item, { files })
|
||||
})
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<script>
|
||||
import ScreenshotProxy from '$/components/Device/components/ControlBar/Screenshot/index.vue'
|
||||
import { allSettled, sleep } from '$/utils'
|
||||
import { allSettledWrapper, sleep } from '$/utils'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -28,7 +28,7 @@ export default {
|
||||
async handleClick() {
|
||||
this.loading = true
|
||||
|
||||
await allSettled(this.devices, (item) => {
|
||||
await allSettledWrapper(this.devices, (item) => {
|
||||
return this.$refs.screenshotProxyRef.invoke(item)
|
||||
})
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<script setup>
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { selectAndSendFileToDevice } from '$/utils/device/index.js'
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
|
||||
const props = defineProps({
|
||||
devices: {
|
||||
@ -44,7 +44,7 @@ async function handleClick(devices) {
|
||||
|
||||
const failFiles = []
|
||||
|
||||
await allSettled(devices, async (device) => {
|
||||
await allSettledWrapper(devices, async (device) => {
|
||||
const successFiles = await selectAndSendFileToDevice(device.id, {
|
||||
files,
|
||||
loadingText: window.t('device.control.shell.push.loading'),
|
||||
|
@ -5,7 +5,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -55,7 +55,7 @@ export default {
|
||||
|
||||
let failCount = 0
|
||||
|
||||
await allSettled(files, (item) => {
|
||||
await allSettledWrapper(files, (item) => {
|
||||
return this.$adb.install(device.id, item).catch((e) => {
|
||||
console.warn(e)
|
||||
++failCount
|
||||
|
@ -19,7 +19,7 @@
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { selectAndSendFileToDevice } from '$/utils/device/index.js'
|
||||
import { useDeviceStore } from '$/store'
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
|
||||
const props = defineProps({
|
||||
device: {
|
||||
@ -65,7 +65,7 @@ async function handlePush(device, { files } = {}) {
|
||||
|
||||
let failCount = 0
|
||||
|
||||
await allSettled(files, (item) => {
|
||||
await allSettledWrapper(files, (item) => {
|
||||
return window.adbkit.push(device.id, item).catch(() => {
|
||||
++failCount
|
||||
})
|
||||
|
@ -64,11 +64,6 @@ export default {
|
||||
deviceScope,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
preferenceModel() {
|
||||
return this.preferenceStore.model || {}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'preferenceData': {
|
||||
handler() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { allSettled } from '$/utils'
|
||||
import { allSettledWrapper } from '$/utils'
|
||||
/**
|
||||
* 选择并将文件发送到设备
|
||||
*/
|
||||
@ -42,7 +42,7 @@ export async function selectAndSendFileToDevice(
|
||||
const successFiles = []
|
||||
const failFiles = []
|
||||
|
||||
await allSettled(files, async (item) => {
|
||||
await allSettledWrapper(files, async (item) => {
|
||||
const ret = await window.adbkit.push(deviceId, item).catch((e) => {
|
||||
console.warn(e?.message)
|
||||
failFiles.push(`${deviceId}-${item}`)
|
||||
|
@ -76,9 +76,9 @@ export function keyByValue(data, key = 'key', valueKey = 'value') {
|
||||
* throw new Error('奇数');
|
||||
* }
|
||||
* };
|
||||
* allSettled(list, iterator).then(console.log);
|
||||
* allSettledWrapper(list, iterator).then(console.log);
|
||||
*/
|
||||
export function allSettled(list = [], iterator) {
|
||||
export function allSettledWrapper(list = [], iterator) {
|
||||
const promises = []
|
||||
|
||||
for (let index = 0; index < list.length; index++) {
|
||||
|
Loading…
Reference in New Issue
Block a user