-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用pinia和路由首位修复切换页面时滚动条不回滚的bug已经完成分类和标签页的默认选中第一个效果
- Loading branch information
Showing
5 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
import { defineStore } from 'pinia' | ||
|
||
|
||
import { getTags } from "@/request/api/getTagInfo" | ||
import { getCategories } from "@/request/api/getCategoryInfo" | ||
export const useBlogStore = defineStore("blog", { | ||
state: () => { | ||
return { | ||
// 博客数据是否获取完成 | ||
isBlogDataLoaded: false | ||
isBlogDataLoaded: false, | ||
// 标签页的首个数据 | ||
firstTag: "", | ||
// 分类页的首个数据 | ||
firstCategory: "", | ||
} | ||
|
||
}, | ||
actions: { | ||
async getFirstTag() { | ||
const res = await getTags() | ||
this.firstTag = res.data.data[0].tag | ||
}, | ||
async getFirstCategory() { | ||
const res = await getCategories() | ||
this.firstCategory = res.data.data[0].category | ||
}, | ||
} | ||
}) |