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) {