2024-05-31 00:46:43 +07:00
|
|
|
export const useArticleStore = defineStore("article", () => {
|
|
|
|
|
const currentArticle = ref<any>({});
|
|
|
|
|
|
|
|
|
|
const getArticleById = async (id: string | number) => {
|
|
|
|
|
try {
|
2024-05-31 12:39:53 +07:00
|
|
|
|
|
|
|
|
const { data} = await useFetch(`/api/articles/get-by-id/${id}`)
|
2024-05-31 00:46:43 +07:00
|
|
|
currentArticle.value = {}
|
2024-05-31 12:39:53 +07:00
|
|
|
currentArticle.value = data.value.item
|
2024-05-31 00:46:43 +07:00
|
|
|
} catch (error: any) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
currentArticle,
|
|
|
|
|
getArticleById
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
import.meta.hot && import.meta.hot.accept(acceptHMRUpdate(useArticleStore, import.meta.hot));
|