Эх сурвалжийг харах

拦截成功的版本。但是无法触发加载。

skyffire 1 жил өмнө
parent
commit
1ea19db375
1 өөрчлөгдсөн 1 нэмэгдсэн , 2 устгасан
  1. 1 2
      example/electron.js

+ 1 - 2
example/electron.js

@@ -87,9 +87,9 @@ app.on('ready', () => {
     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]) {
+      console.log(`Intercepting request for: ${relativePath}`);
       let mimeType = 'text/plain';
       if (relativePath.endsWith('.js')) {
         mimeType = 'application/javascript';
@@ -101,7 +101,6 @@ app.on('ready', () => {
       console.log(`Serving from memory: ${relativePath} as ${mimeType}`);
       callback({ mimeType: mimeType, data: memoryCache[relativePath] });
     } else {
-      console.error(`File not found in memory: ${relativePath}`);
       callback({ cancel: false });
     }
   });