Fix PWA support.

This commit is contained in:
FireMasterK 2021-12-28 14:59:58 +00:00
parent 4bfbb9aa2e
commit 179dcbb687
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
4 changed files with 1990 additions and 388 deletions

View file

@ -17,7 +17,6 @@
"hotkeys-js": "^3.8.7", "hotkeys-js": "^3.8.7",
"javascript-time-ago": "^2.3.10", "javascript-time-ago": "^2.3.10",
"mux.js": "^6.0.1", "mux.js": "^6.0.1",
"register-service-worker": "^1.7.1",
"shaka-player": "3.3.0", "shaka-player": "3.3.0",
"uikit": "3.9.4", "uikit": "3.9.4",
"vue": "^3.2.26", "vue": "^3.2.26",
@ -35,6 +34,7 @@
"eslint-plugin-vue": "^7.20.0", "eslint-plugin-vue": "^7.20.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"vite": "^2.7.8", "vite": "^2.7.8",
"vite-plugin-pwa": "^0.11.12",
"vite-plugin-windicss": "^1.6.1" "vite-plugin-windicss": "^1.6.1"
}, },
"eslintConfig": { "eslintConfig": {

View file

@ -1,33 +1,7 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { register } from "register-service-worker"; import { registerSW } from "virtual:pwa-register";
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
register(`/service-worker.js`, { registerSW();
ready() {
console.log(
"App is being served from cache by a service worker.\n" +
"For more details, visit https://goo.gl/AFskqB",
);
},
registered() {
console.log("Service worker has been registered.");
},
cached() {
console.log("Content has been cached for offline use.");
},
updatefound() {
console.log("New content is downloading.");
},
updated() {
console.log("New content is available; please refresh.");
window.location.reload();
},
offline() {
console.log("No internet connection found. App is running in offline mode.");
},
error(error) {
console.error("Error during service worker registration:", error);
},
});
} }

View file

@ -2,6 +2,7 @@ import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
import WindiCSS from "vite-plugin-windicss"; import WindiCSS from "vite-plugin-windicss";
import vueI18n from "@intlify/vite-plugin-vue-i18n"; import vueI18n from "@intlify/vite-plugin-vue-i18n";
import { VitePWA } from "vite-plugin-pwa";
import path from "path"; import path from "path";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
@ -12,6 +13,7 @@ export default defineConfig({
vueI18n({ vueI18n({
include: path.resolve(__dirname, "./src/locales/**"), include: path.resolve(__dirname, "./src/locales/**"),
}), }),
VitePWA({ registerType: "autoUpdate" }),
], ],
resolve: { resolve: {
alias: { alias: {

2344
yarn.lock

File diff suppressed because it is too large Load diff