This commit is contained in:
nguyen van thai
2024-07-09 15:15:22 +07:00
parent 776a3cf2c7
commit 0dba7790b1
16 changed files with 484 additions and 180 deletions
@@ -1,55 +1,76 @@
<script setup lang="ts">
import { isEmpty } from "@/utils/lodash";
const emit = defineEmits(["dropData", "selectComponent"]);
const { categoryTree } = storeToRefs(useCategoryStore());
const { currentArticle } = storeToRefs(useArticleStore());
if (categoryTree.value) {
await useCategoryStore().fetchBySiteId();
}
const _props = defineProps<{
dataResult?: any;
dataResult?: any[];
}>();
const SETTING_OPTIONS = {
BREADCRUMB_MAX_ELEMENT: 3,
};
const currentCategoryTree = findElementPathById(categoryTree.value, currentArticle.value.categoryId);
function findElementPathById(categories: any[], targetId: number, path: any[] = []) {
for (const category of categories) {
const currentPath = [...path, { title: category.title, code: category.code }];
if (category.id === targetId) {
return currentPath;
}
if (category.children) {
const result: any = findElementPathById(category.children, targetId, currentPath);
if (result) {
return result;
}
}
}
return null;
}
console.log(currentArticle.value, "currentArticle");
</script>
<template>
<div class="overflow-hidden">
<div class="breadcrumb">
<ul class="breadcrumb__list">
<li
class="breadcrumb__list__item"
v-for="(item, index) in _props.dataResult && _props.dataResult?.length > 0 ? _props.dataResult : Array(SETTING_OPTIONS.BREADCRUMB_MAX_ELEMENT).fill(null)"
:key="index"
:class="isEmpty(item) && 'empty'"
>
<p v-if="!isEmpty(item)" class="breadcrumb__list__item__title">
{{ item?.title }}
</p>
</li>
</ul>
<div class="overflow-hidden w-full max-w-1385px mx-auto px-30px image">
<div class="">
<div class="category flex justify-between flex-wrap items-center mb-10px">
<ul class="flex gap-32px">
<li v-for="(category, index) in currentCategoryTree" :key="index" class="first:text-#000 text-#929292 last:after:content-[''] relative after:absolute after:content-['/'] after:text-20px after:right--20px">
<nuxt-link class="font-raleway text-18px font-500 leading-180% uppercase" :to="`${category.code}`">{{ category.title }}</nuxt-link>
</li>
</ul>
<p class="breakcrumb__time">Ngày tạo image</p>
</div>
<div class="content">Nội dung bài viết sẽ đây</div>
<div class="btn-wrap w-100 max-w">
<div class="center-y">
<p title="Quay trở lại" class="button--back">
<Icon name="fa6-solid:arrow-left" />
</p>
<button class="button--bookmark">
<Icon name="fa6-regular:bookmark" />
</button>
<div v-if="currentArticle.topics" class="pl-20px relative bg-primary inline-block">
<nuxt-link class="h-30px block py-4px px-16px border-1 border-#000 bg-white text-12px leading-180% font-raleway font-400" :to="`/topic/${currentArticle.topics[0].code}`">{{ currentArticle.topics[0].title }}</nuxt-link>
</div>
</div>
<h2 class="font-gelasio text-44px font-bold leading-130%" v-if="currentArticle.title" v-html="currentArticle.title"></h2>
<!-- <div class="grid grid-cols-12 gap-20px">
<div class="col-span-3"></div>
</div> -->
<div class="center-y">
<button title="Copy link" class="button--back copy-link">
<Icon name="mdi:link-variant" />
</button>
<div class="author flex gap-12px my-20px" v-if="currentArticle.authors">
<ul class="flex">
<li :style="{ 'z-index': index + 1 }" class="relative ml--12px first:ml-0" v-for="(author, index) in currentArticle.authors" :key="index">
<nuxt-link :to="`tac-gia/${author.code}`">
<img :src="author.thumbnail || `http://picsum.photos/1024/600?random=1`" alt="" class="w-64px p-1px border-1px border-white h-64px object-cover rounded-full" />
</nuxt-link>
</li>
</ul>
<div>
<div class="mt-10px">
<nuxt-link class="font-raleway text-#000" v-for="(author, index) in currentArticle.authors" :key="index" :to="`/tac-gia/${author.code}`">{{ author.title + (index < currentArticle.authors.length - 1 ? ", " : "") }}</nuxt-link>
</div>
<div class="text-12px">Xuất bản vào {{ formatDate(currentArticle.publishedOn, "DD/MM/YYYY | hh:mm") }}</div>
</div>
</div>
<div v-html="currentArticle.detail"></div>
</div>
</div>
</template>
<style scoped lang="scss">
$max-width: 680px;
$max-width: 1276px;
.breadcrumb {
display: flex;