Changes to be committed:

new file:   package-lock.json
	modified:   src/main/index.ts
	modified:   src/main/ipc.ts
	modified:   src/main/splash.ts
	modified:   src/preload/VesktopNative.ts
This commit is contained in:
Sammie Zhang 2024-05-06 00:58:56 -07:00
parent ac35f81476
commit 9023d76d48
5 changed files with 8044 additions and 6 deletions

8010
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@
import "./ipc";
import { app, BrowserWindow, nativeTheme } from "electron";
import { app, BrowserWindow, nativeTheme, net, protocol } from "electron";
import { checkUpdates } from "updater/main";
import { DATA_DIR } from "./constants";
@ -25,7 +25,7 @@ if (IS_DEV) {
process.env.VENCORD_USER_DATA_DIR = DATA_DIR;
function init() {
const { disableSmoothScroll, hardwareAcceleration } = Settings.store;
const { disableSmoothScroll, hardwareAcceleration, splashAnimationPath } = Settings.store;
const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(",");
const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(",");
@ -74,6 +74,10 @@ function init() {
registerScreenShareHandler();
registerMediaPermissionsHandler();
//register file handler so we can load the custom splash animation from the user's filesystem
protocol.handle("splash-animation", () => {
return net.fetch("file:///"+splashAnimationPath);
});
bootstrap();

View file

@ -121,6 +121,17 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
return dir;
});
handle(IpcEvents.SELECT_IMAGE_PATH, async () => {
const res = await dialog.showOpenDialog(mainWin!, {
properties: ["openFile"],
filters: [
{name: "Images", extensions: ["apng", "avif", "gif", "jpeg", "png", "svg", "webp"]}
]
});
if (!res.filePaths.length) return "cancelled";
return res.filePaths[0];
});
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {

View file

@ -4,7 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { BrowserWindow } from "electron";
import { BrowserWindow, webContents } from "electron";
import { join } from "path";
import { SplashProps } from "shared/browserWinProperties";
import { ICON_PATH, VIEW_DIR } from "shared/paths";
@ -12,6 +12,8 @@ import { ICON_PATH, VIEW_DIR } from "shared/paths";
import { Settings } from "./settings";
export function createSplashWindow(startMinimized = false) {
const { splashBackground, splashColor, splashTheming, splashAnimationPath } = Settings.store;
const splash = new BrowserWindow({
...SplashProps,
icon: ICON_PATH,
@ -20,8 +22,6 @@ export function createSplashWindow(startMinimized = false) {
splash.loadFile(join(VIEW_DIR, "splash.html"));
const { splashBackground, splashColor, splashTheming } = Settings.store;
if (splashTheming) {
if (splashColor) {
const semiTransparentSplashColor = splashColor.replace("rgb(", "rgba(").replace(")", ", 0.2)");
@ -35,5 +35,17 @@ export function createSplashWindow(startMinimized = false) {
}
}
if (splashAnimationPath) {
splash.webContents.executeJavaScript(`
document.getElementById("animation").src = "splash-animation://img";
`);
}
else {
splash.webContents.insertCSS(`img {image-rendering: pixelated}`)
splash.webContents.executeJavaScript(`
document.getElementById("animation").src = "../shiggy.gif";
`);
}
return splash;
}

View file

@ -33,7 +33,8 @@ export const VesktopNative = {
},
fileManager: {
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR)
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR),
selectImagePath: () => invoke<LiteralUnion<"cancelled", string>>(IpcEvents.SELECT_IMAGE_PATH)
},
settings: {
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),