feat:增加查询用户菜谱记录功能
This commit is contained in:
@@ -16,16 +16,21 @@ import {
|
||||
updateRecordApi,
|
||||
queryCategoryApi,
|
||||
queryRecordStatsApi,
|
||||
queryCategoryStatsApi, queryRankStatsApi, queryRecipeApi
|
||||
queryCategoryStatsApi,
|
||||
queryRankStatsApi,
|
||||
queryRecipeApi,
|
||||
queryRecipeByUserApi,
|
||||
deleteRecipeLikeApi,
|
||||
addRecipeLikeApi,
|
||||
addRecipeCommentApi
|
||||
} from '@/apis/food.ts'
|
||||
import type { IDialog, IHandleApi, IStatsChart } from 'vue3-common/types'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getCurrentMonth, getCurrentYear, getStartEndDate } from 'vue3-common/utils/dateUtil'
|
||||
import {
|
||||
addCommentApi,
|
||||
addLikeApi,
|
||||
addMomentApi,
|
||||
deleteLikeApi,
|
||||
addMomentLikeApi,
|
||||
addMomentApi, addMomentCommentApi,
|
||||
deleteMomentLikeApi,
|
||||
deleteMomentApi, queryMomentByIdApi,
|
||||
queryMomentListApi,
|
||||
updateMomentApi
|
||||
@@ -42,7 +47,11 @@ export const useFoodStore = defineStore('food', {
|
||||
remark: '',
|
||||
materialList: [],
|
||||
stepList: [],
|
||||
recordList: []
|
||||
recordList: [],
|
||||
likeCount: 0,
|
||||
likeList: [],
|
||||
commentCount: 0,
|
||||
commentList: []
|
||||
} as IRecipe,
|
||||
recordList: [] as IRecord[],
|
||||
currentRecord: {
|
||||
@@ -119,6 +128,11 @@ export const useFoodStore = defineStore('food', {
|
||||
this.isRefresh = !this.isRefresh
|
||||
this.isLoading = false
|
||||
},
|
||||
async queryRecipeByUser(id: number) {
|
||||
this.isLoading = true
|
||||
this.recipeList = await queryRecipeByUserApi(id)
|
||||
this.isLoading = false
|
||||
},
|
||||
async queryRecordList() {
|
||||
const { year, month } = this.queryRecord
|
||||
const date = this.queryDateType === 'year' ? year : month
|
||||
@@ -211,20 +225,36 @@ export const useFoodStore = defineStore('food', {
|
||||
}
|
||||
await this.queryMomentList()
|
||||
},
|
||||
async addComment(id: number, content: string) {
|
||||
await addCommentApi(id, content)
|
||||
async addMomentComment(id: number, content: string) {
|
||||
await addMomentCommentApi(id, content)
|
||||
await this.queryMomentList()
|
||||
},
|
||||
async addLike(id: number) {
|
||||
await addLikeApi(id)
|
||||
async addMomentLike(id: number) {
|
||||
await addMomentLikeApi(id)
|
||||
await this.queryMomentList()
|
||||
},
|
||||
async deleteLike(id: number) {
|
||||
await deleteLikeApi(id)
|
||||
async deleteMomentLike(id: number) {
|
||||
await deleteMomentLikeApi(id)
|
||||
await this.queryMomentList()
|
||||
},
|
||||
async addRecipeComment(id: number, content: string) {
|
||||
await addRecipeCommentApi(id, content)
|
||||
await this.queryRecipe(this.currentRecipe.id as number)
|
||||
},
|
||||
async addRecipeLike(id: number) {
|
||||
await addRecipeLikeApi(id)
|
||||
await this.queryRecipe(this.currentRecipe.id as number)
|
||||
},
|
||||
async deleteRecipeLike(id: number) {
|
||||
await deleteRecipeLikeApi(id)
|
||||
await this.queryRecipe(this.currentRecipe.id as number)
|
||||
},
|
||||
getEmptyRecipe(): IRecipe {
|
||||
return {
|
||||
commentCount: 0,
|
||||
commentList: [],
|
||||
likeCount: 0,
|
||||
likeList: [],
|
||||
category: '',
|
||||
materialList: [],
|
||||
name: '',
|
||||
|
||||
Reference in New Issue
Block a user