|
1 | 1 | import { app, protocol } from "electron";
|
2 | 2 | import { APP_SCHEME } from "./background-constants";
|
| 3 | +// import { getMediaManager } from "./media-manager"; |
3 | 4 | import { openFile } from "./open-file";
|
4 | 5 | import { createWindow } from "./windows";
|
5 | 6 |
|
@@ -39,10 +40,33 @@ app.on("activate", async () => {
|
39 | 40 | createWindow("mainWindow");
|
40 | 41 | });
|
41 | 42 |
|
| 43 | +// https://stackoverflow.com/a/66673831 |
| 44 | +function fileHandler(req, callback) { |
| 45 | + // const { mediaDirectoryPath } = getMediaManager(); |
| 46 | + const requestedPath = req.url; |
| 47 | + // Write some code to resolve path, calculate absolute path etc |
| 48 | + const check = true; // requestedPath.indexOf(mediaDirectoryPath) > -1; |
| 49 | + |
| 50 | + if (!check) { |
| 51 | + callback({ |
| 52 | + // -6 is FILE_NOT_FOUND |
| 53 | + // https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h |
| 54 | + error: -6 |
| 55 | + }); |
| 56 | + return; |
| 57 | + } |
| 58 | + |
| 59 | + callback({ |
| 60 | + path: requestedPath |
| 61 | + }); |
| 62 | +} |
| 63 | + |
42 | 64 | // This method will be called when Electron has finished
|
43 | 65 | // initialization and is ready to create browser windows.
|
44 | 66 | // Some APIs can only be used after this event occurs.
|
45 | 67 | app.on("ready", async () => {
|
| 68 | + protocol.registerFileProtocol("modv", fileHandler); |
| 69 | + |
46 | 70 | app.commandLine.appendSwitch(
|
47 | 71 | "disable-backgrounding-occluded-windows",
|
48 | 72 | "true"
|
|
0 commit comments