在PWA(离线)中启动WebGL
我正在开发PWA(具有非常基本的香草JS),即使用户离线也是如此,也尝试在其中进行Unity WebGL启动。 我已经将所有文件都放在缓存上,但仍然不起作用。 我是这个野生动物,所以我对此表示感谢。 这是我的服务工人文件的内容:
const cacheName = "static"
const appFiles = [
"./",
"xmlhttprequest-length-computable.min.js?v=1.5.1.22060315",
"images/favicon.ico",
"images/icon.png",
"style.css",
"responsiveMinimalTemplateStyles.css",
"responsiveMinimalTemplateLoader.js",
"manifest.json",
"Build/WebGL.loader.js",
"Build/WebGL.framework.js",
"Build/WebGL.data",
"Build/WebGL.wasm"
]
self.addEventListener("install", e => {
console.log('Install')
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll(appFiles)
})
)
})
self.addEventListener("fetch", e => {
e.respondWith(
caches.match(e.request).then(response => {
return response || fetch(e.request)
})
)
})
有什么想法吗?
I am working on a PWA (with very basic vanilla JS) and i try to make a unity webGL launch in it even when the user is offline.
I have put all of my files on cache but it still does not work.
I'm a begginer in this so i'll be very thankfull for any help on this.
Here is the content of my service-worker file :
const cacheName = "static"
const appFiles = [
"./",
"xmlhttprequest-length-computable.min.js?v=1.5.1.22060315",
"images/favicon.ico",
"images/icon.png",
"style.css",
"responsiveMinimalTemplateStyles.css",
"responsiveMinimalTemplateLoader.js",
"manifest.json",
"Build/WebGL.loader.js",
"Build/WebGL.framework.js",
"Build/WebGL.data",
"Build/WebGL.wasm"
]
self.addEventListener("install", e => {
console.log('Install')
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll(appFiles)
})
)
})
self.addEventListener("fetch", e => {
e.respondWith(
caches.match(e.request).then(response => {
return response || fetch(e.request)
})
)
})
Any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我是新手,所以如果可以帮助任何人,我会在这里回答自己。
终于在这里找到了我的答案(当然必须将其适应我自己的代码):
渐进式网络应用程序(在Promise)typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:typeerror:提取
必须完成我的self.addeventlistener(“ fetch”,请求:
Ok i'm new to this so i'll be answering myself here, if it can help anybody another time.
Finally found my answer here (and of course had to adapt it to my own code) :
Progressive web app Uncaught (in promise) TypeError: Failed to fetch
Had to complete my self.addEventListener("fetch", request :