feat(desktop-client): suppress native menu bar on Windows/Linux and support phone number login
- Add suppressNativeWindowMenu() to hide native menu bar on all windows (Win/Linux only) - Set autoHideMenuBar: true on BrowserWindow creation as belt-and-suspenders - Import Menu from electron/main to support menu suppression - Login form: rename field from email to identifier, support phone number input - Migrate saved credential key from geo_rankly_saved_email to geo_rankly_saved_identifier with fallback - Update login error message: "邮箱或密码错误" → "账号或密码错误" - Remove unset ELECTRON_RUN_AS_NODE from dev script (not needed on Windows) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { shell } from "electron";
|
||||
import { BrowserWindow, app, ipcMain, nativeTheme } from "electron/main";
|
||||
import { BrowserWindow, Menu, app, ipcMain, nativeTheme } from "electron/main";
|
||||
import type {
|
||||
BrowserWindow as ElectronBrowserWindow,
|
||||
IpcMainInvokeEvent,
|
||||
@@ -132,6 +132,15 @@ const SETTINGS_WINDOW_SIZE: WindowSizePreset = {
|
||||
resizable: true,
|
||||
};
|
||||
|
||||
function suppressNativeWindowMenu(window?: ElectronBrowserWindow): void {
|
||||
if (process.platform === "darwin") {
|
||||
return;
|
||||
}
|
||||
Menu.setApplicationMenu(null);
|
||||
window?.setMenu(null);
|
||||
window?.setMenuBarVisibility(false);
|
||||
}
|
||||
|
||||
function windowModePath(): string {
|
||||
return join(app.getPath("userData"), "window-mode.json");
|
||||
}
|
||||
@@ -463,6 +472,7 @@ async function createAppWindow(mode: WindowMode): Promise<ElectronBrowserWindow>
|
||||
resizable: initial.resizable,
|
||||
maximizable: initial.resizable,
|
||||
fullscreenable: initial.resizable,
|
||||
autoHideMenuBar: true,
|
||||
backgroundColor: mode === "login" ? "#eaf2ff" : nativeTheme.shouldUseDarkColors ? "#15191a" : "#f0f2f5",
|
||||
webPreferences: {
|
||||
preload: preloadPath(),
|
||||
@@ -472,6 +482,7 @@ async function createAppWindow(mode: WindowMode): Promise<ElectronBrowserWindow>
|
||||
},
|
||||
});
|
||||
appWindowModes.set(window, mode);
|
||||
suppressNativeWindowMenu(window);
|
||||
|
||||
if (!initial.resizable) {
|
||||
window.setMinimumSize(initial.minWidth, initial.minHeight);
|
||||
@@ -548,6 +559,7 @@ async function createSettingsWindow(): Promise<ElectronBrowserWindow> {
|
||||
},
|
||||
});
|
||||
appWindowModes.set(window, "settings");
|
||||
suppressNativeWindowMenu(window);
|
||||
|
||||
window.once("closed", () => {
|
||||
if (settingsWindow === window) {
|
||||
@@ -703,6 +715,7 @@ if (!hasSingleInstanceLock) {
|
||||
app.exit(0);
|
||||
} else {
|
||||
app.whenReady().then(async () => {
|
||||
suppressNativeWindowMenu();
|
||||
currentWindowMode = readPersistedWindowMode();
|
||||
initDesktopAppSettings();
|
||||
registerBridgeHandlers();
|
||||
|
||||
Reference in New Issue
Block a user