This commit is contained in:
2020-08-22 18:31:48 +02:00
parent 7750829b39
commit ab4fc8e18a
7 changed files with 535 additions and 49 deletions

View File

@@ -1,33 +1,15 @@
import OfflinePluginRuntime from 'offline-plugin/runtime';
import { notification } from 'antd';
import React from 'react';
import 'antd/dist/antd.css';
import { render } from 'react-dom';
import App from './App';
if (!__DEV__) {
OfflinePluginRuntime.install({
onUpdating: () => {
console.log('SW Event:', 'onUpdating');
},
onUpdateReady: () => {
console.log('SW Event:', 'onUpdateReady');
OfflinePluginRuntime.applyUpdate();
},
onUpdated: () => {
notification.success({
message: 'Your app has been updated',
});
},
onUpdateFailed: () => {
notification.warn({
message: 'Could not update to the latest version',
});
console.log('SW Event:', 'onUpdateFailed');
}
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js');
});
}
const root = document.createElement('div');
root.style.height = '100%';
document.body.appendChild(root);