Stackedit/src/index.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-07-23 18:42:08 +00:00
import Vue from 'vue';
import 'babel-polyfill';
import 'indexeddbshim/dist/indexeddbshim';
2017-09-26 22:54:26 +00:00
import * as OfflinePluginRuntime from 'offline-plugin/runtime';
2017-07-23 18:42:08 +00:00
import './extensions/';
import './services/optional';
import './icons/';
2017-08-06 00:58:39 +00:00
import App from './components/App';
import store from './store';
import localDbSvc from './services/localDbSvc';
2017-07-23 18:42:08 +00:00
if (!indexedDB) {
throw new Error('Your browser is not supported. Please upgrade to the latest version.');
}
2018-05-06 00:46:33 +00:00
OfflinePluginRuntime.install({
onUpdateReady: () => {
// Tells to new SW to take control immediately
OfflinePluginRuntime.applyUpdate();
},
onUpdated: () => {
if (!store.state.light) {
localDbSvc.sync()
.then(() => {
localStorage.updated = true;
// Reload the webpage to load into the new version
window.location.reload();
});
}
},
});
if (localStorage.updated) {
store.dispatch('notification/info', 'StackEdit has just updated itself!');
setTimeout(() => localStorage.removeItem('updated'), 2000);
2017-09-26 22:54:26 +00:00
}
2017-07-23 18:42:08 +00:00
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
el: '#app',
store,
render: h => h(App),
});