Add home page component; fix user state issues
must be sure to keep "anonymous" user represented as {} instead of null, otherwise getting errors. this also fixes the menu upon user login; previously it wasn't showing most options
This commit is contained in:
parent
2a1f5764a1
commit
721600b12d
7 changed files with 93 additions and 7 deletions
55
src/components/home/ByjoveHome.vue
Normal file
55
src/components/home/ByjoveHome.vue
Normal file
|
@ -0,0 +1,55 @@
|
|||
<template>
|
||||
<div>
|
||||
<img :alt="`${appsettings.systemTitle} logo`" :src="appsettings.logo" />
|
||||
<h1>Welcome to {{ appsettings.appTitle }}</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ByjoveHome',
|
||||
props: {
|
||||
appsettings: {
|
||||
type: Object,
|
||||
},
|
||||
forceLogin: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inited: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
watch: {
|
||||
'$store.state.session_established': 'init',
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
if (this.inited) return
|
||||
|
||||
// nothing to check, unless login is to be enforced
|
||||
if (!this.forceLogin) {
|
||||
this.inited = true
|
||||
return
|
||||
}
|
||||
|
||||
// cannot init until session is established
|
||||
if (!this.$store.state.session_established) {
|
||||
return
|
||||
}
|
||||
|
||||
this.inited = true
|
||||
|
||||
// send anonymous users to login page
|
||||
if (!this.$store.state.user.uuid) {
|
||||
this.$router.push('/login')
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
28
src/components/home/index.js
Normal file
28
src/components/home/index.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Import vue component
|
||||
import ByjoveHome from './ByjoveHome.vue'
|
||||
|
||||
// Declare install function executed by Vue.use()
|
||||
export function install(Vue) {
|
||||
if (install.installed) return;
|
||||
install.installed = true;
|
||||
Vue.component('ByjoveHome', ByjoveHome);
|
||||
}
|
||||
|
||||
// Create module definition for Vue.use()
|
||||
const plugin = {
|
||||
install,
|
||||
};
|
||||
|
||||
// Auto-install when vue is found (eg. in browser via <script> tag)
|
||||
let GlobalVue = null;
|
||||
if (typeof window !== 'undefined') {
|
||||
GlobalVue = window.Vue;
|
||||
} else if (typeof global !== 'undefined') {
|
||||
GlobalVue = global.Vue;
|
||||
}
|
||||
if (GlobalVue) {
|
||||
GlobalVue.use(plugin);
|
||||
}
|
||||
|
||||
// To allow use as module (npm/webpack/etc.) export component
|
||||
export default ByjoveHome
|
Loading…
Add table
Add a link
Reference in a new issue