完善客户端模块与工作区能力
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-13 19:45:30 +08:00
parent 0148b91a15
commit 22add3f01f
97 changed files with 4756 additions and 3226 deletions

View File

@@ -0,0 +1,29 @@
import { timingSafeEqual } from 'node:crypto';
const ADMIN_PASSWORD = 'zhiniankeji666';
let adminSessionUnlocked = false;
function matchesAdminPassword(password: unknown): boolean {
if (typeof password !== 'string') return false;
const received = Buffer.from(password, 'utf8');
const expected = Buffer.from(ADMIN_PASSWORD, 'utf8');
return received.length === expected.length && timingSafeEqual(received, expected);
}
export function verifyAdminPassword(password: unknown): boolean {
const valid = matchesAdminPassword(password);
if (valid) {
adminSessionUnlocked = true;
}
return valid;
}
export function isAdminSessionUnlocked(): boolean {
return adminSessionUnlocked;
}
export function lockAdminSession(): void {
adminSessionUnlocked = false;
}

View File

@@ -258,7 +258,11 @@ function createWindow(): BrowserWindow {
sandbox: false,
webviewTag: false,
},
titleBarStyle: isMac ? 'hiddenInset' : useCustomTitleBar ? 'hidden' : 'default',
// `hiddenInset` leaves a native top inset in the renderer viewport. That
// makes a full-height Canvas look like it has an extra horizontal bar and
// clips the top of the columns. `hidden` keeps the traffic lights while
// giving the renderer the full window bounds.
titleBarStyle: isMac ? 'hidden' : useCustomTitleBar ? 'hidden' : 'default',
// Keep the native traffic lights on the same centerline as the 40px
// renderer title bar. The native glyphs sit about 7px below the
// configured origin, so y=13 centers them on the renderer controls.

View File

@@ -13,6 +13,11 @@ import { getProviderService } from '../services/providers/provider-service';
import type { ProviderConfig } from '../utils/secure-storage';
import type { ProviderAccount } from '../shared/providers/types';
import { validateApiKeyWithProvider } from '../services/providers/provider-validation';
import {
isAdminSessionUnlocked,
lockAdminSession,
verifyAdminPassword,
} from './admin-access';
type UnifiedRequest = {
id?: string;
@@ -282,6 +287,15 @@ export function registerIpcHandlers(
return { success: true, settings: await getAllSettings() };
});
ipcMain.handle('admin:verifyPassword', (_event, password: unknown) => ({
success: verifyAdminPassword(password),
}));
ipcMain.handle('admin:isUnlocked', () => isAdminSessionUnlocked());
ipcMain.handle('admin:lock', () => {
lockAdminSession();
return { success: true };
});
ipcMain.handle('shell:openExternal', (_event, url: string) => shell.openExternal(url));
ipcMain.handle('shell:showItemInFolder', (_event, path: string) => shell.showItemInFolder(path));
ipcMain.handle('shell:openPath', (_event, path: string) => shell.openPath(path));