Skip to content

Commit

Permalink
perf: ⬆️ Optimize the performance of the floating control bar
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Sep 16, 2024
1 parent 790e703 commit a1c60ec
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 30 deletions.
40 changes: 20 additions & 20 deletions control/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ import { ElMessage } from 'element-plus'
const themeStore = useThemeStore()
const deviceStore = useDeviceStore()
themeStore.init()
onMounted(() => {
window.electron.ipcRenderer.send('control-mounted')
})
const locale = computed(() => {
const i18nLocale = i18n.global.locale.value
Expand All @@ -84,31 +78,37 @@ const locale = computed(() => {
const deviceInfo = ref({})
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)
})
const deviceList = ref([])
function handleClose() {
window.electron.ipcRenderer.send('hide-active-window')
}
const deviceList = ref([])
async function switchDevice(e) {
e.preventDefault()
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>

<style lang="postcss">
Expand Down
2 changes: 1 addition & 1 deletion control/electron/events/devices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BrowserWindow, ipcMain, Menu } from 'electron'
import { openControlWindow } from '$control/electron/helpers/index.js'

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) => {
let label = item.$remark || item.$name

Expand Down
2 changes: 1 addition & 1 deletion control/electron/events/gnirehtet/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserWindow, ipcMain, Menu } from 'electron'

export default function (controlWindow) {
ipcMain.handle('open-device-gnirehtet-menu', openDeviceGnirehtetMenu)
ipcMain.on('open-device-gnirehtet-menu', openDeviceGnirehtetMenu)

function openDeviceGnirehtetMenu(event, args = {}) {
const { options = [] } = args
Expand Down
2 changes: 1 addition & 1 deletion control/electron/events/rotation/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserWindow, ipcMain, Menu } from 'electron'

export default function (controlWindow) {
ipcMain.handle('open-device-rotation-menu', openDeviceRotationMenu)
ipcMain.on('open-device-rotation-menu', openDeviceRotationMenu)

function openDeviceRotationMenu(event, args = {}) {
const { options = [] } = args
Expand Down
2 changes: 1 addition & 1 deletion control/electron/events/volume/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserWindow, ipcMain, Menu } from 'electron'

export default function (controlWindow) {
ipcMain.handle('open-device-volume-menu', openDeviceVolumeMenu)
ipcMain.on('open-device-volume-menu', openDeviceVolumeMenu)

function openDeviceVolumeMenu(event, args = {}) {
const { options = [] } = args
Expand Down
4 changes: 2 additions & 2 deletions control/electron/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function initControlWindow(mainWindow) {
icon: getLogoPath(),
width: 500,
minWidth: 500,
height: 30,
maxHeight: 30,
height: 28,
maxHeight: 28,
frame: false,
show: false,
autoHideMenuBar: true,
Expand Down
2 changes: 1 addition & 1 deletion control/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default (mainWindow) => {
controlWindow = initControlWindow(mainWindow)

ipcMain.on('control-mounted', () => {
onControlMounted(controlWindow)
openControlWindow(controlWindow, data)
onControlMounted(controlWindow)
})
})
}
Binary file modified electron/resources/extra/win/scrcpy/SDL2.dll
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/avcodec-61.dll
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/avformat-61.dll
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/avutil-59.dll
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/libusb-1.0.dll
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/scrcpy-server
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/scrcpy.exe
Binary file not shown.
Binary file modified electron/resources/extra/win/scrcpy/swresample-5.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
},
]
window.electron.ipcRenderer.invoke('open-device-gnirehtet-menu', {
window.electron.ipcRenderer.send('open-device-gnirehtet-menu', {
options,
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
const options = toRaw(this.options)
window.electron.ipcRenderer.invoke('open-device-rotation-menu', {
window.electron.ipcRenderer.send('open-device-rotation-menu', {
options,
})
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<el-dropdown :disabled="loading" @command="handleCommand">
<slot :loading />

<template #dropdown>
<el-dropdown-menu>
<template v-if="!loading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
const options = toRaw(this.options)
window.electron.ipcRenderer.invoke('open-device-volume-menu', {
window.electron.ipcRenderer.send('open-device-volume-menu', {
options,
})
},
Expand Down

0 comments on commit a1c60ec

Please sign in to comment.