|
|
@@ -33,14 +33,10 @@ function decryptDirectory(directoryPath) {
|
|
|
}
|
|
|
|
|
|
function createWindow() {
|
|
|
+ console.log('2')
|
|
|
const directoryToDecrypt = path.join(process.resourcesPath, 'app.asar', 'static');
|
|
|
decryptDirectory(directoryToDecrypt);
|
|
|
|
|
|
- // Load index.html into memory
|
|
|
- const indexPath = path.join(process.resourcesPath, 'app.asar', 'index.html');
|
|
|
- const indexRelativePath = path.relative(process.resourcesPath, indexPath).replace(/\\/g, '/');
|
|
|
- memoryCache[indexRelativePath] = fs.readFileSync(indexPath);
|
|
|
-
|
|
|
const win = new BrowserWindow({
|
|
|
width: 1600,
|
|
|
height: 900,
|
|
|
@@ -82,6 +78,7 @@ function createWindow() {
|
|
|
}
|
|
|
|
|
|
app.on('ready', () => {
|
|
|
+ console.log('1')
|
|
|
// Intercept file requests and serve from memory
|
|
|
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
|
|
|
const url = new URL(details.url);
|
|
|
@@ -89,7 +86,12 @@ app.on('ready', () => {
|
|
|
const relativePath = filePath.replace(path.normalize(process.resourcesPath), '').replace(/\\/g, '/').replace('//', '');
|
|
|
|
|
|
if (memoryCache[relativePath]) {
|
|
|
- console.log(`Intercepting request for: ${relativePath}`);
|
|
|
+ const tempFilePath = path.join(app.getPath('temp'), relativePath);
|
|
|
+ fs.mkdirSync(path.dirname(tempFilePath), { recursive: true });
|
|
|
+ fs.writeFileSync(tempFilePath, memoryCache[relativePath]);
|
|
|
+
|
|
|
+ console.log(`Intercepting request for: ${relativePath}, redirectURL: ${tempFilePath}`);
|
|
|
+
|
|
|
let mimeType = 'text/plain';
|
|
|
if (relativePath.endsWith('.js')) {
|
|
|
mimeType = 'application/javascript';
|
|
|
@@ -99,7 +101,7 @@ app.on('ready', () => {
|
|
|
mimeType = 'text/html';
|
|
|
}
|
|
|
console.log(`Serving from memory: ${relativePath} as ${mimeType}`);
|
|
|
- callback({ mimeType: mimeType, data: memoryCache[relativePath] });
|
|
|
+ callback({ cancel: false, redirectURL: tempFilePath });
|
|
|
} else {
|
|
|
callback({ cancel: false });
|
|
|
}
|