Feature(custom): add ipc event handlers for mini window icon and set on top

This commit is contained in:
Kuingsmile 2024-05-26 20:25:27 +08:00
parent 3587bc5225
commit 892a1471b5
3 changed files with 17 additions and 4 deletions

View File

@ -325,6 +325,16 @@ export default {
settingWindow.hide() settingWindow.hide()
}) })
ipcMain.on('updateMiniIcon', (_: IpcMainEvent, iconPath: string) => {
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
miniWindow.webContents.send('updateMiniIcon', iconPath)
})
ipcMain.on('miniWindowOntop', (_: IpcMainEvent, val: boolean) => {
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
miniWindow.setAlwaysOnTop(val)
})
ipcMain.on('refreshSettingWindow', () => { ipcMain.on('refreshSettingWindow', () => {
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)! const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
settingWindow.webContents.reloadIgnoringCache() settingWindow.webContents.reloadIgnoringCache()

View File

@ -88,7 +88,7 @@ async function initLogoPath () {
onBeforeMount(async () => { onBeforeMount(async () => {
os.value = process.platform os.value = process.platform
await initLogoPath() await initLogoPath()
ipcRenderer.on('uploadProgress', (event: IpcRendererEvent, _progress: number) => { ipcRenderer.on('uploadProgress', (_: IpcRendererEvent, _progress: number) => {
if (_progress !== -1) { if (_progress !== -1) {
showProgress.value = true showProgress.value = true
progress.value = _progress progress.value = _progress
@ -97,6 +97,9 @@ onBeforeMount(async () => {
showError.value = true showError.value = true
} }
}) })
ipcRenderer.on('updateMiniIcon', async () => {
await initLogoPath()
})
window.addEventListener('mousedown', handleMouseDown, false) window.addEventListener('mousedown', handleMouseDown, false)
window.addEventListener('mousemove', handleMouseMove, false) window.addEventListener('mousemove', handleMouseMove, false)
window.addEventListener('mouseup', handleMouseUp, false) window.addEventListener('mouseup', handleMouseUp, false)
@ -215,6 +218,7 @@ function openContextMenu () {
onBeforeUnmount(() => { onBeforeUnmount(() => {
ipcRenderer.removeAllListeners('uploadProgress') ipcRenderer.removeAllListeners('uploadProgress')
ipcRenderer.removeAllListeners('updateMiniIcon')
window.removeEventListener('mousedown', handleMouseDown, false) window.removeEventListener('mousedown', handleMouseDown, false)
window.removeEventListener('mousemove', handleMouseMove, false) window.removeEventListener('mousemove', handleMouseMove, false)
window.removeEventListener('mouseup', handleMouseUp, false) window.removeEventListener('mouseup', handleMouseUp, false)

View File

@ -2478,7 +2478,7 @@ function handleAutoCloseMiniWindowChange (val: ICheckBoxValueType) {
function handleMiniWindowOntop (val: ICheckBoxValueType) { function handleMiniWindowOntop (val: ICheckBoxValueType) {
saveConfig(configPaths.settings.miniWindowOntop, val) saveConfig(configPaths.settings.miniWindowOntop, val)
$message.info($T('TIPS_NEED_RELOAD')) ipcRenderer.send('miniWindowOntop', val)
} }
async function handleMiniIconPath (_: Event) { async function handleMiniIconPath (_: Event) {
@ -2486,13 +2486,12 @@ async function handleMiniIconPath (_: Event) {
if (result && result[0]) { if (result && result[0]) {
form.customMiniIcon = result[0] form.customMiniIcon = result[0]
saveConfig(configPaths.settings.customMiniIcon, form.customMiniIcon) saveConfig(configPaths.settings.customMiniIcon, form.customMiniIcon)
$message.info($T('TIPS_NEED_RELOAD')) ipcRenderer.send('updateMiniIcon', form.customMiniIcon)
} }
} }
function handleIsCustomMiniIcon (val: ICheckBoxValueType) { function handleIsCustomMiniIcon (val: ICheckBoxValueType) {
saveConfig(configPaths.settings.isCustomMiniIcon, val) saveConfig(configPaths.settings.isCustomMiniIcon, val)
$message.info($T('TIPS_NEED_RELOAD'))
} }
function handleAutoCopyUrl (val: ICheckBoxValueType) { function handleAutoCopyUrl (val: ICheckBoxValueType) {