feat:重构模块

This commit is contained in:
2025-10-08 22:06:39 +08:00
parent f60d78fe8b
commit 2e81e57774
222 changed files with 2267 additions and 3059 deletions

58
src/views/food/recipe.vue Normal file
View File

@@ -0,0 +1,58 @@
<template>
<div ref="foodRecipeRef" class="mobile-food-view common-mobile-view">
<food-query />
<div class="food-list">
<el-empty v-if="foodStore.foodRecipeList.length === 0" description="暂无美食记录"/>
<div v-else class="list">
<food-card v-for="(item, index) in foodStore.foodRecipeList"
:key="index" :food-item="item"/>
</div>
</div>
<arrive-bottom v-if="foodStore.isScrollEnd"/>
</div>
</template>
<script lang="ts" setup>
import FoodQuery from '@/components/Food/FoodQuery.vue'
import FoodCard from '@/components/Food/FoodCard.vue'
import ArriveBottom from '@/components/Common/ArriveButton.vue'
import { useFoodStore } from '@/store/food.ts'
import { onBeforeUnmount, onMounted, ref } from 'vue'
const foodRecipeRef = ref()
const foodStore = useFoodStore()
onMounted(async () => {
foodStore.pageInfo = {
currentPage: 1,
pageSize: 3,
totalSize: 1
}
foodStore.foodRecipeList = []
await foodStore.queryMobileFoodRecipeList()
foodRecipeRef.value.addEventListener('scroll', handleScroll)
})
onBeforeUnmount(() => {
foodRecipeRef.value.removeEventListener('scroll', handleScroll)
})
const handleScroll = () => {
const el = foodRecipeRef.value
if (el.scrollTop + el.clientHeight >= el.scrollHeight - 10) {
const { currentPage, pageSize, totalSize } = foodStore.pageInfo
foodStore.isScrollEnd = pageSize * currentPage > totalSize
if (!foodStore.isScrollEnd) {
foodStore.pageInfo.currentPage++
foodStore.queryMobileFoodRecipeList()
}
}
}
</script>
<style lang="scss">
@use "@/styles/home/food.mobile.module";
</style>