code refactor

This commit is contained in:
MaysWind
2024-11-08 17:47:40 +08:00
parent 9a009b73dc
commit 01bc9becc0
9 changed files with 167 additions and 111 deletions
+6 -16
View File
@@ -201,6 +201,10 @@ import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import {
isNoAvailableCategory,
getAvailableCategoryCount
} from '@/lib/category.js';
import { getNavSideBarOuterHeight } from '@/lib/ui.desktop.js';
import {
@@ -278,27 +282,13 @@ export default {
}
},
noAvailableCategory() {
for (let i = 0; i < this.categories.length; i++) {
if (this.showHidden || !this.categories[i].hidden) {
return false;
}
}
return true;
return isNoAvailableCategory(this.categories, this.showHidden);
},
noCategory() {
return this.categories.length < 1;
},
availableCategoryCount() {
let count = 0;
for (let i = 0; i < this.categories.length; i++) {
if (this.showHidden || !this.categories[i].hidden) {
count++;
}
}
return count;
return getAvailableCategoryCount(this.categories, this.showHidden);
}
},
created() {