|
|
@@ -51,9 +51,7 @@ function createWindow() {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- // Load the index.html from memory using a data URL
|
|
|
- // const indexHtmlContent = memoryCache[indexRelativePath].toString();
|
|
|
- // win.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(indexHtmlContent));
|
|
|
+ // Load the index.html from disk
|
|
|
win.loadFile('index.html');
|
|
|
|
|
|
// 打开调试工具
|
|
|
@@ -80,13 +78,15 @@ function createWindow() {
|
|
|
|
|
|
// 设置应用程序的菜单
|
|
|
Menu.setApplicationMenu(menu);
|
|
|
+ console.log(Object.keys(memoryCache))
|
|
|
}
|
|
|
|
|
|
app.on('ready', () => {
|
|
|
// Intercept file requests and serve from memory
|
|
|
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
|
|
|
- const url = details.url.substr(7); // Remove 'file://' prefix
|
|
|
- const relativePath = path.relative(process.resourcesPath, url).replace(/\\/g, '/');
|
|
|
+ const url = new URL(details.url);
|
|
|
+ const filePath = path.normalize(decodeURIComponent(url.pathname));
|
|
|
+ const relativePath = filePath.replace(path.normalize(process.resourcesPath), '').replace(/\\/g, '/').replace('//', '');
|
|
|
console.log(`Intercepting request for: ${relativePath}`);
|
|
|
|
|
|
if (memoryCache[relativePath]) {
|