[🐛] Fixed UV issue
This commit is contained in:
parent
4a9aad5005
commit
293a84af8e
4 changed files with 13 additions and 21 deletions
|
|
@ -1,12 +1,8 @@
|
||||||
importScripts('/uv/uv.sw.js');
|
importScripts('/uv/uv.sw.js');
|
||||||
|
|
||||||
const params = new URLSearchParams(self.serviceWorker.scriptURL)
|
const params = new URL(self.serviceWorker.scriptURL).searchParams
|
||||||
|
|
||||||
var cfg = JSON.parse(params.get('config'));
|
|
||||||
const sw = new UVServiceWorker(cfg);
|
|
||||||
|
|
||||||
self.addEventListener('fetch', event =>
|
|
||||||
event.respondWith(sw.fetch(event))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
const serverURL = atob(params.get('url'));
|
||||||
|
const sw = new UVServiceWorker(serverURL);
|
||||||
|
|
||||||
|
self.addEventListener('fetch', event => event.respondWith(sw.fetch(event)));
|
||||||
|
|
@ -2,9 +2,9 @@ importScripts('/uv/uv.bundle.js');
|
||||||
importScripts('/uv/uv.config.js');
|
importScripts('/uv/uv.config.js');
|
||||||
|
|
||||||
class UVServiceWorker extends EventEmitter {
|
class UVServiceWorker extends EventEmitter {
|
||||||
constructor(flowURL, config = __uv$config) {
|
constructor(serverURL, config = __uv$config) {
|
||||||
super();
|
super();
|
||||||
config.bare = flowURL + '/bare/';
|
config.bare = serverURL + '/bare/';
|
||||||
this.addresses = typeof config.bare === 'string' ? [ new URL(config.bare, location) ] : config.bare.map(str => new URL(str, location));
|
this.addresses = typeof config.bare === 'string' ? [ new URL(config.bare, location) ] : config.bare.map(str => new URL(str, location));
|
||||||
this.headers = {
|
this.headers = {
|
||||||
csp: [
|
csp: [
|
||||||
|
|
|
||||||
|
|
@ -82,15 +82,7 @@ export default class SettingsApp implements App {
|
||||||
win.content.querySelector('.save')?.addEventListener('click', () => {
|
win.content.querySelector('.save')?.addEventListener('click', () => {
|
||||||
(config as any)[key] = input.value
|
(config as any)[key] = input.value
|
||||||
|
|
||||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
window.location.reload()
|
||||||
for (const registration of registrations) {
|
|
||||||
registration.unregister().then(() => {
|
|
||||||
navigator.serviceWorker.register('/uv-sw.js?config=' + encodeURIComponent(config.SERVER_URL), {
|
|
||||||
scope: '/service/'
|
|
||||||
}).catch(e => console.error(e))
|
|
||||||
}).catch(e => console.error(e))
|
|
||||||
}
|
|
||||||
}).catch(e => console.error(e))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,13 @@ window.wm = new WindowManager();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.serviceWorker.register('/uv-sw.js?config=' + encodeURIComponent((await window.config()).SERVER_URL), {
|
const registrations = await navigator.serviceWorker.getRegistrations()
|
||||||
|
for (const registration of registrations) {
|
||||||
|
await registration.unregister()
|
||||||
|
}
|
||||||
|
await navigator.serviceWorker.register('/uv-sw.js?url=' + encodeURIComponent(btoa((await window.config()).SERVER_URL)), {
|
||||||
scope: '/service/'
|
scope: '/service/'
|
||||||
}).catch(e => console.error(e))
|
})
|
||||||
|
|
||||||
await window.preloader.setDone('filesystem')
|
await window.preloader.setDone('filesystem')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue