|
@@ -1,5 +1,6 @@
|
|
|
-import { app, shell, BrowserWindow } from 'electron';
|
|
|
-import { join } from 'path';
|
|
|
+import { app, shell, BrowserWindow, protocol, net } from 'electron';
|
|
|
+import { join, resolve } from 'path';
|
|
|
+import url from 'url';
|
|
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils';
|
|
|
import icon from '../../resources/icon.png?asset';
|
|
|
import useElectron from './useElectron';
|
|
@@ -56,6 +57,14 @@ app.whenReady().then(() => {
|
|
|
|
|
|
createWindow();
|
|
|
|
|
|
+ // protocol
|
|
|
+ protocol.handle('local', (request) => {
|
|
|
+ const filePath = request.url.slice('local://'.length);
|
|
|
+ return net.fetch(
|
|
|
+ url.pathToFileURL(resolve(__dirname, filePath)).toString()
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
app.on('activate', () => {
|
|
|
// On macOS it's common to re-create a window in the app when the
|
|
|
// dock icon is clicked and there are no other windows open.
|