This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document | |
.querySelector('.cache-article') | |
.addEventListener('click', (event) => { | |
event.preventDefault() | |
const id = this.dataset.articleId | |
caches | |
.open('mysite-article-' + id) | |
.then((cache) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('fetch', event => { | |
console.log('[Service Worker] - fetch event') | |
event.respondWith( | |
self | |
.caches | |
.match(event.request) | |
.then(result => { | |
if (result == null) { | |
return fetch(event.request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator | |
.serviceWorker | |
.register('/sw.js', { | |
scope: '/app' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const APP_ASSETS_CACHE_NAME = `app-assets-cache-v0.0.1` | |
self.addEventListener('install', event => { | |
console.log('[Service Worker] - install event') | |
event.waitUntil( | |
self | |
.caches | |
.open(APP_ASSETS_CACHE_NAME) | |
.then(cache => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css', | |
'https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js', | |
'https://unpkg.com/[email protected]/dist/vue-router.js', | |
'https://code.jquery.com/jquery-3.2.1.slim.min.js', | |
'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', | |
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', | |
'/app.js', | |
'/manifest.json', | |
'/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('serviceWorker' in navigator) { | |
navigator | |
.serviceWorker | |
.register('/sw.js') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="theme-color" content="#FFFFFF"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="manifest" href="/manifest.json"> | |
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="theme-color" content="#FFFFFF"> | |
<!-- Manifest JSON File --> | |
<link rel="manifest" href="/manifest.json"> | |
<!-- Manifest JSON File --> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"short_name": "order drink", | |
"name": "好想訂飲料", | |
"description": "好想訂飲料 - 快找大家訂飲料吧!", | |
"theme_color": "#FFFFFF", | |
"background_color": "#FFFFFF", | |
"display": "standalone", | |
"orientation": "portrait", | |
"icons": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = (new Array(5000)).fill(1) | |
task = array.map(item => { | |
return fetch('http://localhost:5000/diandian-landing-payment/us-central1/api/test') | |
}) | |
duplicated = [] | |
Promise | |
.all(task) | |
.then(result => result.map(item => item.json())) |