minhnt-dev: fix page template
This commit is contained in:
@@ -1,39 +1,41 @@
|
||||
<script lang="ts" setup>
|
||||
import { HomeBasic } from './index';
|
||||
import { Home, Article } from "./index";
|
||||
import type { Page } from "@/models/cms";
|
||||
import { enumPageKey } from "@/definitions/enum";
|
||||
|
||||
const _props = defineProps<{
|
||||
settings: any
|
||||
}>()
|
||||
settings: any;
|
||||
page: Page;
|
||||
}>();
|
||||
|
||||
const definedDynamicPage: Record<string, any> = {
|
||||
'Home' : HomeBasic,
|
||||
'Article': HomeBasic
|
||||
}
|
||||
[enumPageKey.HOME]: Home,
|
||||
[enumPageKey.ARTICLE]: Article,
|
||||
};
|
||||
|
||||
const getCurrentTemplate = computed(() => {
|
||||
return _props.settings && _props.settings.template || '';
|
||||
return _props.page?.taxonomy || "";
|
||||
});
|
||||
|
||||
|
||||
const GET_PROPS = computed(() => {
|
||||
return () => {
|
||||
let props : any = {};
|
||||
if (_props.settings) {
|
||||
for (const [key, value] of _props.settings ? Object.entries(_props.settings) : []) {
|
||||
props = {
|
||||
...props,
|
||||
[key]: value
|
||||
}
|
||||
}
|
||||
}
|
||||
return props;
|
||||
};
|
||||
})
|
||||
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
|
||||
class="overflow-x-hidden"
|
||||
class="overflow-x-hidden"
|
||||
v-if="definedDynamicPage[getCurrentTemplate]"
|
||||
:is="definedDynamicPage[getCurrentTemplate]"
|
||||
v-bind="{...(GET_PROPS()), settings: _props.settings}"
|
||||
|
||||
Reference in New Issue
Block a user