feat: create by site

This commit is contained in:
MoreStrive
2024-07-15 21:02:22 +07:00
parent 043f97743c
commit 7565a37d60
9 changed files with 83 additions and 31 deletions
+17 -3
View File
@@ -5,9 +5,16 @@ export const useArticleStore = defineStore("article", () => {
const currentArticle = ref<any>({});
const currentArticles = ref<any[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
const getArticleById = async (id: string | number) => {
try {
const { data } = await useFetch(`/api/articles/get-by-id/${id}`)
const { data } = await useFetch(`/api/articles/get-by-id/${id}`, {
query: {
site: host
}
})
currentArticle.value = {}
currentArticle.value = data.value.item
} catch (error: any) { }
@@ -15,7 +22,11 @@ export const useArticleStore = defineStore("article", () => {
const getArticleBySlug = async (slug: string) => {
try {
const article = await $fetch(`/api/articles/get-by-slug/${slug}`)
const article = await $fetch(`/api/articles/get-by-slug/${slug}`, {
query: {
site: host
}
})
currentArticle.value = {}
currentArticle.value = article?.item
@@ -27,7 +38,10 @@ export const useArticleStore = defineStore("article", () => {
try {
const { data: articles } = await useFetch(`/api/articles/condition`, {
method: 'POST',
body: condition
body: condition,
query: {
site: host
}
})
} catch (error: any) {
+10 -2
View File
@@ -1,10 +1,14 @@
import { defineStore, acceptHMRUpdate } from "pinia";
import { useLocalStorage } from "@vueuse/core";
export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
const currentPage = ref<any>({});
const sectionPublished = ref<any[]>([]);
const componentPublished = ref<any[]>([]);
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
const setSectionPublished = () => {
const exsitsTemplate = ['None']
const contentArr: any = [];
@@ -45,7 +49,11 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
async function fetchPageByCode(slug: any) {
try {
const page = await $fetch(`/api/dynamic-page/get-by-code/${slug}`)
const page = await $fetch(`/api/dynamic-page/get-by-code/${slug}`, {
query: {
site: host
}
})
currentPage.value = {}
currentPage.value = page
@@ -60,7 +68,7 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
} catch (error: any) {}
}
async function getOverviewPageComponentById(componentId, dataQuery) {
async function getOverviewPageComponentById(componentId: any, dataQuery: any) {
try {
const { apiUrl } = useRuntimeConfig().public
const res = await $fetch(`${apiUrl}/cms/page-component/overview-page-component/${componentId}`, {