feat: create by site
This commit is contained in:
+17
-3
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user