From ecf4512cd39139c8009bb92ed43705749127c5a1 Mon Sep 17 00:00:00 2001 From: nguyen van thai Date: Thu, 13 Jun 2024 17:24:46 +0700 Subject: [PATCH] =?UTF-8?q?thainv-dev:=20s=E1=BB=ADa=20l=E1=BA=A1i=20c?= =?UTF-8?q?=E1=BA=A5u=20tr=C3=BAc=20folder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/articles/index.vue | 3 +- .../templates/articles/layouts/Card.vue | 125 ++++- .../articles/layouts/details/Podcast.vue | 486 +++++++++++++++++- .../articles/layouts/details/Video.vue | 2 - .../templates/categories/index.ts | 1 + .../templates/categories/index.vue | 34 ++ .../templates/categories/layouts/Default.vue | 38 ++ .../templates/collections/layouts/Article.vue | 129 ++++- .../page-component/templates/index.ts | 3 +- .../page-component/templates/index.vue | 6 +- .../templates/sections/index.ts | 1 + .../templates/sections/index.vue | 34 ++ .../templates/sections/layouts/Article.vue | 225 ++++++++ .../page-section/layouts/Default.vue | 13 +- .../page-section/layouts/index.vue | 1 - pages/[categories]/index.vue | 1 + pages/bai-viet/[slug].vue | 2 +- pages/index.vue | 1 - server/models/category.ts | 1 - server/models/poll-response.ts | 2 +- stores/articles.ts | 1 - utils/parseSQL.ts | 2 + 22 files changed, 1056 insertions(+), 55 deletions(-) create mode 100644 components/dynamic-page/page-component/templates/categories/index.ts create mode 100644 components/dynamic-page/page-component/templates/categories/index.vue create mode 100644 components/dynamic-page/page-component/templates/categories/layouts/Default.vue create mode 100644 components/dynamic-page/page-component/templates/sections/index.ts create mode 100644 components/dynamic-page/page-component/templates/sections/index.vue create mode 100644 components/dynamic-page/page-component/templates/sections/layouts/Article.vue diff --git a/components/dynamic-page/page-component/templates/articles/index.vue b/components/dynamic-page/page-component/templates/articles/index.vue index 3914c4c..c82bd07 100644 --- a/components/dynamic-page/page-component/templates/articles/index.vue +++ b/components/dynamic-page/page-component/templates/articles/index.vue @@ -17,6 +17,7 @@ const definedDynamicComponent: Record = { 'TYPE:Detail-LAYOUT:image': Article_Detail_Image, 'TYPE:Detail-LAYOUT:video': Article_Detail_Video, 'TYPE:Detail-LAYOUT:podcast': Article_Detail_Podcast, + 'TYPE:Card': Article_Card }; const getCurrentComponent = computed(() => `${_props.settings.layout}`); @@ -37,5 +38,5 @@ const GET_PROPS = computed(() => { diff --git a/components/dynamic-page/page-component/templates/articles/layouts/Card.vue b/components/dynamic-page/page-component/templates/articles/layouts/Card.vue index 9ca1f79..e112438 100644 --- a/components/dynamic-page/page-component/templates/articles/layouts/Card.vue +++ b/components/dynamic-page/page-component/templates/articles/layouts/Card.vue @@ -1,24 +1,94 @@ diff --git a/components/dynamic-page/page-component/templates/articles/layouts/details/Podcast.vue b/components/dynamic-page/page-component/templates/articles/layouts/details/Podcast.vue index a285f36..f7dc4a3 100644 --- a/components/dynamic-page/page-component/templates/articles/layouts/details/Podcast.vue +++ b/components/dynamic-page/page-component/templates/articles/layouts/details/Podcast.vue @@ -1,10 +1,478 @@ - - - \ No newline at end of file + +onMounted(async () => { + clickElement("figure", "custom-figure", "data-code"); + clickElement("author", "author", "data-code"); + + let detailEmagazine = document.querySelector('div[layout="ARTICLE_DETAIL_EMAGAZINE"]'); + let breakcrumb = document.querySelector('div[layout="BREADCRUM_DEFAULT"]'); + if (detailEmagazine && breakcrumb) { + breakcrumb.classList.add("lg:max-w-640px", "mx-auto"); + } +}); + +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 isBookmark = ref(false); +const onClickBookmark = () => { + isBookmark.value = !isBookmark.value; +}; +async function copyLink() { + try { + const url = window.location.href; + await navigator.clipboard.writeText(url); + alert("copy link thành công"); + } catch (error) { + alert(error); + } +} + +const getSrc = (htmlString: string) => { + const srcRegex = /src="([^"]+)"/; + return htmlString?.match(srcRegex); +}; + +const isMoreControl = ref(false); +const isPlayed = ref(true); +const isVolume = ref(true); +const speedList = ref<{ [key: number]: string }>({ + 1: "0.5x", + 2: "0.75x", + 3: "1.0x", + 4: "1.25x", + 5: "1.50x", +}); +const speedIndexDefault = ref(3); +const speedDefault = ref(speedList.value[speedIndexDefault.value]); +const volume = ref(1.0); +const audioPlayer = ref(null); +const currentTime = ref(0); +const duration = ref(0); + +function setUpVolums() { + isVolume.value = !isVolume.value; + if (audioPlayer.value) { + if (isVolume.value) { + audioPlayer.value.volume = 1; + } else { + audioPlayer.value.volume = 0; + } + } +} + +const updateVolume = (num?: number) => { + if (audioPlayer.value) { + if(num) { + volume.value += num + } + audioPlayer.value.volume = volume.value; + } +}; + +function chanageSpeed() { + if (speedIndexDefault.value < 5) { + speedIndexDefault.value += 1; + if (audioPlayer.value) { + audioPlayer.value.playbackRate += 0.25; + } + speedDefault.value = speedList.value[speedIndexDefault.value]; + } else { + if (audioPlayer.value) { + audioPlayer.value.playbackRate = 0.5; + } + speedIndexDefault.value = 1; + speedDefault.value = speedList.value[1]; + } +} + +function togglePlayer() { + isPlayed.value = !isPlayed.value; + if (audioPlayer.value) { + if (isPlayed.value) { + audioPlayer.value.pause(); + } else { + audioPlayer.value.play(); + } + } +} + +function replayAndForward(time: number) { + if (audioPlayer.value) { + if (audioPlayer.value.currentTime == audioPlayer.value.duration) { + isPlayed.value = true; + } else { + audioPlayer.value.currentTime = audioPlayer.value.currentTime + time; + } + } +} + +const seekToTime = () => { + if (audioPlayer.value) { + audioPlayer.value.currentTime = currentTime.value; + } +}; + +const updateCurrentTime = () => { + if (audioPlayer.value) { + currentTime.value = audioPlayer.value.currentTime; + } +}; + +const updateDuration = () => { + if (audioPlayer.value) { + duration.value = audioPlayer.value.duration; + } +}; + +const currrentTimeComputed = computed(() => { + return utils.formattedTime(currentTime.value); +}); + +const durationComputed = computed(() => { + return utils.formattedTime(duration.value); +}); + + + diff --git a/components/dynamic-page/page-component/templates/articles/layouts/details/Video.vue b/components/dynamic-page/page-component/templates/articles/layouts/details/Video.vue index 11b8ab0..c8b1558 100644 --- a/components/dynamic-page/page-component/templates/articles/layouts/details/Video.vue +++ b/components/dynamic-page/page-component/templates/articles/layouts/details/Video.vue @@ -16,8 +16,6 @@ const store = reactive({ article: useArticleStore(), category: useCategoryStore(), }); - -console.log(currentArticle.value ,'curenta') + + diff --git a/components/dynamic-page/page-component/templates/index.ts b/components/dynamic-page/page-component/templates/index.ts index 65d4869..15fe183 100644 --- a/components/dynamic-page/page-component/templates/index.ts +++ b/components/dynamic-page/page-component/templates/index.ts @@ -5,7 +5,8 @@ export { default as CollectionPaging } from './pageCategories/collection_page.vu export { default as Dynamic_Other } from './other/index.vue' - +export { default as Dynamic_Section } from './sections/index.vue'; export { default as Dynamic_Advertising } from './advertising/index.vue' +export { default as Dynamic_Category } from './categories/index.vue' export { default as Dynamic_Article } from './articles/index.vue' export { default as Dynamic_Collection } from './collections/index.vue' \ No newline at end of file diff --git a/components/dynamic-page/page-component/templates/index.vue b/components/dynamic-page/page-component/templates/index.vue index bfdc1ac..5e91b73 100644 --- a/components/dynamic-page/page-component/templates/index.vue +++ b/components/dynamic-page/page-component/templates/index.vue @@ -1,6 +1,6 @@ + + diff --git a/components/dynamic-page/page-component/templates/sections/layouts/Article.vue b/components/dynamic-page/page-component/templates/sections/layouts/Article.vue new file mode 100644 index 0000000..4576302 --- /dev/null +++ b/components/dynamic-page/page-component/templates/sections/layouts/Article.vue @@ -0,0 +1,225 @@ + + + + + diff --git a/components/dynamic-page/page-section/layouts/Default.vue b/components/dynamic-page/page-section/layouts/Default.vue index 996847c..a38b394 100644 --- a/components/dynamic-page/page-section/layouts/Default.vue +++ b/components/dynamic-page/page-section/layouts/Default.vue @@ -147,15 +147,24 @@ const CLASS_FOR_SECTION = computed(() => { :key="index" :class="[CLASS_FOR_SECTION[index]]" > - + + -