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:
parent
ac35f81476
commit
9023d76d48
5 changed files with 8044 additions and 6 deletions
8010
package-lock.json
generated
Normal file
8010
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import "./ipc";
|
import "./ipc";
|
||||||
|
|
||||||
import { app, BrowserWindow, nativeTheme } from "electron";
|
import { app, BrowserWindow, nativeTheme, net, protocol } from "electron";
|
||||||
import { checkUpdates } from "updater/main";
|
import { checkUpdates } from "updater/main";
|
||||||
|
|
||||||
import { DATA_DIR } from "./constants";
|
import { DATA_DIR } from "./constants";
|
||||||
|
@ -25,7 +25,7 @@ if (IS_DEV) {
|
||||||
process.env.VENCORD_USER_DATA_DIR = DATA_DIR;
|
process.env.VENCORD_USER_DATA_DIR = DATA_DIR;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
const { disableSmoothScroll, hardwareAcceleration } = Settings.store;
|
const { disableSmoothScroll, hardwareAcceleration, splashAnimationPath } = Settings.store;
|
||||||
|
|
||||||
const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(",");
|
const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(",");
|
||||||
const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(",");
|
const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(",");
|
||||||
|
@ -74,6 +74,10 @@ function init() {
|
||||||
|
|
||||||
registerScreenShareHandler();
|
registerScreenShareHandler();
|
||||||
registerMediaPermissionsHandler();
|
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();
|
bootstrap();
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,17 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
||||||
return dir;
|
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.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
|
||||||
|
|
||||||
handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
|
handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BrowserWindow } from "electron";
|
import { BrowserWindow, webContents } from "electron";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { SplashProps } from "shared/browserWinProperties";
|
import { SplashProps } from "shared/browserWinProperties";
|
||||||
import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
||||||
|
@ -12,6 +12,8 @@ import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings";
|
||||||
|
|
||||||
export function createSplashWindow(startMinimized = false) {
|
export function createSplashWindow(startMinimized = false) {
|
||||||
|
const { splashBackground, splashColor, splashTheming, splashAnimationPath } = Settings.store;
|
||||||
|
|
||||||
const splash = new BrowserWindow({
|
const splash = new BrowserWindow({
|
||||||
...SplashProps,
|
...SplashProps,
|
||||||
icon: ICON_PATH,
|
icon: ICON_PATH,
|
||||||
|
@ -20,8 +22,6 @@ export function createSplashWindow(startMinimized = false) {
|
||||||
|
|
||||||
splash.loadFile(join(VIEW_DIR, "splash.html"));
|
splash.loadFile(join(VIEW_DIR, "splash.html"));
|
||||||
|
|
||||||
const { splashBackground, splashColor, splashTheming } = Settings.store;
|
|
||||||
|
|
||||||
if (splashTheming) {
|
if (splashTheming) {
|
||||||
if (splashColor) {
|
if (splashColor) {
|
||||||
const semiTransparentSplashColor = splashColor.replace("rgb(", "rgba(").replace(")", ", 0.2)");
|
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;
|
return splash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ export const VesktopNative = {
|
||||||
},
|
},
|
||||||
fileManager: {
|
fileManager: {
|
||||||
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
|
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: {
|
settings: {
|
||||||
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
||||||
|
|
Reference in a new issue