fix: 优化分类列表显示逻辑,简化分类视图计算
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 18s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
孙诚
2026-01-12 14:46:11 +08:00
parent 694925e326
commit 8c7dbd24ad

View File

@@ -102,9 +102,9 @@
</div>
<!-- 分类列表 -->
<div v-if="expenseCategoriesView.length > 0" class="category-list">
<div v-if="expenseCategoriesSimpView.length > 0" class="category-list">
<div
v-for="(category) in expenseCategoriesView"
v-for="(category) in expenseCategoriesSimpView"
:key="category.isOther ? 'other' : category.classify"
class="category-item clickable"
@click="category.isOther ? (showAllExpense = true) : goToCategoryBills(category.classify, 0)"
@@ -386,13 +386,8 @@ const expenseCategories = ref([])
const incomeCategories = ref([])
const noneCategories = ref([])
const expenseCategoriesView = computed(() => {
const list = [...expenseCategories.value]
const unclassifiedIndex = list.findIndex(c => !c.classify)
if (unclassifiedIndex !== -1) {
const [unclassified] = list.splice(unclassifiedIndex, 1)
list.unshift(unclassified)
}
const expenseCategoriesSimpView = computed(() => {
const list = expenseCategoriesView.value
if (showAllExpense.value || list.length <= 7) return list
@@ -409,6 +404,17 @@ const expenseCategoriesView = computed(() => {
return top
})
const expenseCategoriesView = computed(() => {
const list = [...expenseCategories.value]
const unclassifiedIndex = list.findIndex(c => !c.classify)
if (unclassifiedIndex !== -1) {
const [unclassified] = list.splice(unclassifiedIndex, 1)
list.unshift(unclassified)
}
return list
})
const incomeCategoriesView = computed(() => {
const list = [...incomeCategories.value]
const unclassifiedIndex = list.findIndex(c => !c.classify)