refactor(project): Reorganize frontend and backend directories

This commit is contained in:
2026-03-18 10:45:15 +08:00
parent cc9eaf4cdf
commit 92a139e470
513 changed files with 28251 additions and 287 deletions
@@ -0,0 +1,94 @@
<template>
<div class="favorite-page">
<van-nav-bar title="我的收藏" fixed placeholder left-arrow @click-left="router.back()" />
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list
v-model:loading="loading"
:finished="finished"
finished-text="没有更多了"
@load="loadMore"
>
<van-cell-group v-if="favorites.length" inset>
<van-cell
v-for="fav in favorites"
:key="fav.id"
:title="fav.name"
:label="`${fav.videoCount}个视频`"
is-link
@click="goToFavorite(fav.id)"
>
<template #icon>
<van-icon name="star" class="fav-icon" />
</template>
</van-cell>
</van-cell-group>
<van-empty v-else description="暂无收藏夹" />
</van-list>
</van-pull-refresh>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { showToast } from 'vant'
import { favoriteApi, type Favorite } from '@/api/favorite.ts'
const router = useRouter()
const favorites = ref<Favorite[]>([])
const loading = ref(false)
const finished = ref(false)
const refreshing = ref(false)
const currentPage = ref(1)
const loadFavorites = async (isRefresh = false) => {
if (isRefresh) {
currentPage.value = 1
favorites.value = []
finished.value = false
}
loading.value = true
try {
const data = await favoriteApi.getList()
favorites.value = data
finished.value = true
} catch (error) {
showToast('加载失败')
} finally {
loading.value = false
refreshing.value = false
}
}
const loadMore = () => {
if (!finished.value) loadFavorites()
}
const onRefresh = () => {
loadFavorites(true)
}
const goToFavorite = (id: number) => {
router.push(`/favorite/${id}`)
}
onMounted(() => {
loadFavorites()
})
</script>
<style scoped lang="scss">
.favorite-page {
min-height: 100vh;
background: #f5f5f5;
padding-bottom: 60px;
.fav-icon {
color: #f7ba2a;
margin-right: 8px;
font-size: 20px;
}
}
</style>