Change klippy window behavour, Fix user management behavour, clean up search server page

This commit is contained in:
2026-03-08 00:00:17 +01:00
parent 90f067e662
commit d20509566d
56 changed files with 1783 additions and 489 deletions

View File

@@ -4,7 +4,7 @@ import {
destroyDatabase,
getDataSource
} from '../db/database';
import { createWindow } from '../window/create-window';
import { createWindow, getDockIconPath } from '../window/create-window';
import {
setupCqrsHandlers,
setupSystemHandlers,
@@ -13,6 +13,11 @@ import {
export function registerAppLifecycle(): void {
app.whenReady().then(async () => {
const dockIconPath = getDockIconPath();
if (process.platform === 'darwin' && dockIconPath)
app.dock?.setIcon(dockIconPath);
await initializeDatabase();
setupCqrsHandlers();
setupWindowControlHandlers();

View File

@@ -12,5 +12,5 @@ export async function handleIsUserBanned(query: IsUserBannedQuery, dataSource: D
.andWhere('(ban.expiresAt IS NULL OR ban.expiresAt > :now)', { now })
.getMany();
return rows.some((row) => row.oderId === userId);
return rows.some((row) => row.userId === userId || (!row.userId && row.oderId === userId));
}

View File

@@ -1,13 +1,44 @@
import { BrowserWindow, shell } from 'electron';
import { app, BrowserWindow, shell } from 'electron';
import * as fs from 'fs';
import * as path from 'path';
let mainWindow: BrowserWindow | null = null;
function getAssetPath(...segments: string[]): string {
const basePath = app.isPackaged
? path.join(process.resourcesPath, 'images')
: path.join(__dirname, '..', '..', '..', 'images');
return path.join(basePath, ...segments);
}
function getExistingAssetPath(...segments: string[]): string | undefined {
const assetPath = getAssetPath(...segments);
return fs.existsSync(assetPath) ? assetPath : undefined;
}
function getWindowIconPath(): string | undefined {
if (process.platform === 'win32')
return getExistingAssetPath('windows', 'icon.ico');
if (process.platform === 'linux')
return getExistingAssetPath('icon.png');
return undefined;
}
export function getDockIconPath(): string | undefined {
return getExistingAssetPath('macos', '1024x1024.png');
}
export function getMainWindow(): BrowserWindow | null {
return mainWindow;
}
export async function createWindow(): Promise<void> {
const windowIconPath = getWindowIconPath();
mainWindow = new BrowserWindow({
width: 1400,
height: 900,
@@ -16,6 +47,7 @@ export async function createWindow(): Promise<void> {
frame: false,
titleBarStyle: 'hidden',
backgroundColor: '#0a0a0f',
...(windowIconPath ? { icon: windowIconPath } : {}),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,