From d768c8d08c2acbba7a02c9a3a4cf49f01c6d1e98 Mon Sep 17 00:00:00 2001 From: H3CoF6 <1707889225@qq.com> Date: Thu, 9 Apr 2026 15:22:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4wayland=E7=9A=84?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=92=8C=E8=AD=A6=E5=91=8A=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- electron/main.ts | 7 ---- electron/preload.ts | 1 - src/App.tsx | 65 -------------------------------------- src/pages/SettingsPage.tsx | 22 ------------- src/types/electron.d.ts | 1 - 5 files changed, 96 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 8cb84e2..a3c0cf0 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1693,13 +1693,6 @@ function registerIpcHandlers() { return applyLaunchAtStartupPreference(enabled === true) }) - ipcMain.handle('app:checkWayland', async () => { - if (process.platform !== 'linux') return false; - - const sessionType = process.env.XDG_SESSION_TYPE?.toLowerCase(); - return Boolean(process.env.WAYLAND_DISPLAY || sessionType === 'wayland'); - }) - ipcMain.handle('log:getPath', async () => { return join(app.getPath('userData'), 'logs', 'wcdb.log') }) diff --git a/electron/preload.ts b/electron/preload.ts index d13f938..48564f1 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -71,7 +71,6 @@ contextBridge.exposeInMainWorld('electronAPI', { ipcRenderer.on('app:updateAvailable', (_, info) => callback(info)) return () => ipcRenderer.removeAllListeners('app:updateAvailable') }, - checkWayland: () => ipcRenderer.invoke('app:checkWayland'), }, // 日志 diff --git a/src/App.tsx b/src/App.tsx index 2ccf779..c9c574b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -107,44 +107,6 @@ function App() { const [showAnalyticsConsent, setShowAnalyticsConsent] = useState(false) const [analyticsConsent, setAnalyticsConsent] = useState(null) - const [showWaylandWarning, setShowWaylandWarning] = useState(false) - - useEffect(() => { - const checkWaylandStatus = async () => { - try { - // 防止在非客户端环境报错,先检查 API 是否存在 - if (!window.electronAPI?.app?.checkWayland) return - - // 通过 configService 检查是否已经弹过窗 - const hasWarned = await window.electronAPI.config.get('waylandWarningShown') - - if (!hasWarned) { - const isWayland = await window.electronAPI.app.checkWayland() - if (isWayland) { - setShowWaylandWarning(true) - } - } - } catch (e) { - console.error('检查 Wayland 状态失败:', e) - } - } - - // 只有在协议同意之后并且已经进入主应用流程才检查 - if (!isAgreementWindow && !isOnboardingWindow && !agreementLoading) { - checkWaylandStatus() - } - }, [isAgreementWindow, isOnboardingWindow, agreementLoading]) - - const handleDismissWaylandWarning = async () => { - try { - // 记录到本地配置中,下次不再提示 - await window.electronAPI.config.set('waylandWarningShown', true) - } catch (e) { - console.error('保存 Wayland 提示状态失败:', e) - } - setShowWaylandWarning(false) - } - useEffect(() => { if (location.pathname !== '/settings') { settingsBackgroundRef.current = location @@ -685,33 +647,6 @@ function App() { )} - {/*{showWaylandWarning && (*/} - {/*
*/} - {/*
*/} - {/*
*/} - {/* */} - {/*

环境兼容性提示 (Wayland)

*/} - {/*
*/} - {/*
*/} - {/*
*/} - {/*

检测到您当前正在使用 Wayland 显示服务器。

*/} - {/*

在 Wayland 环境下,出于系统级的安全与设计机制,应用程序无法直接控制新弹出窗口的位置

*/} - {/*

这可能导致某些独立窗口(如消息通知、图片查看器等)出现位置随机、或不受控制的情况。这是底层机制导致的,对此我们无能为力。

*/} - {/*
*/} - {/*

如果您觉得窗口位置异常严重影响了使用体验,建议尝试:

*/} - {/*

1. 在系统登录界面,将会话切换回 X11 (Xorg) 模式。

*/} - {/*

2. 修改您的桌面管理器 (WM/DE) 配置,强制指定该应用程序的窗口规则。

*/} - {/*
*/} - {/*
*/} - {/*
*/} - {/*
*/} - {/* */} - {/*
*/} - {/*
*/} - {/*
*/} - {/*
*/} - {/*)}*/} - {/* 更新提示对话框 */} { - const checkWaylandStatus = async () => { - if (window.electronAPI?.app?.checkWayland) { - try { - const wayland = await window.electronAPI.app.checkWayland() - setIsWayland(wayland) - } catch (e) { - console.error('检查 Wayland 状态失败:', e) - } - } - } - checkWaylandStatus() - }, []) - - - // 检查 Hello 可用性 useEffect(() => { setHelloAvailable(isWindows) @@ -1696,11 +1679,6 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
选择通知弹窗在屏幕上的显示位置 - {isWayland && ( - - ⚠️ 注意:Wayland 环境下该配置可能无效! - - )}
Promise<{ success: boolean }> onDownloadProgress: (callback: (progress: number) => void) => () => void onUpdateAvailable: (callback: (info: { version: string; releaseNotes: string }) => void) => () => void - checkWayland: () => Promise } notification: { show: (data: { title: string; content: string; avatarUrl?: string; sessionId: string }) => Promise<{ success?: boolean; error?: string } | void>