feat: adding local file protocol

This commit is contained in:
Chubby Granny Chaser 2024-06-19 09:48:11 +01:00
parent 1ef8e3fce3
commit 1fb1c9e81a
No known key found for this signature in database
10 changed files with 42 additions and 54 deletions

View file

@ -2,6 +2,7 @@ import { app, BrowserWindow, net, protocol } from "electron";
import updater from "electron-updater";
import i18n from "i18next";
import path from "node:path";
import url from "node:url";
import { electronApp, optimizer } from "@electron-toolkit/utils";
import { DownloadManager, logger, WindowManager } from "@main/services";
import { dataSource } from "@main/data-source";
@ -51,9 +52,10 @@ if (process.defaultApp) {
app.whenReady().then(async () => {
electronApp.setAppUserModelId("site.hydralauncher.hydra");
protocol.handle("hydra", (request) =>
net.fetch("file://" + request.url.slice("hydra://".length))
);
protocol.handle("local", (request) => {
const filePath = request.url.slice("local://".length);
return net.fetch(url.pathToFileURL(filePath).toString());
});
await dataSource.initialize();
await dataSource.runMigrations();