Skip to content

Commit

Permalink
perf: 🐛 Global search error
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed May 15, 2024
1 parent 8587977 commit 091d503
Show file tree
Hide file tree
Showing 39 changed files with 96 additions and 77 deletions.
2 changes: 1 addition & 1 deletion copilot/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions copilot/components/Transmission/Message/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
10 changes: 5 additions & 5 deletions copilot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion electron/configs/android-platform-tools/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extraResolve } from '#electron/helpers/index.js'
import { extraResolve } from '$electron/helpers/index.js'

export const getAdbPath = () => {
switch (process.platform) {
Expand Down
2 changes: 1 addition & 1 deletion electron/configs/gnirehtet/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion electron/configs/index.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion electron/configs/scrcpy/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions electron/events/tray/index.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion electron/events/updater/index.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions electron/exposes/adbkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions electron/exposes/gnirehtet/index.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 4 additions & 4 deletions electron/exposes/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion electron/exposes/log/index.js
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 3 additions & 3 deletions electron/exposes/scrcpy/index.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
37 changes: 26 additions & 11 deletions electron/exposes/search/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
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()
}
catch (error) {
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
Expand All @@ -48,6 +61,8 @@ export default () => {
}
: {}),
})

return findInPage
}

return {
Expand Down
2 changes: 1 addition & 1 deletion electron/helpers/console.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion electron/helpers/log.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 5 additions & 5 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/About/index.vue
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppSearch/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</template>

<script setup>
import { useThemeStore } from '#/store'
import { useThemeStore } from '$/store'
const themeStore = useThemeStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/components/MirrorAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
props: {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Device/components/Wireless/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export default {
const totalCount = this.wirelessList.length
if (!totalCount) {
return false
}
let failCount = 0
const promises = []
Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/components/WirelessAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</template>

<script>
import { sleep } from '#/utils'
import { sleep } from '$/utils'
export default {
inheritAttrs: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Device/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading

0 comments on commit 091d503

Please sign in to comment.