mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-23 08:16:16 -04:00
revert(pwa): fallback to autoUpdate
This commit is contained in:
parent
400654b6b1
commit
ad202bd372
5 changed files with 2 additions and 89 deletions
|
@ -1,52 +0,0 @@
|
|||
/* eslint-disable vue/one-component-per-file */
|
||||
import { useRegisterSW } from 'virtual:pwa-register/vue';
|
||||
import { useNotification, type NotificationReactive } from 'naive-ui';
|
||||
import { defineComponent } from 'vue';
|
||||
import { whenever } from '@vueuse/core';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const notificationBuilder = useNotification();
|
||||
|
||||
const { needRefresh, offlineReady, updateServiceWorker } = useRegisterSW();
|
||||
|
||||
let notification: NotificationReactive | null = null;
|
||||
|
||||
const onUpdateClicked = () => {
|
||||
if (notification) {
|
||||
notification.action = () => (
|
||||
<n-button loading type="primary" secondary>
|
||||
Reloading
|
||||
</n-button>
|
||||
);
|
||||
}
|
||||
|
||||
updateServiceWorker();
|
||||
};
|
||||
|
||||
whenever(
|
||||
needRefresh,
|
||||
() => {
|
||||
notification = notificationBuilder.create({
|
||||
title: 'A new version is out!',
|
||||
content: 'Update to get the latest version of it-tools',
|
||||
closable: true,
|
||||
onClose: () => {
|
||||
needRefresh.value = false;
|
||||
return true;
|
||||
},
|
||||
action: () => (
|
||||
<n-button onClick={onUpdateClicked} type="primary" secondary>
|
||||
Reload
|
||||
</n-button>
|
||||
),
|
||||
});
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
whenever(offlineReady, () => notification?.destroy(), { immediate: true });
|
||||
|
||||
return () => '';
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue