2024-05-30 18:06:50 +07:00
|
|
|
<script lang="ts" setup>
|
2024-07-01 16:04:16 +07:00
|
|
|
import type { PageSection } from "@/server/models/dynamic-page/index";
|
2024-06-28 15:39:26 +07:00
|
|
|
import { enumPageSectionLayouts, enumPageSectionTemplate, enumPageSectionKey } from "@/definitions/enum";
|
|
|
|
|
import { NONE_DEFAULT_LAYOUT } from "./index";
|
2024-05-30 18:06:50 +07:00
|
|
|
|
|
|
|
|
const _props = defineProps<{
|
|
|
|
|
settings?: any;
|
|
|
|
|
layout?: string;
|
|
|
|
|
content?: any;
|
|
|
|
|
section: any;
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const definedDynamicSection: Record<string, any> = {
|
2024-07-01 16:05:16 +07:00
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_TWO"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_ONE_TWO_THREE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_ONE_FIVE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_LEFT_TWO"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_RIGHT_TWO"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_THREE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_FOUR"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_CENTER_TWO"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_CENTER_THREE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["VERTICAL_CENTER_FOUR"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_ONE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_TWO"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_THREE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_FOUR"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_FIVE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_SIX"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_SEVEN"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_EIGHT"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_NINE"]]: NONE_DEFAULT_LAYOUT,
|
|
|
|
|
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]["NONE"]]["HORIZONTAL_TEN"]]: NONE_DEFAULT_LAYOUT,
|
2024-05-30 18:06:50 +07:00
|
|
|
};
|
|
|
|
|
|
2024-06-28 15:39:26 +07:00
|
|
|
const getCurrentSection = computed(() => {
|
|
|
|
|
return _props.settings.layout
|
|
|
|
|
});
|
2024-05-30 18:06:50 +07:00
|
|
|
const GET_PROPS = computed(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
let props: any = {};
|
|
|
|
|
if (_props.settings) {
|
2024-06-28 15:39:26 +07:00
|
|
|
for (const [key, value] of Object.entries(_props.settings)) {
|
2024-05-30 18:06:50 +07:00
|
|
|
props = {
|
|
|
|
|
...props,
|
|
|
|
|
[key]: value,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return props;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<component
|
2024-06-28 15:39:26 +07:00
|
|
|
:is="definedDynamicSection[getCurrentSection]"
|
2024-05-30 18:06:50 +07:00
|
|
|
v-bind="{
|
|
|
|
|
...GET_PROPS(),
|
|
|
|
|
section: _props.section,
|
|
|
|
|
content: _props.content,
|
2024-06-28 15:39:26 +07:00
|
|
|
settings: _props.settings,
|
2024-05-30 18:06:50 +07:00
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<slot />
|
|
|
|
|
</component>
|
|
|
|
|
</template>
|