Files
NSG_PORTAL_V2/components/dynamic-page/page-section/templates/index.vue
T
nguyen van thai 35f069a776 thainv-dev:
2024-07-01 16:04:16 +07:00

41 lines
979 B
Vue

<script lang="ts" setup>
import type { PageSection } from "@/server/models/dynamic-page/index";
import { enumPageSectionKey } from "@/definitions/enum";
import { None_Section } from "./index";
const _props = defineProps<{
settings?: any;
content?: any;
section?: any;
}>();
const definedDynamicSection: Record<string, any> = {
[enumPageSectionKey.NONE]: None_Section,
};
const getCurrentSection = computed(() => {
return _props.section?.taxonomy;
});
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="definedDynamicSection[getCurrentSection]" v-bind="{ ...GET_PROPS(), section: _props.section, content: _props.content, settings: _props.settings }">
<slot />
</component>
</template>