pwa: automatyczny reload

This commit is contained in:
2023-01-03 01:29:15 +01:00
parent 6a10b1e191
commit 242be73c78
4 changed files with 19 additions and 6 deletions
+3 -1
View File
@@ -69,7 +69,9 @@ export default defineComponent({
}),
async created() {
const stockData = await (await fetch(`https://spythere.github.io/api/stockDataNew.json?t=${Math.floor(Date.now() / 60000)}`)).json();
const stockData = await (
await fetch(`https://spythere.github.io/api/stockDataNew.json?t=${Math.floor(Date.now() / 60000)}`)
).json();
this.store.stockData = stockData;
},
+11 -3
View File
@@ -1,10 +1,18 @@
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { registerSW } from 'virtual:pwa-register';
import App from './App.vue';
const pinia = createPinia();
createApp(App)
.use(pinia)
.mount('#app');
const updateSW = registerSW({
onOfflineReady() {},
onNeedRefresh() {
console.log('Need refresh!');
},
});
createApp(App).use(pinia).mount('#app');