mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2025-02-17 18:59:19 +01:00
perf: ⬆️ Optimize the performance of the floating control bar
This commit is contained in:
parent
790e70349a
commit
a1c60ecd78
@ -68,12 +68,6 @@ import { ElMessage } from 'element-plus'
|
|||||||
const themeStore = useThemeStore()
|
const themeStore = useThemeStore()
|
||||||
const deviceStore = useDeviceStore()
|
const deviceStore = useDeviceStore()
|
||||||
|
|
||||||
themeStore.init()
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
window.electron.ipcRenderer.send('control-mounted')
|
|
||||||
})
|
|
||||||
|
|
||||||
const locale = computed(() => {
|
const locale = computed(() => {
|
||||||
const i18nLocale = i18n.global.locale.value
|
const i18nLocale = i18n.global.locale.value
|
||||||
|
|
||||||
@ -84,31 +78,37 @@ const locale = computed(() => {
|
|||||||
|
|
||||||
const deviceInfo = ref({})
|
const deviceInfo = ref({})
|
||||||
|
|
||||||
window.electron.ipcRenderer.on('device-change', (event, data) => {
|
const deviceList = ref([])
|
||||||
deviceInfo.value = data
|
|
||||||
})
|
|
||||||
|
|
||||||
window.electron.ipcRenderer.on('language-change', (event, data) => {
|
|
||||||
i18n.global.locale.value = data
|
|
||||||
})
|
|
||||||
|
|
||||||
window.electron.ipcRenderer.on('theme-change', (event, data) => {
|
|
||||||
themeStore.update(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
window.electron.ipcRenderer.send('hide-active-window')
|
window.electron.ipcRenderer.send('hide-active-window')
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceList = ref([])
|
|
||||||
|
|
||||||
async function switchDevice(e) {
|
async function switchDevice(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
const data = await deviceStore.getList()
|
const data = await deviceStore.getList()
|
||||||
|
|
||||||
window.electron.ipcRenderer.invoke('open-control-device-menu', data)
|
window.electron.ipcRenderer.send('open-control-device-menu', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.electron.ipcRenderer.send('control-mounted')
|
||||||
|
|
||||||
|
themeStore.init()
|
||||||
|
|
||||||
|
window.electron.ipcRenderer.on('device-change', (event, data) => {
|
||||||
|
deviceInfo.value = data
|
||||||
|
})
|
||||||
|
|
||||||
|
window.electron.ipcRenderer.on('language-change', (event, data) => {
|
||||||
|
i18n.global.locale.value = data
|
||||||
|
})
|
||||||
|
|
||||||
|
window.electron.ipcRenderer.on('theme-change', (event, data) => {
|
||||||
|
themeStore.update(data)
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
|
@ -2,7 +2,7 @@ import { BrowserWindow, ipcMain, Menu } from 'electron'
|
|||||||
import { openControlWindow } from '$control/electron/helpers/index.js'
|
import { openControlWindow } from '$control/electron/helpers/index.js'
|
||||||
|
|
||||||
export default function (controlWindow) {
|
export default function (controlWindow) {
|
||||||
ipcMain.handle('open-control-device-menu', (event, deviceList) => {
|
ipcMain.on('open-control-device-menu', (event, deviceList) => {
|
||||||
const template = deviceList.map((item) => {
|
const template = deviceList.map((item) => {
|
||||||
let label = item.$remark || item.$name
|
let label = item.$remark || item.$name
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
||||||
|
|
||||||
export default function (controlWindow) {
|
export default function (controlWindow) {
|
||||||
ipcMain.handle('open-device-gnirehtet-menu', openDeviceGnirehtetMenu)
|
ipcMain.on('open-device-gnirehtet-menu', openDeviceGnirehtetMenu)
|
||||||
|
|
||||||
function openDeviceGnirehtetMenu(event, args = {}) {
|
function openDeviceGnirehtetMenu(event, args = {}) {
|
||||||
const { options = [] } = args
|
const { options = [] } = args
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
||||||
|
|
||||||
export default function (controlWindow) {
|
export default function (controlWindow) {
|
||||||
ipcMain.handle('open-device-rotation-menu', openDeviceRotationMenu)
|
ipcMain.on('open-device-rotation-menu', openDeviceRotationMenu)
|
||||||
|
|
||||||
function openDeviceRotationMenu(event, args = {}) {
|
function openDeviceRotationMenu(event, args = {}) {
|
||||||
const { options = [] } = args
|
const { options = [] } = args
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
||||||
|
|
||||||
export default function (controlWindow) {
|
export default function (controlWindow) {
|
||||||
ipcMain.handle('open-device-volume-menu', openDeviceVolumeMenu)
|
ipcMain.on('open-device-volume-menu', openDeviceVolumeMenu)
|
||||||
|
|
||||||
function openDeviceVolumeMenu(event, args = {}) {
|
function openDeviceVolumeMenu(event, args = {}) {
|
||||||
const { options = [] } = args
|
const { options = [] } = args
|
||||||
|
@ -12,8 +12,8 @@ export function initControlWindow(mainWindow) {
|
|||||||
icon: getLogoPath(),
|
icon: getLogoPath(),
|
||||||
width: 500,
|
width: 500,
|
||||||
minWidth: 500,
|
minWidth: 500,
|
||||||
height: 30,
|
height: 28,
|
||||||
maxHeight: 30,
|
maxHeight: 28,
|
||||||
frame: false,
|
frame: false,
|
||||||
show: false,
|
show: false,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
@ -34,8 +34,8 @@ export default (mainWindow) => {
|
|||||||
controlWindow = initControlWindow(mainWindow)
|
controlWindow = initControlWindow(mainWindow)
|
||||||
|
|
||||||
ipcMain.on('control-mounted', () => {
|
ipcMain.on('control-mounted', () => {
|
||||||
onControlMounted(controlWindow)
|
|
||||||
openControlWindow(controlWindow, data)
|
openControlWindow(controlWindow, data)
|
||||||
|
onControlMounted(controlWindow)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -69,7 +69,7 @@ export default {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
window.electron.ipcRenderer.invoke('open-device-gnirehtet-menu', {
|
window.electron.ipcRenderer.send('open-device-gnirehtet-menu', {
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -82,7 +82,7 @@ export default {
|
|||||||
|
|
||||||
const options = toRaw(this.options)
|
const options = toRaw(this.options)
|
||||||
|
|
||||||
window.electron.ipcRenderer.invoke('open-device-rotation-menu', {
|
window.electron.ipcRenderer.send('open-device-rotation-menu', {
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dropdown :disabled="loading" @command="handleCommand">
|
<el-dropdown :disabled="loading" @command="handleCommand">
|
||||||
<slot :loading />
|
<slot :loading />
|
||||||
|
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<template v-if="!loading">
|
<template v-if="!loading">
|
||||||
|
@ -76,7 +76,7 @@ export default {
|
|||||||
|
|
||||||
const options = toRaw(this.options)
|
const options = toRaw(this.options)
|
||||||
|
|
||||||
window.electron.ipcRenderer.invoke('open-device-volume-menu', {
|
window.electron.ipcRenderer.send('open-device-volume-menu', {
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user