mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-17 00:12:28 -04:00
Make Electron app work with pwabuilder
Former-commit-id: d3ddcf4b7e75db8bbba6b2d7f6917b01e066f3e1 [formerly dc1e971e68f1b682bbceb494d70bd6b3e771ee2b] [formerly 42142309a5bb263848ae3500ac9655a743a9821a [formerly b2cd0e46617655422abdcbcce83f1921bb7af1f4]] Former-commit-id: bdee798fc30446b0248248579c0686f1cc1a3907 [formerly 403a4424c4d62b0f179a31872ed2638dad66c50d] Former-commit-id: ef10d2de4ecd92c4383c5cf36194f3c42c69e312
This commit is contained in:
parent
54a2fd8cdd
commit
f051e470c1
19
main.js
19
main.js
@ -8,15 +8,15 @@ const {
|
||||
const path = require('path');
|
||||
|
||||
// This is used to set capabilities of the app: protocol in onready event below
|
||||
protocol.registerSchemesAsPrivileged([{
|
||||
scheme: 'app',
|
||||
privileges: {
|
||||
standard: true,
|
||||
secure: true,
|
||||
allowServiceWorkers: true,
|
||||
supportFetchAPI: true
|
||||
}
|
||||
}]);
|
||||
// protocol.registerSchemesAsPrivileged([{
|
||||
// scheme: 'app',
|
||||
// privileges: {
|
||||
// standard: true,
|
||||
// secure: true,
|
||||
// allowServiceWorkers: true,
|
||||
// supportFetchAPI: true
|
||||
// }
|
||||
// }]);
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
@ -45,6 +45,7 @@ function createWindow() {
|
||||
|
||||
// and load the index.html of the app.
|
||||
// mainWindow.loadURL(`https://${__dirname}/www/index.html`);
|
||||
// mainWindow.loadURL(`https://kiwix.github.io/kiwix-js-windows/`);
|
||||
// DEV: If you need Service Worker more than you need document.cookie, load app like this:
|
||||
mainWindow.loadFile('www/index.html');
|
||||
|
||||
|
@ -135,7 +135,7 @@ self.addEventListener('fetch', intercept);
|
||||
|
||||
// Look up fetch in cache, and if it does not exist, try to get it from the network
|
||||
function intercept(event) {
|
||||
if (excludedURLSchema.test(event.request.url) && !(/\.zim\w{0,2}\//i.test(event.request.url) || regexpZIMUrlWithNamespace.test(event.request.url))) return;
|
||||
if (excludedURLSchema.test(event.request.url) && !(/\.zim\w{0,2}\//i.test(event.request.url) && regexpZIMUrlWithNamespace.test(event.request.url))) return;
|
||||
console.log('[SW] Service Worker ' + (event.request.method === "GET" ? 'intercepted ' : 'noted ') + event.request.url, event.request.method);
|
||||
if (event.request.method !== "GET") return;
|
||||
event.respondWith(
|
||||
|
@ -2112,7 +2112,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
||||
// For Electron, we need to set an absolute filepath in case the file was launched from a shortcut (and if it's not already absolute)
|
||||
// DEV: Periodically check Electron hasn't changed its resources folder; NB the ! in indexOf below indicates position at start of string
|
||||
if (!filepath.indexOf(params.archivePath) && /^file:/.test(window.location.protocol)) {
|
||||
filepath = window.location.pathname.replace(/^\//, '').replace(/resources\/app\/www\/[^/]+$/, '') + filepath;
|
||||
filepath = window.location.pathname.replace(/^\//, '').replace(/(resources\/app\/)?www\/[^/]+$/, '') + filepath;
|
||||
}
|
||||
file.name = filename;
|
||||
file.path = filepath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user