thainv-dev: tạo lại cấu trúc folder và làm UI
This commit is contained in:
@@ -11,17 +11,57 @@ 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'
|
||||
|
||||
const { currentArticle } = storeToRefs(useArticleStore());
|
||||
const { step } = storeToRefs(useDynamicPageStore());
|
||||
import * as cherrio from 'cheerio'
|
||||
|
||||
const $ = cherrio.load(currentArticle.value.detail)
|
||||
// console.log($, 'cherrip')
|
||||
const router = useRouter()
|
||||
// import * as cherrio from 'cheerio'
|
||||
|
||||
// const $ = cherrio.load(currentArticle.value.detail)
|
||||
// for(let index = 0; index < $('articlerelation').length, index++) {
|
||||
// $('articlerelation')[index]
|
||||
// }
|
||||
// console.log($('articlerelation').length, 'cherrip')
|
||||
// onBeforeMount(async () => {
|
||||
// await useArticleStore().getArticleCondition({ids: [1, 2, 3]})
|
||||
// })
|
||||
// console.log(router,'route')
|
||||
onMounted(() => {
|
||||
// const elements = document.querySelectorAll('custom-figure')
|
||||
// elements.forEach((element) => {
|
||||
// element.addEventListener('click', (event) => {
|
||||
// event.preventDefault();
|
||||
// console.log(element, 'element')
|
||||
// const url = `figure/${element.getAttribute('data-code')}`;
|
||||
|
||||
// const a = document.createElement('a')
|
||||
// a.href = url;
|
||||
// document.body.appendChild(a)
|
||||
// a.click();
|
||||
// document.body.removeChild(a);
|
||||
// })
|
||||
// })
|
||||
|
||||
clickElement('figure', 'custom-figure', 'data-code')
|
||||
clickElement('author', 'author', 'data-code')
|
||||
})
|
||||
|
||||
function clickElement(type: string, selector: string, attribute: string) {
|
||||
const elements = document.querySelectorAll(selector)
|
||||
elements.forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
const url = `${window.location.protocol}//${window.location.host}/${type}/${element.getAttribute(attribute)}`;
|
||||
|
||||
const a = document.createElement('a')
|
||||
a.href = url;
|
||||
document.body.appendChild(a)
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
})
|
||||
})
|
||||
}
|
||||
// const fileName = ref('')
|
||||
// onMounted(() => {
|
||||
// const documentElements = document.querySelectorAll('document, attachment')
|
||||
|
||||
@@ -50,15 +90,24 @@ const $ = cherrio.load(currentArticle.value.detail)
|
||||
</script>
|
||||
<template>
|
||||
<div class="content" v-if="currentArticle">
|
||||
<h1 id="sub" v-html="currentArticle?.sub" class=" font-bold opacity-60 pb-1" :style="{ 'font-size': `${16 + Number(step)}px`}"></h1>
|
||||
<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} }" /> -->
|
||||
<h1 id="sub" v-html="currentArticle?.sub" class=" font-bold opacity-60 pb-1"></h1>
|
||||
<h3 id="title" class="font-bold pb-1" v-html="currentArticle?.title"></h3>
|
||||
<p id="published-on" class="text-gray-600 mb-3">{{ 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"></div>
|
||||
<component :is="{template: currentArticle.detail, components: { Poll, Quiz, Survey, Document, Attachment, Tag} }" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
#sub, #intro, #intro + div {
|
||||
font-size: calc(16px + var(--step) * 1px);
|
||||
}
|
||||
|
||||
#title {
|
||||
font-size: calc(28px + var(--step) * 1px);
|
||||
}
|
||||
|
||||
#published-on {
|
||||
font-size: calc(14px + var(--step) * 1px);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user