Files
mixtape/zero.Backoffice.UI/old_app/app.vue
T

116 lines
2.5 KiB
Vue
Raw Normal View History

2020-03-23 20:05:02 +01:00
<template>
<div class="app" :class="getClassList()" :key="appKey">
2020-04-09 11:48:34 +02:00
<template v-if="isAuthenticated">
2021-08-25 10:57:04 +02:00
<!--<app-bar />-->
2020-10-15 14:10:38 +02:00
<app-navigation />
2020-04-09 11:48:34 +02:00
<div class="app-main">
<router-view></router-view>
</div>
2021-09-03 09:40:36 +02:00
<!--<app-search />-->
2020-10-15 14:10:38 +02:00
<app-overlays />
<app-notifications />
2020-04-09 11:48:34 +02:00
</template>
2020-10-15 14:10:38 +02:00
<app-login v-else />
2020-03-23 20:05:02 +01:00
</div>
</template>
<script>
2021-08-25 10:12:48 +02:00
import '../sass/sass.js'
2021-08-26 20:42:25 +02:00
import AppNavigation from './navigation.vue'
2021-08-25 10:38:13 +02:00
import AppBar from 'zero/bar.vue'
2021-09-01 23:09:22 +02:00
import AppSearch from 'zero/search.vue'
2020-10-15 14:10:38 +02:00
import AppLogin from 'zero/pages/login/login.vue'
import AppOverlays from 'zero/components/overlays/overlay-holder.vue'
import AppNotifications from 'zero/components/notifications/notification-holder.vue'
import EventHub from 'zero/helpers/eventhub.js';
import AuthApi from 'zero/helpers/auth.js'
2021-08-25 10:12:48 +02:00
import ConfigApi from 'zero/api/config.js';
2021-09-03 09:40:36 +02:00
import Overlay from 'zero/helpers/overlay.js'
2021-08-25 10:12:48 +02:00
2020-03-23 20:05:02 +01:00
export default {
name: 'app',
2021-09-01 23:09:22 +02:00
components: { AppNavigation, AppBar, AppSearch, AppOverlays, AppLogin, AppNotifications },
2020-04-09 11:48:34 +02:00
data: () => ({
isAuthenticated: false,
keyIndex: 0
2020-04-09 11:48:34 +02:00
}),
computed: {
appKey()
{
return 'appkey-' + this.keyIndex;
}
},
created()
2020-04-09 11:48:34 +02:00
{
2021-11-11 15:39:26 +01:00
console.info('xzero', this.zero);
2020-10-16 14:02:10 +02:00
AuthApi.setUser(__zero.user);
2020-10-15 14:10:38 +02:00
AuthApi.$on('authenticated', isAuthenticated =>
{
this.isAuthenticated = isAuthenticated;
});
AuthApi.$on('appswitch', data =>
{
2021-09-05 09:15:19 +02:00
location.reload();
this.rerender();
//this.isAuthenticated = isAuthenticated;
});
2021-08-25 10:12:48 +02:00
AuthApi.$on('apprebuild', data =>
{
this.rerender();
});
2021-09-03 09:40:36 +02:00
EventHub.$on('app.search.open', () =>
{
this.search();
});
2021-09-04 16:58:11 +02:00
if (localStorage.getItem('zero.theme') === 'dark')
{
document.body.classList.remove('theme-light');
document.body.classList.add('theme-dark');
}
2020-09-04 15:28:06 +02:00
},
methods: {
getClassList()
{
return {
2020-10-16 11:23:54 +02:00
'is-preview': false //this.$route.name === 'preview'
2020-09-04 15:28:06 +02:00
};
},
rerender()
{
2021-08-25 10:12:48 +02:00
ConfigApi.getConfig().then(res => {
window.__zero = res;
window.zero = res;
AuthApi.setUser(res.user);
this.keyIndex += 1;
});
2021-09-03 09:40:36 +02:00
},
search()
{
Overlay.open({
component: AppSearch,
autoclose: false,
softdismiss: true,
width: 780,
class: 'app-search-overlay'
});
2020-09-04 15:28:06 +02:00
}
2020-04-09 11:48:34 +02:00
}
2020-03-23 20:05:02 +01:00
}
</script>