thainv-dev: Fix

This commit is contained in:
nguyen van thai
2024-07-17 10:35:35 +07:00
parent 5f9525371d
commit 795cd47e41
18 changed files with 78 additions and 43 deletions
@@ -53,7 +53,9 @@ const parseData = computed(() => {
<template>
<article :id="`cpn_${props.component.id}`" class="card-audio" :class="LAYOUT_PARSE['article_Class']" :style="LAYOUT_PARSE['article']">
<img :src="parseData?.thumbnail ? parseData?.thumbnail : 'https://indiaeducationdiary.in/wp-content/uploads/2021/02/SD-default-image.png'" :alt="parseData?.title?.replace(/<[^>]+>/g, '')" />
<nuxt-link :to="`/bai-viet/${parseData?.slug}`" class="article-thumbnail">
<img :src="parseData?.thumbnail ? parseData?.thumbnail : 'https://indiaeducationdiary.in/wp-content/uploads/2021/02/SD-default-image.png'" :alt="parseData?.title?.replace(/<[^>]+>/g, '')" />
</nuxt-link>
<div class="card-audio__content">
<span class="flex justify-center">
<template v-if="['Image', 'Infographics', 'Emagazine'].includes(type)">
@@ -93,12 +95,18 @@ const parseData = computed(() => {
padding-bottom: calc((16 / 9) * 100%);
overflow: hidden;
img {
.article-thumbnail {
position: absolute;
height: 100%;
width: 100%;
object-fit: cover;
z-index: 1;
& img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.card-audio__content {
@@ -48,11 +48,18 @@ const drop = (e: any) => {
<article :id="`cpn_${props.component.id}`" class="basic-article border-custom" :class="LAYOUT_PARSE['article_Class']" :style="LAYOUT_PARSE['article']">
<div class="article_miss">
<template v-if="parseData">
<div class="article_miss_thumb custom-thumb" :style="{ backgroundImage: `url('${parseData.thumbnail ? parseData.thumbnail : '/images/default-thumbnail.jpg'}')` }"></div>
<nuxt-link :to="`/bai-viet/${parseData.slug}`">
<div class="article_miss_thumb custom-thumb" :style="{ backgroundImage: `url('${parseData.thumbnail ? parseData.thumbnail : '/images/default-thumbnail.jpg'}')` }"></div>
</nuxt-link>
<div class="article_miss_content" :style="LAYOUT_PARSE['content']">
<nuxt-link :to="`/bai-viet/${parseData.slug}`">
<h3 class="line-clamp text-white" :class="LAYOUT_PARSE['title_Class']" :style="LAYOUT_PARSE['h3.title']">
{{ parseData.title?.replace(/<[^>]+>/g, "") }}
</h3>
</nuxt-link>
</div>
</template>
<div v-else class="empty-box"></div>
@@ -70,7 +70,7 @@ const mapActivesToItems = (index: number) => {
<section :id="`cpn_${_props.component.id}`" class="gallery" :class="[LAYOUT_PARSE['div.collection-container_Class'], LAYOUT_PARSE['collection_Class']]" @click="selectComponent" :style="LAYOUT_PARSE['div.collection-container']">
<div class="wrap" v-for="(component, index) in _dataResult" :key="index">
<DynamicComponent
class="abc"
class="box"
:settings="{
template: SETTING_OPTIONS.TEMPLATE,
layout: SETTING_OPTIONS.LAYOUT,
@@ -142,7 +142,7 @@ const mapActivesToItems = (index: number) => {
padding-top: 241px;
}
& > .abc {
& > .box {
position: absolute;
top: 0;
width: 100%;
@@ -85,6 +85,7 @@ const mapActivesToItems = (index: number) => {
const currentCategoryTree = ref<any []>([]);
if(currentArticle.value?.categoryId) {
console.log('urrentArticle.value?.categoryId', categoryTree.value)
currentCategoryTree.value = findElementPathById(categoryTree.value, currentArticle.value.categoryId)
}
function findElementPathById(categories: any[], targetId: number, path: any[] = []) {
@@ -108,7 +109,7 @@ function findElementPathById(categories: any[], targetId: number, path: any[] =
<div class="section_layout border-custom four_col_layout" :style="LAYOUT_PARSE['div.section_layout']">
<div class="left">
<div>
<div class="audio">
<!-- <div class="audio">
<div class="play">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
@@ -124,7 +125,7 @@ function findElementPathById(categories: any[], targetId: number, path: any[] =
<div class="timeline">
<input type="range" name="" id="" />
</div>
</div>
</div> -->
<div class="buttons">
<div class="actions">
+2 -2
View File
@@ -11,12 +11,12 @@ const store = reactive({
});
//lấy danh sách categoryTree
await store.category.fetchBySiteId()
const site = useCookie('site')
// const site = useCookie('site')
const { data } = await useAsyncData('index', () => store.dynamicPage.fetchPageByCode(route.path === '/' ? 'trang-chu' : route.path.replace('/', '')))
const asycnCurrentPage = data.value && data.value.currentPage;
const asycnSectionPublished = data.value && data.value.sectionPublished;
const asycnComponentPublished = data.value && data.value.componentPublished;
site.value = data.value?.currentPage?.siteId
// site.value = data.value?.currentPage?.siteId
useHead({
title: () => 'Trang chủ',
description: () => 'Với công nghệ đột phá và giải pháp sáng tạo, Vpress sẽ là đối tác tin cậy của các tòa soạn báo, cùng nhau kiến tạo nên những giá trị bền vững trong kỷ nguyên chuyển đổi số báo chí.',
+3 -2
View File
@@ -32,10 +32,11 @@ export const list = async (event : H3Event) => {
try {
const { site, apiUrl } = useRuntimeConfig().public;
const query = getQuery(event)
const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:1`, {
const siteId = getSite(query.site).toString()
const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:${siteId}`, {
method: "GET",
headers: new Headers({
site: getSite(query.site).toString(),
site: siteId,
}),
});
return { items } ;
+2 -1
View File
@@ -20,10 +20,11 @@ export type PollOption = {
const { apiUrl } = useRuntimeConfig().public
const { pollId }: any = getQuery(event)
const query = getQuery(event)
const { items }: PollOption[] | any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
method: 'GET',
headers: {
site: Number(useCookie('site').value)
site: getSite(query.site).toString()
},
})
+4 -2
View File
@@ -16,10 +16,11 @@ export const create = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const payload = await readBody<any>(event)
const query = getQuery(event)
const { item }: any = await $fetch(`${apiUrl}/cms/poll-response`, {
method: 'POST',
headers: {
site: Number(useCookie('site').value)
site: getSite(query.site).toString()
},
body: payload
})
@@ -35,10 +36,11 @@ export const fetchByPollId = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { pollId }: any = getQuery(event)
const query = getQuery(event)
const { items }: PollResponse[] | any = await $fetch(`${apiUrl}/cms/poll-response/poll:${pollId}`, {
method: 'GET',
headers: {
site: Number(useCookie('site').value)
site: getSite(query.site).toString()
},
})
+2 -1
View File
@@ -32,10 +32,11 @@ export type Poll = {
try {
const { apiUrl } = useRuntimeConfig().public
const { pollId}: any = getQuery(event)
const query = getQuery(event)
const { item }: Poll | any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
method: 'GET',
headers: {
site: 1
site: getSite(query.site).toString()
}
})
+2 -1
View File
@@ -31,10 +31,11 @@ export type Quiz = {
const { apiUrl } = useRuntimeConfig().public
const { quizId }: any = getQuery(event)
const query = getQuery(event)
const { item }: Quiz | any = await $fetch(`${apiUrl}/cms/quiz/${quizId}`, {
method: 'GET',
headers: {
site: 1
site: getSite(query.site).toString()
}
})
+2 -1
View File
@@ -31,10 +31,11 @@ export type Survey = {
const { apiUrl } = useRuntimeConfig().public
const { surveyId }: any = getQuery(event)
const query = getQuery(event)
const { item }: Survey | any = await $fetch(`${apiUrl}/cms/survey/${surveyId}`, {
method: 'GET',
headers: {
site: 1
site: getSite(query.site).toString()
}
})
+4 -3
View File
@@ -7,10 +7,10 @@ export const get = async(event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { code } = getQuery(event)
const query = getQuery(event)
const { items }: any = await $fetch(`${apiUrl}/cms/tag/code:${code}`, {
headers: {
site: 1
site: getSite(query.site).toString()
}
})
return items
@@ -23,10 +23,11 @@ export const fetchById = async(event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { tagId }: any = getQuery(event)
const query = getQuery(event)
const { item }: any = await $fetch(`${apiUrl}/cms/tag/${tagId}`, {
method: 'GET',
headers: {
Site: 1
Site: getSite(query.site).toString()
}
})
return item
+6 -4
View File
@@ -12,10 +12,10 @@ export const listPaging = async (event: H3Event) => {
if(categoryId) {
query.value = { categoryId }
}
const gQuery = getQuery(event)
const { items, total }: any = await $fetch(`${apiUrl}/cms/topic/condition/paging:${page}-${limit}/sorting:${sort}`,{
method: 'POST',
headers: {site: 1},
headers: {site: getSite(gQuery.site).toString()},
body:{ ...query.value }
})
@@ -29,10 +29,11 @@ export const fetchByCode = async(event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { topicCode }: any = getQuery(event)
const query = getQuery(event)
const { item }: any = await $fetch(`${apiUrl}/cms/topic/code:${topicCode}`, {
method: 'GET',
headers: {
site: 1
site: getSite(query.site).toString()
}
})
@@ -46,10 +47,11 @@ export const fetchById = async(event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { topicId }: any = getQuery(event)
const query = getQuery(event)
const { item }: any = await $fetch(`${apiUrl}/cms/topic/${topicId}`, {
method: 'GET',
headers: {
site: 1
site: getSite(query.site).toString()
}
})
+3 -2
View File
@@ -1,11 +1,12 @@
export const getSite = (dns : any) => {
const SITE = {
DEFAULT: 1,
KINHTEDOTHI: 'kinhtedothi',
PORTAL2: 'portal2',
}
let site = null;
switch (dns) {
case SITE.KINHTEDOTHI:
case SITE.PORTAL2:
site = 2;
break;
default:
+7 -2
View File
@@ -83,9 +83,14 @@ import type { Category, CategoryTree } from "~/server/models/category";
export const useCategoryStore = defineStore('usecategorystore', () => {
const categoryTree = shallowRef<CategoryTree[]>([])
const currentCategoryTree = shallowRef<any[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchBySiteId() {
const { data }: any = await useFetch(`/api/services/category-tree`)
const { data }: any = await useFetch(`/api/services/category-tree`,{
query: {
site: host
}
})
categoryTree.value = data.value.items
return categoryTree.value
}
+4 -1
View File
@@ -2,11 +2,14 @@ import type { PollOption } from "~/server/models/poll-option"
export const usePollOptionStore = defineStore('usePollOptionStore', () => {
const currentPollOption = shallowReactive<PollOption>({})
const currentPollOptions = shallowRef<PollOption[] | any[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchByPollId(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-option/pollId`, {
query: {
pollId: id
pollId: id,
site: host
}
})
+6 -2
View File
@@ -2,12 +2,15 @@ import type { PollResponse } from "~/server/models/poll-response"
export const usePollResponseStore = defineStore('usePollResponseStore', () => {
const currentPollResponse = shallowReactive<PollResponse>({})
const currentPollResponses = shallowRef<PollResponse[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
const create = async (pollResponse: any) => {
try {
const { data } = await useFetch<any>(`/api/services/poll-response`, {
method: 'POST',
body: pollResponse
body: pollResponse,
query: {site: host}
})
data.value && (Object.assign(currentPollResponse, data.value))
return currentPollResponse
@@ -21,7 +24,8 @@ export const usePollResponseStore = defineStore('usePollResponseStore', () => {
try {
const { data } = await useFetch<any>(`/api/services/poll-response/pollId`, {
query: {
pollId: id
pollId: id,
site: host
}
})
+7 -11
View File
@@ -1,12 +1,17 @@
import type { Poll } from "~/server/models/poll"
export const usePollStore = defineStore('usePollStore', () => {
const currentPoll = shallowReactive<Poll>({})
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchById(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-by-id`, {
query: {
pollId: id
pollId: id,
site: host
}
})
@@ -16,16 +21,7 @@ export const usePollStore = defineStore('usePollStore', () => {
}
}
async function categoryId() {
try {
const { data } = await useFetch(`/api/services/category-tree`)
return data.value
} catch (error) {}
}
return { fetchById, currentPoll, categoryId }
return { fetchById, currentPoll }
})
if(import.meta.hot) {