mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-08 10:12:44 -08:00
fix: serving static images
https://github.com/electron-userland/electron-forge/issues/1592
This commit is contained in:
parent
61f075697c
commit
bb515c7be6
1 changed files with 9 additions and 4 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -1,5 +1,5 @@
|
|||
import 'reflect-metadata';
|
||||
import fs from 'fs';
|
||||
import fs from 'fs-extra';
|
||||
import { ipcMain, protocol, session, powerMonitor, app } from 'electron';
|
||||
import isDev from 'electron-is-dev';
|
||||
import settings from 'electron-settings';
|
||||
|
|
@ -28,6 +28,7 @@ import { IWikiService } from './services/wiki/interface';
|
|||
import { IWindowService } from './services/windows/interface';
|
||||
import { IWorkspaceService } from './services/workspaces/interface';
|
||||
import { IWorkspaceViewService } from './services/workspacesView/interface';
|
||||
import path from 'path';
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
|
|
@ -101,10 +102,14 @@ if (!gotTheLock) {
|
|||
// eslint-disable-next-line promise/catch-or-return
|
||||
await app.whenReady();
|
||||
if (isDev) {
|
||||
protocol.registerFileProtocol('file', (request, callback) => {
|
||||
// TODO: this might be useless after use electron-forge, this is for loading html file after bundle, forge handle this now
|
||||
protocol.registerFileProtocol('file', async (request, callback) => {
|
||||
const pathname = decodeURIComponent(request.url.replace('file:///', ''));
|
||||
callback(pathname);
|
||||
if (path.isAbsolute(pathname) ? await fs.pathExists(pathname) : await fs.pathExists(`/${pathname}`)) {
|
||||
callback(pathname);
|
||||
} else {
|
||||
const filePath = path.join(app.getAppPath(), '.webpack/renderer', pathname);
|
||||
callback(filePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
await windowService.open(WindowNames.main);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue