feat:重构模块

This commit is contained in:
2025-09-22 19:42:28 +08:00
parent b0935a05fd
commit e8a3339f43
32 changed files with 132 additions and 6542 deletions

View File

@@ -4,7 +4,7 @@ import {
IBlogLatest, IBlogNestedComment, IBlogStats, INewBlog, IQueryBlog
} from '@/types/blog'
import {
addBlogApi, addBlogCommentApi, deleteBlogApi, queryAdminBlogApi, queryAdminBlogByIdApi, queryAdminBlogCategoryApi,
addBlogApi, addBlogCommentApi, deleteBlogApi,
queryBlogApi, queryBlogByConditionApi, queryBlogByIdApi,
queryBlogCategoryApi, queryBlogCommentApi, queryBlogStatsApi, queryLatestBlogApi, updateBlogApi
} from '@/apis/blog.ts'
@@ -59,32 +59,15 @@ export const useBlogStore = defineStore('blog', {
totalSize: 1
},
isScrollEnd: false,
adminPageInfo: {
currentPage: 1,
pageSize: 10,
totalSize: 1
},
progressValue: '0%'
}),
actions: {
async queryBlog() {
async queryBlogList() {
const { currentPage, pageSize } = this.pageInfo
const result = await queryBlogApi(currentPage, pageSize)
this.blogList = result.records
this.pageInfo.totalSize = result.total
},
async queryMobileBlog() {
const { currentPage, pageSize } = this.pageInfo
const result = await queryBlogApi(currentPage, pageSize)
this.blogList.push(...result.records)
this.pageInfo.totalSize = result.total
},
async queryAdminBlog() {
const { currentPage, pageSize } = this.adminPageInfo
const result = await queryAdminBlogApi(currentPage, pageSize)
this.blogList = result.records
this.pageInfo.totalSize = result.total
},
async queryBlogByCondition(query: IQueryBlog) {
this.blogList = await queryBlogByConditionApi(query)
},
@@ -93,8 +76,8 @@ export const useBlogStore = defineStore('blog', {
await this.queryBlogComment(this.currentBlogId)
this.blogNestedCommentList = flattenToTwoLevel(this.blogCommentList)
},
async queryAdminBlogById(id: number) {
this.currentBlog = await queryAdminBlogByIdApi(id)
async queryBlogByIdApi(id: number) {
this.currentBlog = await queryBlogByIdApi(id)
},
async queryBlogComment(blogId: number) {
this.blogCommentList = await queryBlogCommentApi(blogId)
@@ -106,9 +89,6 @@ export const useBlogStore = defineStore('blog', {
async queryBlogCategory() {
this.blogCategoryList = await queryBlogCategoryApi()
},
async queryAdminBlogCategory() {
this.blogCategoryList = await queryAdminBlogCategoryApi()
},
async queryBlogStats() {
this.blogStats = await queryBlogStatsApi()
},
@@ -136,7 +116,7 @@ export const useBlogStore = defineStore('blog', {
},
async refreshInfo() {
this.pageInfo.currentPage = 1
await this.queryBlog()
await this.queryBlogList()
await this.queryBlogStats()
await this.queryLatestBlog()
},