diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index fcbb126..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution') - -module.exports = { - extends: [ - 'eslint:recommended', - 'plugin:vue/vue3-recommended', - '@electron-toolkit', - '@vue/eslint-config-prettier', - ], - rules: { - 'vue/require-default-prop': 'off', - 'vue/multi-word-component-names': 'off', - }, -} diff --git a/.eslintrc.js b/.eslintrc.js index 649dcbb..96ee5c4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,6 @@ +/* eslint-env node */ +require('@rushstack/eslint-patch/modern-module-resolution') + module.exports = { extends: ['@electron-toolkit', '@viarotel-org'], rules: { diff --git a/src/main/index.js b/src/main/index.js index 13ed426..5cde97c 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -3,6 +3,8 @@ import { BrowserWindow, app, shell } from 'electron' import { electronApp, is, optimizer } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' +import './ipc/index.js' + function createWindow() { // Create the browser window. const mainWindow = new BrowserWindow({ diff --git a/src/main/ipc/index.js b/src/main/ipc/index.js new file mode 100644 index 0000000..2c76ce4 --- /dev/null +++ b/src/main/ipc/index.js @@ -0,0 +1,6 @@ +import { app, ipcMain } from 'electron' + +ipcMain.on('restart-app', () => { + app.relaunch() + app.quit() +}) diff --git a/src/preload/index.js b/src/preload/index.js index 9bac5d2..8623415 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -22,11 +22,44 @@ addContext('adbkit', () => { const getDevices = async () => await client.listDevicesWithPaths() const shell = async (id, command) => await client.getDevice(id).shell(command) - const kill = async () => await client.kill() + 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) + }) + + tracker.on('remove', (device) => { + callback(device) + }) + + tracker.on('end', (ret) => { + callback(ret) + }) + + tracker.on('error', (err) => { + callback(err) + }) + + const close = () => tracker.end() + + return close + } + + // window.addEventListener('beforeunload', () => { + // kill() + // }) + return { getDevices, shell, kill, + connect, + disconnect, + watch, } }) diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index b9f3e17..a451a76 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -6,6 +6,7 @@ :key="index" :label="item.label" :name="item.prop" + lazy > diff --git a/src/renderer/src/components/Wired/index.vue b/src/renderer/src/components/Wired/index.vue index 1ad45a9..5a95021 100644 --- a/src/renderer/src/components/Wired/index.vue +++ b/src/renderer/src/components/Wired/index.vue @@ -1,15 +1,18 @@