-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
146 additions
and
184 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,49 @@ | ||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js'); | ||
|
||
const CACHE = 'cache-offline-page'; | ||
const offlineFallbackPage = 'offline.html'; | ||
|
||
self.addEventListener('message', (event) => { | ||
if (event.data && event.data.type === 'SKIP_WAITING') { | ||
self.skipWaiting(); | ||
} | ||
}); | ||
const CACHE_NAME = 'my-pwa-cache'; | ||
const urlsToCache = ['/', '/offline.html']; | ||
|
||
self.addEventListener('install', (event) => { | ||
event.waitUntil( | ||
caches | ||
.open(CACHE) | ||
.then((cache) => | ||
cache.addAll([ | ||
'https://amatta.site/', | ||
'./offline.html', | ||
'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x128.png', | ||
'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x192.png', | ||
'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x384.png', | ||
'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x512.png', | ||
]), | ||
), | ||
); | ||
event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(urlsToCache))); | ||
}); | ||
|
||
if (workbox.navigationPreload.isSupported()) { | ||
workbox.navigationPreload.enable(); | ||
} | ||
|
||
workbox.routing.registerRoute( | ||
new RegExp('/*'), | ||
new workbox.strategies.StaleWhileRevalidate({ | ||
cacheName: CACHE, | ||
}), | ||
); | ||
|
||
self.addEventListener('fetch', (event) => { | ||
if (event.request.mode === 'navigate') { | ||
event.respondWith( | ||
(async () => { | ||
try { | ||
const preloadResp = await event.preloadResponse; | ||
|
||
if (preloadResp) { | ||
return preloadResp; | ||
event.respondWith( | ||
caches | ||
.match(event.request) | ||
.then((response) => { | ||
if (response) { | ||
return response; | ||
} | ||
return fetch(event.request).then((response) => { | ||
if (response.status === 404) { | ||
return caches.match('/offline.html'); | ||
} | ||
const responseToCache = response.clone(); | ||
caches.open(CACHE_NAME).then((cache) => { | ||
cache.put(event.request, responseToCache); | ||
}); | ||
return response; | ||
}); | ||
}) | ||
.catch(() => { | ||
return caches.match('/offline.html'); | ||
}), | ||
); | ||
}); | ||
|
||
const networkResp = await fetch(event.request); | ||
return networkResp; | ||
} catch (error) { | ||
const cache = await caches.open(CACHE); | ||
const cachedResp = await cache.match(offlineFallbackPage); | ||
return cachedResp; | ||
} | ||
})(), | ||
); | ||
} | ||
self.addEventListener('beforeinstallprompt', (event) => { | ||
event.preventDefault(); | ||
const promptEvent = event; | ||
const installButton = document.createElement('button'); | ||
installButton.textContent = 'Add to Home Screen'; | ||
document.body.appendChild(installButton); | ||
installButton.addEventListener('click', () => { | ||
promptEvent.prompt(); | ||
promptEvent.userChoice.then((choiceResult) => { | ||
if (choiceResult.outcome === 'accepted') { | ||
console.log('User accepted the install prompt'); | ||
} else { | ||
console.log('User dismissed the install prompt'); | ||
} | ||
}); | ||
}); | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ const login = () => { | |
const submitData = async (e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
console.log('뭔데'); | ||
await loginU({ email: '[email protected]', password: 'testPassword' }); | ||
// await loginU(userData); | ||
|
||
|
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default as cardDetail } from './cardDetail'; | ||
export { default as searchCard } from './cardSearch'; |
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
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
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
Oops, something went wrong.