Vesktop/src/main/splash.ts

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-04-09 22:49:50 +02:00
/*
* SPDX-License-Identifier: GPL-3.0
2023-07-13 19:03:13 +02:00
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
2023-04-09 22:49:50 +02:00
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
2023-03-30 01:02:30 +02:00
import { BrowserWindow } from "electron";
import { join } from "path";
2023-04-10 22:53:44 +02:00
import { SplashProps } from "shared/browserWinProperties";
import { ICON_PATH, VIEW_DIR } from "shared/paths";
2023-03-30 01:02:30 +02:00
import { Settings } from "./settings";
2023-03-30 01:02:30 +02:00
export function createSplashWindow() {
const splash = new BrowserWindow({
...SplashProps,
icon: ICON_PATH
});
2023-03-30 01:02:30 +02:00
2023-06-23 17:20:54 +02:00
splash.loadFile(join(VIEW_DIR, "splash.html"));
2023-03-30 01:02:30 +02:00
const { splashBackground, splashColor, splashTheming } = Settings.store;
if (splashTheming) {
if (splashColor) {
const semiTransparentSplashColor = splashColor.replace("rgb(", "rgba(").replace(")", ", 0.2)");
splash.webContents.insertCSS(`body { --fg: ${splashColor} !important }`);
splash.webContents.insertCSS(`body { --fg-semi-trans: ${semiTransparentSplashColor} !important }`);
}
if (splashBackground) {
splash.webContents.insertCSS(`body { --bg: ${splashBackground} !important }`);
}
}
2023-03-30 01:02:30 +02:00
return splash;
}