Update favicon and add PWA
This commit is contained in:
17
src-pwa/.eslintrc.js
Normal file
17
src-pwa/.eslintrc.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const { resolve } = require('path');
|
||||
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
project: resolve(__dirname, './tsconfig.json'),
|
||||
},
|
||||
|
||||
overrides: [
|
||||
{
|
||||
files: ['custom-service-worker.ts'],
|
||||
|
||||
env: {
|
||||
serviceworker: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
35
src-pwa/custom-service-worker.ts
Normal file
35
src-pwa/custom-service-worker.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file (which will be your service worker)
|
||||
* is picked up by the build system ONLY if
|
||||
* quasar.config.js > pwa > workboxMode is set to "injectManifest"
|
||||
*/
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope &
|
||||
typeof globalThis & { skipWaiting: () => void };
|
||||
|
||||
import { clientsClaim } from 'workbox-core';
|
||||
import {
|
||||
precacheAndRoute,
|
||||
cleanupOutdatedCaches,
|
||||
createHandlerBoundToURL,
|
||||
} from 'workbox-precaching';
|
||||
import { registerRoute, NavigationRoute } from 'workbox-routing';
|
||||
|
||||
self.skipWaiting();
|
||||
clientsClaim();
|
||||
|
||||
// Use with precache injection
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
cleanupOutdatedCaches();
|
||||
|
||||
// Non-SSR fallback to index.html
|
||||
// Production SSR fallback to offline.html (except for dev)
|
||||
if (process.env.MODE !== 'ssr' || process.env.PROD) {
|
||||
registerRoute(
|
||||
new NavigationRoute(
|
||||
createHandlerBoundToURL(process.env.PWA_FALLBACK_HTML),
|
||||
{ denylist: [/sw\.js$/, /workbox-(.)*\.js$/] }
|
||||
)
|
||||
);
|
||||
}
|
||||
32
src-pwa/manifest.json
Normal file
32
src-pwa/manifest.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"background_color": "#ffffff",
|
||||
"theme_color": "#027be3",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
8
src-pwa/pwa-env.d.ts
vendored
Normal file
8
src-pwa/pwa-env.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
SERVICE_WORKER_FILE: string;
|
||||
PWA_FALLBACK_HTML: string;
|
||||
}
|
||||
}
|
||||
10
src-pwa/pwa-flag.d.ts
vendored
Normal file
10
src-pwa/pwa-flag.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable */
|
||||
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
|
||||
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
|
||||
import "quasar/dist/types/feature-flag";
|
||||
|
||||
declare module "quasar/dist/types/feature-flag" {
|
||||
interface QuasarFeatureFlags {
|
||||
pwa: true;
|
||||
}
|
||||
}
|
||||
41
src-pwa/register-service-worker.ts
Normal file
41
src-pwa/register-service-worker.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { register } from 'register-service-worker';
|
||||
|
||||
// The ready(), registered(), cached(), updatefound() and updated()
|
||||
// events passes a ServiceWorkerRegistration instance in their arguments.
|
||||
// ServiceWorkerRegistration: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
||||
|
||||
register(process.env.SERVICE_WORKER_FILE, {
|
||||
// The registrationOptions object will be passed as the second argument
|
||||
// to ServiceWorkerContainer.register()
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#Parameter
|
||||
|
||||
// registrationOptions: { scope: './' },
|
||||
|
||||
ready (/* registration */) {
|
||||
// console.log('Service worker is active.')
|
||||
},
|
||||
|
||||
registered (/* registration */) {
|
||||
// console.log('Service worker has been registered.')
|
||||
},
|
||||
|
||||
cached (/* registration */) {
|
||||
// console.log('Content has been cached for offline use.')
|
||||
},
|
||||
|
||||
updatefound (/* registration */) {
|
||||
// console.log('New content is downloading.')
|
||||
},
|
||||
|
||||
updated (/* registration */) {
|
||||
// console.log('New content is available; please refresh.')
|
||||
},
|
||||
|
||||
offline () {
|
||||
// console.log('No internet connection found. App is running in offline mode.')
|
||||
},
|
||||
|
||||
error (/* err */) {
|
||||
// console.error('Error during service worker registration:', err)
|
||||
},
|
||||
});
|
||||
7
src-pwa/tsconfig.json
Normal file
7
src-pwa/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["WebWorker", "ESNext"]
|
||||
},
|
||||
"include": ["*.ts", "*.d.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user