Change klippy window behavour, Fix user management behavour, clean up search server page
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user