2019-04-11 00:12:23 +02:00
|
|
|
<template lang="html">
|
2019-06-03 13:06:44 +02:00
|
|
|
<div :id="id">
|
2019-06-06 17:37:43 +02:00
|
|
|
<!-- <router-view name="home" :html="home_template_src"></router-view> -->
|
|
|
|
<!-- <router-view name="base"></router-view> -->
|
2021-05-25 22:22:00 +02:00
|
|
|
<router-view :html="home_template_src" :full="full_home_template_loaded"/>
|
2019-06-03 13:06:44 +02:00
|
|
|
</div>
|
2019-04-11 00:12:23 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
|
2021-09-16 21:40:18 +02:00
|
|
|
import MA from 'vuejs/api/ma-axios'
|
2019-06-03 13:06:44 +02:00
|
|
|
import router from 'vuejs/route'
|
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
export default {
|
2019-06-03 13:06:44 +02:00
|
|
|
router,
|
2019-06-04 22:38:44 +02:00
|
|
|
props:['id','html', 'isfront'],
|
|
|
|
data() {
|
|
|
|
return {
|
2021-05-25 22:22:00 +02:00
|
|
|
home_template_src: null,
|
|
|
|
full_home_template_loaded: false
|
2019-06-04 22:38:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('MainContent beforeMount this.html', this.html)
|
|
|
|
if (!this.home_template_src) {
|
2021-05-25 22:22:00 +02:00
|
|
|
// // console.log('no home_template_src')
|
|
|
|
// if (this.html && this.isfront) { // if html prop is available and we are landing on home then record it has data
|
|
|
|
// this.home_template_src = this.html
|
|
|
|
// } else { // else get it from ajax (e.g. if we didn't load the page from home)
|
|
|
|
// this.getHomeHtml()
|
|
|
|
// }
|
|
|
|
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('no home_template_src')
|
2021-05-25 22:22:00 +02:00
|
|
|
if (this.isfront) {
|
|
|
|
// if html prop is available and we are landing on home then record it has data
|
2019-06-04 22:38:44 +02:00
|
|
|
this.home_template_src = this.html
|
2021-05-25 22:22:00 +02:00
|
|
|
}
|
|
|
|
// in any case load the full home template if not already loaded
|
|
|
|
if (!this.full_home_template_loaded) {
|
2019-06-04 22:38:44 +02:00
|
|
|
this.getHomeHtml()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getHomeHtml(){
|
2021-05-25 22:22:00 +02:00
|
|
|
console.log('MainContent getHomeHtml');
|
2019-06-04 22:38:44 +02:00
|
|
|
MA.get('materio_home/ajax/gethome')
|
|
|
|
.then(({data}) => {
|
2021-06-02 11:21:03 +02:00
|
|
|
// console.log('MainContent getHomeHtml data', data)
|
2021-05-25 22:22:00 +02:00
|
|
|
this.full_home_template_loaded = true
|
2019-06-04 22:38:44 +02:00
|
|
|
this.home_template_src = data.rendered // record the html src into data
|
|
|
|
})
|
2021-03-31 18:42:05 +02:00
|
|
|
.catch((error) => {
|
2019-06-04 22:38:44 +02:00
|
|
|
console.warn('Issue with getHomeHtml', error)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 00:12:23 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2019-05-23 18:11:06 +02:00
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
</style>
|