Files

62 lines
2.1 KiB
Vue
Raw Permalink Normal View History

2024-06-17 11:48:00 +07:00
<script setup lang="ts">
2024-06-28 15:39:26 +07:00
import { enumPageComponentLayouts, enumPageComponentTemplate, enumPageComponentKey } from "@/definitions/enum";
2024-06-17 11:48:00 +07:00
import DynamicComponent from "~/components/dynamic-page/page-component/templates/index.vue";
import { useDynamicPageStore } from '~/stores/dynamic-page';
const { currentPage } = storeToRefs(useDynamicPageStore());
const props = defineProps<{
2024-07-05 10:39:07 +07:00
type?: any; // [TOP_NAVIGATION, BOTTOM_NAVIGATION]
2024-06-17 11:48:00 +07:00
}>();
2024-07-16 09:23:44 +07:00
const contentParse = computed(() => (currentPage.value.content ? JSON.parse(currentPage.value.content) : {}));
2024-06-17 11:48:00 +07:00
const defineTypeRecusive = {
2024-07-01 16:04:16 +07:00
TOP_NAVIGATION: enumPageComponentLayouts[`${enumPageComponentTemplate[enumPageComponentKey.NAVIGATION]['TOP']}`]['NAVIGATION_TOP_DEFAULT'],
BOTTOM_NAVIGATION: enumPageComponentLayouts[`${enumPageComponentTemplate[enumPageComponentKey.NAVIGATION]['BOTTOM']}`]['NAVIGATION_BOTTOM_DEFAULT'],
2024-06-17 11:48:00 +07:00
};
2024-07-01 16:04:16 +07:00
const findDataPosition = computed<any>(() => {
2024-06-17 11:48:00 +07:00
let result = {};
switch (props.type) {
case defineTypeRecusive.TOP_NAVIGATION:
2024-07-16 09:23:44 +07:00
if (contentParse.value.navigationTop) {
result =
currentPage.value.components &&
currentPage.value.components.find((component: any) => {
return component.id === contentParse.value.navigationTop;
});
}
2024-06-17 11:48:00 +07:00
break;
case defineTypeRecusive.BOTTOM_NAVIGATION:
2024-07-16 09:23:44 +07:00
if (contentParse.value.navigationBottom) {
result =
currentPage.value.components &&
currentPage.value.components.find((component: any) => {
return component.id === contentParse.value.navigationBottom;
});
}
2024-06-17 11:48:00 +07:00
break;
default:
result = {};
break;
}
return result;
});
</script>
<template>
<div>
<DynamicComponent
v-if="findDataPosition && findDataPosition?.id"
:settings="findDataPosition?.settings"
:component="findDataPosition"
:content="findDataPosition?.content"
/>
<div v-else class="text-center">
<span>Hãy tạo thành phần "Thanh điều hướng ở đầu trang" để hiển thị thành điều hướng tại đây</span>
</div>
</div>
</template>
<style lang="scss" scoped>
</style>