Stackedit/src/index.js

48 lines
1.2 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.');
}
2017-10-02 00:34:48 +00:00
if (NODE_ENV === 'production') {
OfflinePluginRuntime.install({
onUpdateReady: () => {
// Tells to new SW to take control immediately
OfflinePluginRuntime.applyUpdate();
},
onUpdated: () => {
2018-04-05 18:35:55 +00:00
if (!store.state.light) {
localDbSvc.sync()
.then(() => {
localStorage.updated = true;
// Reload the webpage to load into the new version
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),
});