Files
WT-Offline/apps/launcher/src/main/services/main-window.ts
T
N0VAN0M4LY 81c900a61d feat(launcher): redesign the main launcher window
The window is now a fixed 1120x720 frameless window with its own title
bar: page navigation, language, minimize and close. The layout follows
the game's launcher: a side panel, the main area over the background,
and a bottom bar with the state of the current task and the primary
action. The colours and type follow the game's website: dark blue-grey,
red actions, Roboto Condensed (bundled, OFL), cyan progress.

- Pages: home (requirements before installation, the current copy
  after), copies (copy details with folders to open, feature status
  grouped by inventory section), settings (language), about.
- The install wizard is a hook shared by the side panel (step list),
  the main area (current step) and the bottom bar (back, next, install,
  cancel, copy progress).
- The adaptation shown for a game version is the version itself when
  the patches were verified on it, otherwise the nearest verified one.
- Both language packs are rewritten in consistent product wording.
- New IPC: app:openFolder, install:listFeatures (patcher's new
  patchFeatures), window:minimize, window:close; app:getInfo reports the
  supported game versions.

Launching is not built yet; its button stays disabled.

Checked: launcher typecheck (main and renderer), electron-vite build,
root typecheck. Ran the window from a scratch user data folder over the
remote debugging port: every page and section in Chinese and English,
empty and installed state, the wizard's first step, both new IPC calls,
no console errors and no overflow.
2026-11-29 07:39:12 +08:00

59 lines
1.9 KiB
TypeScript

import { join } from 'node:path';
import { BrowserWindow, shell } from 'electron';
/**
* The launcher's single window: a fixed size without the system frame, like the game's own
* launcher. The window draws its title bar and asks for minimize and close over IPC.
*/
/** The layout is drawn for exactly this content size. */
const CONTENT_WIDTH = 1120;
const CONTENT_HEIGHT = 720;
/** The window background before the page paints (--bg in the window's styles). */
const BACKGROUND = '#13191b';
let mainWindow: BrowserWindow | null = null;
export function createMainWindow(): BrowserWindow {
const window = new BrowserWindow({
width: CONTENT_WIDTH,
height: CONTENT_HEIGHT,
useContentSize: true,
resizable: false,
maximizable: false,
fullscreenable: false,
frame: false,
backgroundColor: BACKGROUND,
show: false,
webPreferences: {
preload: join(import.meta.dirname, '../preload/index.cjs'),
sandbox: true,
contextIsolation: true,
nodeIntegration: false,
},
});
window.once('ready-to-show', () => window.show());
// Links leave the launcher for the player's browser; the window itself never navigates away.
window.webContents.setWindowOpenHandler(({ url }) => {
if (/^https?:\/\//.test(url)) void shell.openExternal(url);
return { action: 'deny' };
});
window.webContents.on('will-navigate', (event) => event.preventDefault());
window.on('closed', () => {
if (mainWindow === window) mainWindow = null;
});
const devServer = process.env['ELECTRON_RENDERER_URL'];
if (devServer) void window.loadURL(devServer);
else void window.loadFile(join(import.meta.dirname, '../renderer/index.html'));
mainWindow = window;
return window;
}
/** Brings the window forward, building it again if it was closed. */
export function showMainWindow(): void {
const window = mainWindow ?? createMainWindow();
if (window.isMinimized()) window.restore();
window.focus();
}