2024-05-31 12:39:53 +07:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { enumPageComponentTemplates } from "@/definitions/enum";
|
2024-06-03 12:27:22 +07:00
|
|
|
import { Article_Button, Article_Detail_Emagazine, Article_Detail_Default, Article_Detail_Infographics,
|
|
|
|
|
Default_Breadcrumb, ADS_Default, Comment, Article_Detail_Podcast, Article_Detail_Video
|
|
|
|
|
} from "./index";
|
2024-05-31 12:39:53 +07:00
|
|
|
const _props = defineProps<{
|
|
|
|
|
settings: any;
|
|
|
|
|
component?: any;
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const definedDynamicComponent: Record<string, any> = {
|
|
|
|
|
'BREADCRUM_DEFAULT': Default_Breadcrumb,
|
|
|
|
|
'ARTICLE_DETAIL_DEFAULT': Article_Detail_Default,
|
|
|
|
|
'ARTICLE_DETAIL_INFOGRAPHICS': Article_Detail_Infographics,
|
|
|
|
|
'ARTICLE_DETAIL_EMAGAZINE': Article_Detail_Emagazine,
|
2024-05-31 15:31:05 +07:00
|
|
|
'ADS_DEFAULT': ADS_Default,
|
2024-05-31 12:39:53 +07:00
|
|
|
'ARTICLE_BUTTON': Article_Button,
|
2024-05-31 15:31:05 +07:00
|
|
|
COMMENT: Comment,
|
2024-05-31 16:38:12 +07:00
|
|
|
PODCAST: Article_Detail_Podcast,
|
2024-06-03 12:27:22 +07:00
|
|
|
VIDEO: Article_Detail_Video
|
2024-05-31 12:39:53 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getCurrentComponent = computed(() => `${_props.settings.layout}`);
|
|
|
|
|
|
|
|
|
|
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 :is="definedDynamicComponent[getCurrentComponent]" v-bind="GET_PROPS()" />
|
|
|
|
|
</template>
|