minhnt-dev: fix page template
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<script lang="ts" setup>
|
||||
import { Home } from './index';
|
||||
import { enumPageKey, enumPageTemplate } from "@/definitions/enum";
|
||||
|
||||
const _props = defineProps<{
|
||||
settings: any
|
||||
}>()
|
||||
|
||||
const definedDynamicPage: Record<string, any> = {
|
||||
[enumPageTemplate[enumPageKey.HOME]['DEFAULT']]: Home,
|
||||
}
|
||||
|
||||
const getCurrentTemplate = computed(() => {
|
||||
return _props.settings?.template || '';
|
||||
});
|
||||
|
||||
const GET_PROPS = computed(() => {
|
||||
return () => {
|
||||
let props : any = {};
|
||||
if (_props.settings) {
|
||||
for (const [key, value] of Object.entries(_props.settings)) {
|
||||
props = {
|
||||
...props,
|
||||
[key]: value
|
||||
}
|
||||
}
|
||||
}
|
||||
return props;
|
||||
};
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component v-if="definedDynamicPage[getCurrentTemplate]" :is="definedDynamicPage[getCurrentTemplate]" v-bind="{...(GET_PROPS()), settings: _props.settings}">
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
Reference in New Issue
Block a user