interface ArticleCondition { ids?: number[] } export const useArticleStore = defineStore("article", () => { const currentArticle = ref({}); const currentArticles = ref([]) 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}`, { query: { site: host } }) currentArticle.value = {} currentArticle.value = data.value.item } catch (error: any) { } } const getArticleBySlug = async (slug: string) => { try { const article = await $fetch(`/api/articles/get-by-slug/${slug}`, { query: { site: host } }) currentArticle.value = {} currentArticle.value = article?.item return currentArticle; } catch (error: any) { } } const getArticleCondition = async (condition: ArticleCondition) => { try { const { data: articles } = await useFetch(`/api/articles/condition`, { method: 'POST', body: condition, query: { site: host } }) } catch (error: any) { } } return { currentArticle, getArticleById, getArticleBySlug, getArticleCondition } }); import.meta.hot && import.meta.hot.accept(acceptHMRUpdate(useArticleStore, import.meta.hot));