Skip to content

Commit 7b798ef

Browse files
committed
Prompt before update
1 parent 36dab3b commit 7b798ef

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

frontend/src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import PasswordDialog from '@/components/PasswordDialog.vue'
1616
import FileServerView from "@/components/FileServerView.vue";
1717
import {useGlobalStatus} from "@/composables/useGlobalStatus.js";
1818
import {useService} from "@/composables/useService.js";
19+
import ReloadPrompt from "@/components/ReloadPrompt.vue";
1920
2021
const passwordDialog = ref()
2122
@@ -222,6 +223,7 @@ const handleFileUpload = async (file) => {
222223
</v-snackbar>
223224

224225
<PasswordDialog ref="passwordDialog" />
226+
<ReloadPrompt />
225227

226228
</v-main>
227229
</v-app>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<v-snackbar
3+
v-model="needRefresh"
4+
:timeout="-1"
5+
color="info"
6+
vertical
7+
>
8+
{{ i18n.global.t('New version is available') }}
9+
10+
<template v-slot:actions>
11+
<v-btn variant="text" @click="updateServiceWorker()">{{ i18n.global.t('Update') }}</v-btn>
12+
<v-btn variant="text" @click="close">{{ i18n.global.t('Close') }}</v-btn>
13+
</template>
14+
</v-snackbar>
15+
</template>
16+
17+
<script setup>
18+
import { useRegisterSW } from 'virtual:pwa-register/vue'
19+
import i18n from "@/i18n/index.js";
20+
21+
const {
22+
needRefresh,
23+
updateServiceWorker,
24+
} = useRegisterSW()
25+
26+
const close = () => {
27+
needRefresh.value = false
28+
}
29+
</script>

frontend/vite.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineConfig(({ mode }) => {
2828
plugins: [
2929
vue(),
3030
VitePWA({
31-
registerType: 'autoUpdate',
31+
registerType: 'prompt',
3232
manifest: {
3333
id: env.VITE_BASE_PATH || '/OpenNumismatWeb/',
3434
name: 'OpenNumismat Web',
@@ -44,6 +44,7 @@ export default defineConfig(({ mode }) => {
4444
},
4545
workbox: {
4646
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,wasm}'],
47+
cleanupOutdatedCaches: true,
4748
}
4849
}),
4950
viteStaticCopy({

0 commit comments

Comments
 (0)