Stackedit/src/components/App.vue

67 lines
1.6 KiB
Vue
Raw Normal View History

2017-07-23 18:42:08 +00:00
<template>
2018-04-08 14:49:10 +00:00
<div class="app" :class="classes">
2017-12-10 23:49:20 +00:00
<splash-screen v-if="!ready"></splash-screen>
<layout v-else></layout>
2018-06-07 23:56:11 +00:00
<modal></modal>
2017-09-23 19:01:50 +00:00
<notification></notification>
2018-03-09 21:18:20 +00:00
<context-menu></context-menu>
2017-07-23 18:42:08 +00:00
</div>
</template>
<script>
2018-05-06 00:46:33 +00:00
import '../styles';
import '../styles/markdownHighlighting.scss';
import '../styles/app.scss';
2017-07-23 18:42:08 +00:00
import Layout from './Layout';
import Modal from './Modal';
2017-09-23 19:01:50 +00:00
import Notification from './Notification';
2018-03-09 21:18:20 +00:00
import ContextMenu from './ContextMenu';
2017-10-02 00:34:48 +00:00
import SplashScreen from './SplashScreen';
2017-12-10 23:49:20 +00:00
import syncSvc from '../services/syncSvc';
2017-12-11 00:53:46 +00:00
import networkSvc from '../services/networkSvc';
import sponsorSvc from '../services/sponsorSvc';
2018-03-15 13:51:39 +00:00
import tempFileSvc from '../services/tempFileSvc';
2018-09-19 08:59:22 +00:00
import store from '../store';
import './common/vueGlobals';
2017-11-15 08:12:56 +00:00
2018-01-10 21:45:34 +00:00
const themeClasses = {
light: ['app--light'],
dark: ['app--dark'],
};
2017-07-23 18:42:08 +00:00
export default {
components: {
Layout,
Modal,
2017-09-23 19:01:50 +00:00
Notification,
2018-03-09 21:18:20 +00:00
ContextMenu,
2017-10-02 00:34:48 +00:00
SplashScreen,
2017-07-23 18:42:08 +00:00
},
2017-12-10 23:49:20 +00:00
data: () => ({
ready: false,
}),
2017-07-28 07:40:24 +00:00
computed: {
2018-04-08 14:49:10 +00:00
classes() {
2018-09-19 08:59:22 +00:00
const result = themeClasses[store.getters['data/computedSettings'].colorTheme];
2018-01-10 21:45:34 +00:00
return Array.isArray(result) ? result : themeClasses.light;
},
2017-07-28 07:40:24 +00:00
},
2018-05-13 13:27:33 +00:00
async created() {
try {
await syncSvc.init();
await networkSvc.init();
await sponsorSvc.init();
this.ready = true;
tempFileSvc.setReady();
} catch (err) {
2018-08-17 10:13:08 +00:00
if (err && err.message === 'RELOAD') {
window.location.reload();
} else if (err && err.message !== 'RELOAD') {
2018-05-13 13:27:33 +00:00
console.error(err); // eslint-disable-line no-console
2018-09-19 08:59:22 +00:00
store.dispatch('notification/error', err);
2018-05-13 13:27:33 +00:00
}
}
2017-12-10 23:49:20 +00:00
},
2017-07-23 18:42:08 +00:00
};
</script>