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>
|
2017-08-03 17:08:12 +00:00
|
|
|
<modal v-if="showModal"></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>
|
2017-09-17 15:32:39 +00:00
|
|
|
import Vue from 'vue';
|
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';
|
2017-08-03 17:08:12 +00:00
|
|
|
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';
|
2017-11-15 08:12:56 +00:00
|
|
|
import timeSvc from '../services/timeSvc';
|
|
|
|
import store from '../store';
|
2017-07-23 18:42:08 +00:00
|
|
|
|
2017-09-17 15:32:39 +00:00
|
|
|
// Global directives
|
|
|
|
Vue.directive('focus', {
|
|
|
|
inserted(el) {
|
|
|
|
el.focus();
|
2018-05-06 00:46:33 +00:00
|
|
|
const { value } = el;
|
2017-11-26 20:58:24 +00:00
|
|
|
if (value && el.setSelectionRange) {
|
|
|
|
el.setSelectionRange(0, value.length);
|
|
|
|
}
|
2017-09-17 15:32:39 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-10-07 11:22:24 +00:00
|
|
|
const setVisible = (el, value) => {
|
|
|
|
el.style.display = value ? '' : 'none';
|
|
|
|
if (value) {
|
|
|
|
el.removeAttribute('aria-hidden');
|
|
|
|
} else {
|
|
|
|
el.setAttribute('aria-hidden', 'true');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Vue.directive('show', {
|
|
|
|
bind(el, { value }) {
|
|
|
|
setVisible(el, value);
|
|
|
|
},
|
|
|
|
update(el, { value, oldValue }) {
|
|
|
|
if (value !== oldValue) {
|
|
|
|
setVisible(el, value);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Vue.directive('title', {
|
|
|
|
bind(el, { value }) {
|
|
|
|
el.title = value;
|
|
|
|
el.setAttribute('aria-label', value);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-11-15 08:12:56 +00:00
|
|
|
// Global filters
|
|
|
|
Vue.filter('formatTime', time =>
|
|
|
|
// Access the minute counter for reactive refresh
|
|
|
|
timeSvc.format(time, store.state.minuteCounter));
|
|
|
|
|
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,
|
2017-08-03 17:08:12 +00:00
|
|
|
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-01-10 21:45:34 +00:00
|
|
|
const result = themeClasses[this.$store.getters['data/computedSettings'].colorTheme];
|
|
|
|
return Array.isArray(result) ? result : themeClasses.light;
|
|
|
|
},
|
2017-08-03 17:08:12 +00:00
|
|
|
showModal() {
|
2017-09-23 19:01:50 +00:00
|
|
|
return !!this.$store.getters['modal/config'];
|
2017-08-03 17:08:12 +00:00
|
|
|
},
|
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) {
|
|
|
|
if (err && err.message !== 'reload') {
|
|
|
|
console.error(err); // eslint-disable-line no-console
|
|
|
|
this.$store.dispatch('notification/error', err);
|
|
|
|
}
|
|
|
|
}
|
2017-12-10 23:49:20 +00:00
|
|
|
},
|
2017-07-23 18:42:08 +00:00
|
|
|
};
|
|
|
|
</script>
|