Skip to content

Commit

Permalink
feat: 🚀 Add basic timing task function
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Jul 23, 2024
1 parent 8e6af20 commit 04a7608
Show file tree
Hide file tree
Showing 28 changed files with 1,107 additions and 538 deletions.
2 changes: 2 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ declare module 'vue' {
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"electron-in-page-search": "^1.3.2",
"nanoid": "^5.0.7",
"vue": "^3.4.26"
},
"devDependencies": {
Expand Down
61 changes: 37 additions & 24 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
<template>
<div class="absolute inset-0 px-4 pb-4 h-full">
<el-tabs
v-model="activeTab"
class="el-tabs-flex"
addable
@tab-change="onTabChange"
>
<template #add-icon>
<AppSearch />
</template>
<el-tab-pane
v-for="(item, index) of tabsModel"
:key="index"
:label="$t(item.label)"
:name="item.prop"
lazy
<el-config-provider :locale="locale">
<div class="absolute inset-0 px-4 pb-4 h-full">
<el-tabs
v-model="activeTab"
class="el-tabs-flex"
addable
@tab-change="onTabChange"
>
<component
:is="item.component"
v-if="isRender(item)"
:ref="item.prop"
/>
</el-tab-pane>
</el-tabs>
</div>
<template #add-icon>
<AppSearch />
</template>
<el-tab-pane
v-for="(item, index) of tabsModel"
:key="index"
:label="$t(item.label)"
:name="item.prop"
lazy
>
<component
:is="item.component"
v-if="isRender(item)"
:ref="item.prop"
/>
</el-tab-pane>
</el-tabs>
</div>
</el-config-provider>
</template>

<script setup>
Expand All @@ -34,9 +36,20 @@ import Preference from './components/Preference/index.vue'
import About from './components/About/index.vue'
import AppSearch from './components/Search/index.vue'
import { i18n } from '$/locales/index.js'
import localeModel from '$/plugins/element-plus/locale.js'
import { useThemeStore } from '$/store/theme/index.js'
import { usePreferenceStore } from '$/store/preference/index.js'
const locale = computed(() => {
const i18nLocale = i18n.global.locale.value
const value = localeModel[i18nLocale]
return value
})
const tabsModel = ref([
{
label: 'device.list',
Expand Down
81 changes: 18 additions & 63 deletions src/components/Device/components/BatchActions/Application/index.vue
Original file line number Diff line number Diff line change
@@ -1,76 +1,31 @@
<template>
<div class="" @click="handleClick">
<div class="" @click="handleClick(devices)">
<slot v-bind="{ loading }" />
<ApplicationProxy ref="applicationProxyRef" />
</div>
</template>

<script>
import ApplicationProxy from '$/components/Device/components/ControlBar/Application/index.vue'
import { allSettledWrapper } from '$/utils'
<script setup>
import { useInstallAction } from '$/composables/useInstallAction/index.js'
export default {
components: {
ApplicationProxy,
},
props: {
devices: {
type: Array,
default: () => [],
},
},
data() {
return {
loading: false,
}
},
methods: {
async handleClick() {
let files = null
try {
files = await this.$electron.ipcRenderer.invoke('show-open-dialog', {
properties: ['openFile', 'multiSelections'],
filters: [
{
name: this.$t('device.control.install.placeholder'),
extensions: ['apk'],
},
],
})
}
catch (error) {
if (error.message) {
const message
= error.message?.match(/Error: (.*)/)?.[1] || error.message
this.$message.warning(message)
}
return false
}
import { useTaskStore } from '$/store/index.js'
this.loading = true
const closeMessage = this.$message.loading(
this.$t('device.control.install.progress', {
deviceName: window.t('common.device'),
}),
).close
await allSettledWrapper(this.devices, (item) => {
return this.$refs.applicationProxyRef.invoke(item, {
files,
silent: true,
})
})
const props = defineProps({
devices: {
type: Array,
default: () => [],
},
})
closeMessage()
const { loading, invoke: handleClick } = useInstallAction()
ElMessage.success(window.t('common.success.batch'))
const taskStore = useTaskStore()
this.loading = false
},
},
}
taskStore.on('install', (task) => {
taskStore.start({
task,
handler: handleClick,
})
})
</script>

<style></style>
50 changes: 2 additions & 48 deletions src/components/Device/components/BatchActions/FileManage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<el-dropdown :hide-on-click="false" :disabled="loading">
<div class="">
<slot :loading="loading" />
<FileManageProxy ref="fileManageProxyRef" />
</div>
<template #dropdown>
<el-dropdown-menu>
Expand All @@ -17,11 +16,7 @@
</template>

<script setup>
import { ElMessage } from 'element-plus'
import FileManageProxy from '$/components/Device/components/ControlBar/FileManage/index.vue'
import { selectAndSendFileToDevice } from '$/utils/device/index.js'
import { allSettledWrapper } from '$/utils'
import { useFileActions } from '$/composables/useFileActions/index.js'
const props = defineProps({
devices: {
Expand All @@ -30,48 +25,7 @@ const props = defineProps({
},
})
const loading = ref(false)
const fileManageProxyRef = ref(null)
async function handlePush(devices) {
let files = null
try {
files = await window.electron.ipcRenderer.invoke('show-open-dialog', {
properties: ['openFile', 'multiSelections'],
filters: [
{
name: window.t('device.control.file.push.placeholder'),
extensions: ['*'],
},
],
})
}
catch (error) {
if (error.message) {
const message = error.message?.match(/Error: (.*)/)?.[1] || error.message
ElMessage.warning(message)
}
return false
}
loading.value = true
const closeMessage = ElMessage.loading(
window.t('device.control.file.push.loading'),
).close
await allSettledWrapper(devices, (item) => {
return fileManageProxyRef.value.handlePush(item, { files, silent: true })
})
closeMessage()
ElMessage.success(window.t('common.success.batch'))
loading.value = false
}
const { loading, send: handlePush } = useFileActions()
</script>

<style></style>
56 changes: 18 additions & 38 deletions src/components/Device/components/BatchActions/Screenshot/index.vue
Original file line number Diff line number Diff line change
@@ -1,51 +1,31 @@
<template>
<div class="" @click="handleClick">
<div class="" @click="handleClick(devices)">
<slot v-bind="{ loading }" />
<ScreenshotProxy ref="screenshotProxyRef" />
</div>
</template>

<script>
import ScreenshotProxy from '$/components/Device/components/ControlBar/Screenshot/index.vue'
import { allSettledWrapper, sleep } from '$/utils'
<script setup>
import { useTaskStore } from '$/store/index.js'
export default {
components: {
ScreenshotProxy,
},
props: {
devices: {
type: Array,
default: () => [],
},
},
data() {
return {
loading: false,
}
},
methods: {
async handleClick() {
this.loading = true
import { useScreenshotAction } from '$/composables/useScreenshotAction/index.js'
const closeMessage = this.$message.loading(
window.t('device.control.capture.progress', {
deviceName: window.t('common.device'),
}),
).close
await allSettledWrapper(this.devices, (item) => {
return this.$refs.screenshotProxyRef.invoke(item, { silent: true })
})
const props = defineProps({
devices: {
type: Array,
default: () => [],
},
})
closeMessage()
const { loading, invoke: handleClick } = useScreenshotAction()
ElMessage.success(window.t('common.success.batch'))
const taskStore = useTaskStore()
this.loading = false
},
},
}
taskStore.on('screenshot', (task) => {
taskStore.start({
task,
handler: handleClick,
})
})
</script>

<style></style>
Loading

0 comments on commit 04a7608

Please sign in to comment.