Files
NSG_PORTAL_V2/components/dynamic-page/page-component/templates/other/details/default.vue
T

64 lines
3.3 KiB
Vue
Raw Normal View History

2024-05-31 12:39:53 +07:00
<script setup lang="ts">
2024-06-03 21:53:23 +07:00
import { breakpoint } from '~/definitions';
import { useWindowSize } from '@vueuse/core'
const { width } = useWindowSize()
2024-05-31 15:31:05 +07:00
import { useArticleStore } from '~/stores/articles';
2024-06-03 21:53:23 +07:00
import { useDynamicPageStore } from "~/stores/dynamic-page";
2024-06-06 13:29:22 +07:00
import Poll from '~/components/article/immerse/Poll.vue'
import Quiz from '~/components/article/immerse/Quiz.vue'
import Survey from '~/components/article/immerse/Survey.vue'
import Document from '~/components/article/immerse/Document.vue'
import Attachment from '@/components/article/immerse/Attachment.vue'
import Tag from '@/components/article/immerse/Tag.vue'
import Articlerelation from '~/components/article/immerse/ArticleRelation.vue'
2024-05-31 15:31:05 +07:00
const { currentArticle } = storeToRefs(useArticleStore());
2024-06-03 21:53:23 +07:00
const { step } = storeToRefs(useDynamicPageStore());
2024-06-06 13:29:22 +07:00
import * as cherrio from 'cheerio'
2024-06-03 21:53:23 +07:00
2024-06-06 13:29:22 +07:00
const $ = cherrio.load(currentArticle.value.detail)
// console.log($, 'cherrip')
2024-06-04 15:03:54 +07:00
// onBeforeMount(async () => {
// await useArticleStore().getArticleCondition({ids: [1, 2, 3]})
// })
2024-06-06 13:29:22 +07:00
// onMounted(() => {
// const documentElements = document.querySelectorAll('document, attachment')
// console.log(documentElements, 'doc')
// if(documentElements.length > 0) {
// documentElements.forEach((doc) => {
// doc.addEventListener('click', (event) => {
// event.preventDefault();
// const url = doc.getAttribute('data-resource');
// const file = doc.getAttribute('data-resource') ? doc.getAttribute('data-resource')?.toString().split('.').pop() : 'docx'
// fileName.value = `${doc.getAttribute('data-title')}.${file}` ;
// console.log(url , fileName.value, '123')
// if(url && fileName.value) {
// const a = document.createElement('a');
// a.href = url?.toString();
// a.download = fileName.value;
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// }
// })
// })
// }
// })
2024-05-31 12:39:53 +07:00
</script>
<template>
2024-05-31 15:31:05 +07:00
<div class="content" v-if="currentArticle">
2024-06-03 21:53:23 +07:00
<h1 id="sub" v-html="currentArticle?.sub" class=" font-bold opacity-60 pb-1" :style="{ 'font-size': `${16 + Number(step)}px`}"></h1>
2024-06-06 13:29:22 +07:00
<h3 id="title" :style="{ 'font-size': width > breakpoint.lg ? `${32 + Number(step)}px` : `${20 + Number(step)}px`}" class="font-bold pb-1" v-html="currentArticle?.title"></h3>
<p id="published-on" class="text-gray-600 mb-3" :style="{ 'font-size': `${14 + Number(step)}px` }">{{ utils.dateFormat(currentArticle?.publishedOn, "dddd, DD/MM/YYYY - HH:mm") }}</p>
<div id="intro" v-if="currentArticle?.intro" v-html="currentArticle?.intro" class="font-semibold tracking-widest pb-1 mb-3" :style="{'font-size': `${16 + Number(step)}px`}"></div>
<!-- <div id="article-detail" :class="'tracking-wider'" v-html="currentArticle.detail" class="[&_img]:mx-auto" :style="{ 'font-size': `${16 + Number(step)}px`}"> </div> -->
<component :is="{template: currentArticle.detail, components: { Poll, Document, Attachment, Tag} }" />
<!-- <component :is="{template: currentArticle.detail, components: { Poll, Quiz, Survey, Document, Attachment, Tag} }" /> -->
2024-05-31 12:39:53 +07:00
</div>
</template>
2024-05-31 15:31:05 +07:00
<style lang="scss">
2024-05-31 12:39:53 +07:00
</style>