diff --git a/src/api/index.ts b/src/api/index.ts index edde93ef..272b9621 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -26,6 +26,13 @@ export async function fetchPostsList( return request.get(`/posts/${currentPage}.json`) } +// GET /api/posts/:pageNum.json (default 1.json) +export async function fetchArchivesList( + currentPage: number +): Promise> { + return request.get(`/archives/${currentPage}.json`) +} + // GET /api/tags/:TagName.json export async function fetchPostsListByTag( tagName: string diff --git a/src/stores/post.ts b/src/stores/post.ts index 43ba72b6..385773c3 100644 --- a/src/stores/post.ts +++ b/src/stores/post.ts @@ -11,7 +11,8 @@ import { fetchPostsList, fetchPostBySlug, fetchPostsListByCategory, - fetchPostsListByTag + fetchPostsListByTag, + fetchArchivesList } from '@/api' export const usePostStore = defineStore({ @@ -52,7 +53,7 @@ export const usePostStore = defineStore({ }, async fetchArchives(page?: number): Promise { if (!page) page = 1 - const { data } = await fetchPostsList(page) + const { data } = await fetchArchivesList(page) return new Promise(resolve => setTimeout(() => { resolve(new Archives(data))