fix: 🐛 Fixed the issue where there is a chance of an error when closing the floating control bar on macOS

This commit is contained in:
viarotel
2025-07-14 14:37:43 +08:00
parent 608b8f3120
commit 5c2c71131c
3 changed files with 13 additions and 6 deletions

View File

@@ -64,7 +64,6 @@ import { i18n } from '$/locales/index.js'
import localeModel from '$/plugins/element-plus/locale.js'
const deviceStore = useDeviceStore()
const themeStore = useThemeStore()
const locale = computed(() => {
const i18nLocale = i18n.global.locale.value
@@ -76,12 +75,10 @@ const locale = computed(() => {
const deviceInfo = ref({})
const deviceList = ref([])
const deviceName = computed(() => deviceStore.getLabel(deviceInfo.value, ({ deviceName }) => deviceName))
function handleClose() {
window.electron.ipcRenderer.send('hide-active-window')
window.electron.ipcRenderer.invoke('hide-control-window')
}
async function switchDevice(e) {

View File

@@ -29,4 +29,8 @@ export default (mainWindow) => {
onControlMounted(controlWindow)
})
})
ipcMain.handle('hide-control-window', () => {
controlWindow.hide()
})
}

View File

@@ -9,11 +9,17 @@ export default () => {
ipcMain.on('close-active-window', (event) => {
const win = BrowserWindow.getFocusedWindow()
win.close()
if (win) {
win.close()
}
})
ipcMain.on('hide-active-window', (event) => {
const win = BrowserWindow.getFocusedWindow()
win.hide()
if (win) {
win.hide()
}
})
}