gamebrary/src/App.vue

131 lines
2.5 KiB
Vue
Raw Normal View History

2018-10-19 05:15:28 +00:00
<template>
2019-11-08 20:34:06 +00:00
<div
id="app"
:dir="dir"
2021-02-09 18:54:52 +00:00
v-shortkey="KEYBOARD_SHORTCUTS"
@shortkey="handleShortcutAction"
2019-11-08 20:34:06 +00:00
>
2021-02-22 01:20:33 +00:00
<dock v-if="user || isPublicRoute" />
2021-02-01 21:16:03 +00:00
<global-modals />
2020-10-31 17:44:15 +00:00
<main :class="{
'authorizing': !user,
2021-03-11 00:06:47 +00:00
'is-board': isBoard,
}"
>
2020-09-26 00:09:20 +00:00
<router-view />
</main>
2019-11-08 20:34:06 +00:00
</div>
2018-10-19 05:15:28 +00:00
</template>
<script>
2021-01-10 19:55:45 +00:00
import Dock from '@/components/Dock';
2021-02-01 21:16:03 +00:00
import GlobalModals from '@/components/GlobalModals';
2021-04-16 23:17:22 +00:00
import sessionMixin from '@/mixins/sessionMixin';
2018-11-05 02:28:29 +00:00
import firebase from 'firebase/app';
import { mapState } from 'vuex';
2021-02-18 19:40:53 +00:00
import { KEYBOARD_SHORTCUTS, FIREBASE_CONFIG } from '@/constants';
2021-02-18 19:40:53 +00:00
firebase.initializeApp(FIREBASE_CONFIG);
2018-10-19 05:15:28 +00:00
export default {
2019-11-08 19:56:03 +00:00
name: 'App',
2018-10-19 05:15:28 +00:00
2019-11-08 19:56:03 +00:00
components: {
2021-01-10 19:55:45 +00:00
Dock,
2021-02-01 21:16:03 +00:00
GlobalModals,
2019-11-08 19:56:03 +00:00
},
2021-04-16 23:17:22 +00:00
mixins: [sessionMixin],
2020-08-11 04:16:43 +00:00
data() {
return {
debugUserId: null,
2021-02-09 18:54:52 +00:00
KEYBOARD_SHORTCUTS,
2020-08-11 04:16:43 +00:00
};
},
2019-11-08 19:56:03 +00:00
computed: {
2021-02-27 03:01:11 +00:00
...mapState(['user', 'settings', 'sessionExpired']),
2018-11-21 02:43:10 +00:00
2020-08-11 04:16:43 +00:00
userId() {
return this.debugUserId || this.user.uid;
},
2019-11-08 19:56:03 +00:00
dir() {
2021-02-22 01:20:33 +00:00
const { settings } = this;
2021-02-22 01:20:33 +00:00
return settings && settings.language === 'ar' ? 'rtl' : 'ltr';
2019-11-08 19:56:03 +00:00
},
2020-10-05 18:42:28 +00:00
2021-02-22 01:20:33 +00:00
isPublicRoute() {
2020-10-05 18:42:28 +00:00
return this.$route.meta && this.$route.meta.public;
},
2020-11-18 05:55:35 +00:00
isBoard() {
2021-01-06 21:42:33 +00:00
return ['public-board', 'board'].includes(this.$route.name);
2020-11-18 05:55:35 +00:00
},
2019-11-08 19:56:03 +00:00
},
2021-04-16 23:17:22 +00:00
watch: {
sessionExpired(expired) {
if (expired) this.session_handleExpiredSession();
},
},
2020-10-15 23:15:09 +00:00
async mounted() {
await this.$store.dispatch('GET_TWITCH_TOKEN');
2019-11-08 19:56:03 +00:00
this.init();
},
methods: {
2021-02-09 18:54:52 +00:00
handleShortcutAction(data) {
this.$bus.$emit('HANDLE_SHORTCUT', data);
},
2019-11-08 19:56:03 +00:00
init() {
2021-02-22 01:20:33 +00:00
if (this.isPublicRoute) {
2020-10-05 18:42:28 +00:00
return;
}
2019-11-08 19:56:03 +00:00
if (this.user) {
this.load();
2021-04-07 00:02:50 +00:00
} else if (this.$route.name !== 'auth' && !this.$route.params.providerId) {
2020-09-28 23:27:08 +00:00
this.$router.replace({ name: 'auth' });
2019-11-08 19:56:03 +00:00
}
},
load() {
2021-03-03 23:14:57 +00:00
this.$store.dispatch('LOAD_RELEASES');
this.$store.dispatch('LOAD_WALLPAPERS');
this.$store.dispatch('SYNC_LOAD_SETTINGS');
this.$store.dispatch('SYNC_LOAD_TAGS');
this.$store.dispatch('SYNC_LOAD_NOTES');
this.$store.dispatch('SYNC_LOAD_PROGRESSES');
2019-11-08 19:56:03 +00:00
},
},
2018-10-19 05:15:28 +00:00
};
</script>
<style lang="scss" rel="stylesheet/scss">
2020-08-25 23:41:57 +00:00
@import "~styles/styles";
2018-10-19 05:15:28 +00:00
</style>
2019-02-15 22:58:32 +00:00
<style lang="scss" rel="stylesheet/scss" scoped>
2020-09-26 00:09:20 +00:00
main {
overflow-y: auto;
2021-03-11 00:06:47 +00:00
height: calc(100vh - 54px);
2020-09-28 23:27:08 +00:00
&.authorizing {
2021-04-07 00:02:50 +00:00
height: 100vh;
2020-09-28 23:27:08 +00:00
width: 100%;
left: 0;
}
2020-11-18 05:55:35 +00:00
2021-03-11 00:06:47 +00:00
&.is-board {
height: 100vh;
2020-11-18 05:55:35 +00:00
}
2019-11-08 20:34:06 +00:00
}
2019-02-15 22:58:32 +00:00
</style>