Stackedit/src/index.js

40 lines
995 B
JavaScript
Raw Normal View History

2017-07-23 18:42:08 +00:00
import Vue from 'vue';
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
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: () => {
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),
});