diff --git a/electron/main/window/options.ts b/electron/main/window/options.ts index ac16fe618c1066b9edac2949a8d7d5f8a7c52029..f48f00eb770e125ad11b02c484435f7c8a5268aa 100644 --- a/electron/main/window/options.ts +++ b/electron/main/window/options.ts @@ -26,10 +26,28 @@ const getLinuxSpecificOptions = }; }; +// 调整Linux平台窗口尺寸,为16px阴影留出空间 +const adjustWindowSize = ( + options: Electron.BrowserWindowConstructorOptions, +): Electron.BrowserWindowConstructorOptions => { + if (!isLinux) return options; + + // 阴影在各个方向增加16px,所以宽高各需要增加32px + const shadowOffset = 32; // 16px * 2 + const result = { ...options }; + + if (result.width) result.width += shadowOffset; + if (result.height) result.height += shadowOffset; + if (result.minWidth) result.minWidth += shadowOffset; + if (result.minHeight) result.minHeight += shadowOffset; + + return result; +}; + export const options: allWindowType = { mainWindow: { id: 'mainWindow', - window: { + window: adjustWindowSize({ width: 1440, height: 810, minWidth: 1440, @@ -41,12 +59,12 @@ export const options: allWindowType = { useContentSize: true, icon: 'dist/favicon.ico', ...getLinuxSpecificOptions(), - }, + }), hash: '/', }, chatWindow: { id: 'chatWindow', - window: { + window: adjustWindowSize({ width: 680, height: 960, minWidth: 680, @@ -59,7 +77,7 @@ export const options: allWindowType = { titleBarStyle: 'hidden', icon: 'dist/favicon.ico', ...getLinuxSpecificOptions(), - }, + }), hash: '/chat', }, }; diff --git a/electron/preload/index.ts b/electron/preload/index.ts index a55456965e51330806267d9cec94527370e2c067..cbea3f1db0941e0466bf60282c433d048ba22456 100644 --- a/electron/preload/index.ts +++ b/electron/preload/index.ts @@ -9,6 +9,13 @@ import { ipcRenderer, contextBridge } from 'electron'; function validateIPC(channel: string): true | never { if (!channel || !channel.startsWith('copilot:')) { + // 允许窗口状态变化事件通过验证 + if ( + channel === 'window-maximized-change' || + channel === 'window-is-maximized' + ) { + return true; + } throw new Error(`Unsupported event IPC channel '${channel}'`); } @@ -19,9 +26,32 @@ const globals = { ipcRenderer: { invoke(channel: string, ...args: any[]): Promise { validateIPC(channel); - return ipcRenderer.invoke(channel, ...args); }, + + // 添加事件监听方法 + on(channel: string, listener: (...args: any[]) => void): void { + validateIPC(channel); + ipcRenderer.on(channel, (event, ...args) => listener(...args)); + }, + + // 添加一次性事件监听方法 + once(channel: string, listener: (...args: any[]) => void): void { + validateIPC(channel); + ipcRenderer.once(channel, (event, ...args) => listener(...args)); + }, + + // 添加移除特定事件监听器的方法 + removeListener(channel: string, listener: (...args: any[]) => void): void { + validateIPC(channel); + ipcRenderer.removeListener(channel, listener); + }, + + // 添加移除所有事件监听器的方法 + removeAllListeners(channel: string): void { + validateIPC(channel); + ipcRenderer.removeAllListeners(channel); + }, }, process: { diff --git a/src/App.vue b/src/App.vue index 6500ab760eb14fc11e3dcbc74e545232345fd2d7..c405064f429ea9469747f72f54b0e3c1ff2df3be 100644 --- a/src/App.vue +++ b/src/App.vue @@ -30,8 +30,8 @@ onMounted(() => { diff --git a/src/views/chat/Welcome.vue b/src/views/chat/Welcome.vue index db295741b6d8e34b08e967274ff327a900360f0f..a9a7f2e03b59c5616c3806ad1c433123913807ef 100644 --- a/src/views/chat/Welcome.vue +++ b/src/views/chat/Welcome.vue @@ -5,7 +5,7 @@ src="../../assets/svgs/euler_copilot_logo.svg" alt="euler_copilot_logo" /> -

EulerCopilot,很高兴为您服务

+

EulerCopilot 很高兴为您服务

我是你的智能问答助手,现在就可以向我提问啦!