perf: 🐛 Global search error

This commit is contained in:
viarotel 2024-05-15 11:16:02 +08:00
parent 8587977627
commit 091d5035dd
39 changed files with 96 additions and 77 deletions

View File

@ -2,7 +2,7 @@
<div class="flex flex-col absolute inset-0 h-full overflow-hidden">
<div class="py-4 px-4 flex items-center flex-none">
<a class="block" :href="escrcpyURL" target="_blank">
<img src="#electron/resources/build/logo.png" class="h-9" alt="" />
<img src="$electron/resources/build/logo.png" class="h-9" alt="" />
</a>
<div class="pl-2 text-sm">
Escrcpy Copilot

View File

@ -25,10 +25,10 @@
</template>
<script>
import logoURL from '#electron/resources/build/logo.png'
import userURL from '#/assets/user.png'
import mobileURL from '#/assets/mobile.png'
import computerURL from '#/assets/computer.png'
import logoURL from '$electron/resources/build/logo.png'
import userURL from '$/assets/user.png'
import mobileURL from '$/assets/mobile.png'
import computerURL from '$/assets/computer.png'
export default {
props: {

View File

@ -2,14 +2,14 @@ import { createApp, toRaw } from 'vue'
import App from './App.vue'
import { mockAPI } from './utils/index.js'
import ws from './utils/ws.js'
import { i18n, t } from '#/locales/index.js'
import plugins from '#/plugins/index.js'
import icons from '#/icons/index.js'
import { i18n, t } from '$/locales/index.js'
import plugins from '$/plugins/index.js'
import icons from '$/icons/index.js'
import { replaceIP, restoreIP } from '#/utils/index.js'
import { replaceIP, restoreIP } from '$/utils/index.js'
import 'virtual:uno.css'
import '#/styles/index.js'
import '$/styles/index.js'
const app = createApp(App)

View File

@ -1,4 +1,4 @@
import { extraResolve } from '#electron/helpers/index.js'
import { extraResolve } from '$electron/helpers/index.js'
export const getAdbPath = () => {
switch (process.platform) {

View File

@ -1,5 +1,5 @@
import which from 'which'
import { extraResolve } from '#electron/helpers/index.js'
import { extraResolve } from '$electron/helpers/index.js'
export const getGnirehtetPath = () => {
switch (process.platform) {

View File

@ -1,6 +1,6 @@
import { resolve } from 'node:path'
import { buildResolve, extraResolve } from '#electron/helpers/index.js'
import { buildResolve, extraResolve } from '$electron/helpers/index.js'
export { adbPath } from './android-platform-tools/index.js'

View File

@ -1,5 +1,5 @@
import which from 'which'
import { extraResolve } from '#electron/helpers/index.js'
import { extraResolve } from '$electron/helpers/index.js'
export const getScrcpyPath = () => {
switch (process.platform) {

View File

@ -1,7 +1,7 @@
import { Menu, Tray, app, dialog } from 'electron'
import { trayPath } from '#electron/configs/index.js'
import appStore from '#electron/helpers/store.js'
import { executeI18n } from '#electron/helpers/index.js'
import { trayPath } from '$electron/configs/index.js'
import appStore from '$electron/helpers/store.js'
import { executeI18n } from '$electron/helpers/index.js'
export default (mainWindow) => {
const t = value => executeI18n(mainWindow, value)

View File

@ -1,7 +1,7 @@
import { app, ipcMain } from 'electron'
import { is } from '@electron-toolkit/utils'
import electronUpdater from 'electron-updater'
import { devPublishPath } from '#electron/configs/index.js'
import { devPublishPath } from '$electron/configs/index.js'
const { autoUpdater } = electronUpdater

View File

@ -5,8 +5,8 @@ import fs from 'node:fs'
import dayjs from 'dayjs'
import { Adb } from '@devicefarmer/adbkit'
import { uniq } from 'lodash-es'
import appStore from '#electron/helpers/store.js'
import { adbPath } from '#electron/configs/index.js'
import appStore from '$electron/helpers/store.js'
import { adbPath } from '$electron/configs/index.js'
const exec = util.promisify(_exec)

View File

@ -1,10 +1,10 @@
import { spawn } from 'node:child_process'
import appStore from '#electron/helpers/store.js'
import appStore from '$electron/helpers/store.js'
import {
adbPath,
gnirehtetApkPath,
gnirehtetPath,
} from '#electron/configs/index.js'
} from '$electron/configs/index.js'
const appDebug = appStore.get('common.debug') || false

View File

@ -1,14 +1,14 @@
import path from 'node:path'
import '#electron/helpers/console.js'
import '$electron/helpers/console.js'
import electron from './electron/index.js'
import adbkit from './adbkit/index.js'
import scrcpy from './scrcpy/index.js'
import gnirehtet from './gnirehtet/index.js'
import search from './search/index.js'
import * as configs from '#electron/configs/index.js'
import store from '#electron/helpers/store.js'
import appLog from '#electron/helpers/log.js'
import * as configs from '$electron/configs/index.js'
import store from '$electron/helpers/store.js'
import appLog from '$electron/helpers/log.js'
export default {
init(expose) {

View File

@ -1,5 +1,5 @@
import log from 'electron-log/main.js'
import { createProxy } from '#electron/helpers/index'
import { createProxy } from '$electron/helpers/index'
const levels = Object.keys(log.functions)

View File

@ -1,8 +1,8 @@
import util from 'node:util'
import { exec as _exec, spawn } from 'node:child_process'
import { replaceIP, sleep } from '#renderer/utils/index.js'
import appStore from '#electron/helpers/store.js'
import { adbPath, scrcpyPath } from '#electron/configs/index.js'
import { replaceIP, sleep } from '$renderer/utils/index.js'
import appStore from '$electron/helpers/store.js'
import { adbPath, scrcpyPath } from '$electron/configs/index.js'
let adbkit

View File

@ -1,28 +1,32 @@
import remote from '@electron/remote'
import { FindInPage } from 'electron-find-in-page'
import { primaryColor } from '#renderer/configs/index.js'
import { primaryColor } from '$renderer/configs/index.js'
export default () => {
const theme = {
isDark: false,
}
let findInPage = create()
let findInPage = null
async function open({ isDark = false } = {}) {
if (theme.isDark !== isDark) {
theme.isDark = isDark
await update()
}
async function open({ ...args } = {}) {
await create(args)
return findInPage.openFindWindow()
}
function close() {
if (!findInPage) {
return false
}
return findInPage.closeFindWindow()
}
async function update() {
async function update({ isDark = false, ...args } = {}) {
if (isDark === theme.isDark) {
return findInPage
}
try {
await findInPage.destroy()
}
@ -30,11 +34,20 @@ export default () => {
console.warn('error', error.message)
}
findInPage = create()
findInPage = null
return create({ ...args, isDark })
}
function create() {
return new FindInPage(remote.getCurrentWebContents(), {
async function create({ ...args } = {}) {
if (findInPage) {
return update(args)
}
theme.isDark = args.isDark
findInPage = new FindInPage(remote.getCurrentWebContents(), {
...args,
preload: true,
inputFocusColor: primaryColor,
...(theme.isDark
@ -48,6 +61,8 @@ export default () => {
}
: {}),
})
return findInPage
}
return {

View File

@ -1,6 +1,6 @@
import appStore from './store.js'
import { createProxy } from './index.js'
import log from '#electron/helpers/log.js'
import log from '$electron/helpers/log.js'
const debug = appStore.get('common.debug') || false

View File

@ -1,6 +1,6 @@
import { shell } from 'electron'
import log from 'electron-log/main.js'
import { createProxy } from '#electron/helpers/index'
import { createProxy } from '$electron/helpers/index'
log.transports.console.level = false

View File

@ -2,11 +2,11 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#/*": ["src/*"],
"#copilot/*": ["copilot/*"],
"#root/*": ["*"],
"#electron/*": ["electron/*"],
"#renderer/*": ["src/*"]
"$/*": ["src/*"],
"$copilot/*": ["copilot/*"],
"$root/*": ["*"],
"$electron/*": ["electron/*"],
"$renderer/*": ["src/*"]
}
},
"exclude": ["node_modules", "dist", "dist-electron", "dist-release"],

View File

@ -35,8 +35,8 @@ import Preference from './components/Preference/index.vue'
import About from './components/About/index.vue'
import AppSearch from './components/AppSearch/index.vue'
import { useThemeStore } from '#/store/theme/index.js'
import { usePreferenceStore } from '#/store/preference/index.js'
import { useThemeStore } from '$/store/theme/index.js'
import { usePreferenceStore } from '$/store/preference/index.js'
const tabsModel = ref([
{

View File

@ -1,7 +1,7 @@
<template>
<div class="flex flex-col items-center justify-center h-full -mt-8">
<a class="block" :href="escrcpyURL" target="_blank">
<img src="#electron/resources/build/logo.png" class="h-48" alt="" />
<img src="$electron/resources/build/logo.png" class="h-48" alt="" />
</a>
<div class="pt-4 text-xl text-center italic text-gray-700 dark:text-white">

View File

@ -15,7 +15,7 @@
</template>
<script setup>
import { useThemeStore } from '#/store'
import { useThemeStore } from '$/store'
const themeStore = useThemeStore()

View File

@ -5,7 +5,7 @@
</template>
<script>
import LoadingIcon from '#/components/Device/components/LoadingIcon/index.vue'
import LoadingIcon from '$/components/Device/components/LoadingIcon/index.vue'
export default {
props: {

View File

@ -15,7 +15,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -21,7 +21,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -18,7 +18,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -5,7 +5,7 @@
</template>
<script>
import LoadingIcon from '#/components/Device/components/LoadingIcon/index.vue'
import LoadingIcon from '$/components/Device/components/LoadingIcon/index.vue'
export default {
props: {

View File

@ -12,7 +12,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -3,7 +3,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -3,7 +3,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -3,7 +3,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {

View File

@ -170,6 +170,10 @@ export default {
const totalCount = this.wirelessList.length
if (!totalCount) {
return false
}
let failCount = 0
const promises = []

View File

@ -30,7 +30,7 @@
</template>
<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
inheritAttrs: false,

View File

@ -120,7 +120,7 @@ import MirrorAction from './components/MirrorAction/index.vue'
import MoreDropdown from './components/MoreDropdown/index.vue'
import WirelessAction from './components/WirelessAction/index.vue'
import { isIPWithPort, sleep } from '#/utils/index.js'
import { isIPWithPort, sleep } from '$/utils/index.js'
export default {
components: {

View File

@ -18,7 +18,7 @@
</template>
<script>
import { i18n } from '#/locales/index.js'
import { i18n } from '$/locales/index.js'
export default {
props: {

View File

@ -207,8 +207,8 @@ import AudioCodecSelect from './components/AudioCodecSelect/index.vue'
import DisplaySelect from './components/DisplaySelect/index.vue'
import KeyboardInjectSelect from './components/KeyboardInjectSelect/index.vue'
import { usePreferenceStore } from '#/store/index.js'
import LoadingIcon from '#/components/Device/components/LoadingIcon/index.vue'
import { usePreferenceStore } from '$/store/index.js'
import LoadingIcon from '$/components/Device/components/LoadingIcon/index.vue'
export default {
components: {

View File

@ -1,4 +1,4 @@
import '#/utils/console.js'
import '$/utils/console.js'
import { createApp, toRaw } from 'vue'
import App from './App.vue'
@ -10,7 +10,7 @@ import icons from './icons/index.js'
import { i18n, t } from './locales/index.js'
import { replaceIP, restoreIP } from '#/utils/index.js'
import { replaceIP, restoreIP } from '$/utils/index.js'
import 'virtual:uno.css'
import './styles/index.js'

View File

@ -1,8 +1,8 @@
import { defineStore } from 'pinia'
import dayjs from 'dayjs'
import { t } from '#/locales/index.js'
import { isIPWithPort, replaceIP } from '#/utils/index.js'
import { t } from '$/locales/index.js'
import { isIPWithPort, replaceIP } from '$/utils/index.js'
const $appStore = window.appStore

View File

@ -11,7 +11,7 @@ import {
setStoreData,
} from './helpers/index.js'
import { replaceIP, restoreIP } from '#/utils/index.js'
import { replaceIP, restoreIP } from '$/utils/index.js'
const { adbPath, scrcpyPath, gnirehtetPath } = window.electron?.configs || {}

View File

@ -18,9 +18,9 @@ const merge = (config, { command = '' } = {}) =>
{
resolve: {
alias: {
'#root': resolve(),
'#electron': resolve('electron'),
'#renderer': resolve('src'),
$root: resolve(),
$electron: resolve('electron'),
$renderer: resolve('src'),
},
},
plugins: [...(command === 'serve' ? [notBundle()] : [])],
@ -41,9 +41,9 @@ export default args =>
},
resolve: {
alias: {
'#': resolve('src'),
'#copilot': resolve('copilot'),
'#electron': resolve('electron'),
$: resolve('src'),
$copilot: resolve('copilot'),
$electron: resolve('electron'),
},
},
plugins: [