code refactor

This commit is contained in:
MaysWind
2025-01-13 21:59:09 +08:00
parent c1f94a4499
commit 9026c526f8
@@ -104,6 +104,7 @@ const transactionTagsStore = useTransactionTagsStore();
const selectedItemIds = ref<string[]>(copyArrayTo(props.modelValue, [])); const selectedItemIds = ref<string[]>(copyArrayTo(props.modelValue, []));
const newTag = ref<TransactionTag | null>(null); const newTag = ref<TransactionTag | null>(null);
const heightClass = ref<string>(getHeightClass());
const allTags = computed<TransactionTag[]>(() => transactionTagsStore.allTransactionTags); const allTags = computed<TransactionTag[]>(() => transactionTagsStore.allTransactionTags);
@@ -119,15 +120,15 @@ const noAvailableTag = computed<boolean>(() => {
return true; return true;
}); });
const heightClass = computed<string>(() => { function getHeightClass(): string {
if (transactionTagsStore.allTransactionTags && transactionTagsStore.allTransactionTags.length > 10) { if (transactionTagsStore.allTransactionTags && transactionTagsStore.allTransactionTags.length > 8) {
return 'tag-selection-huge-sheet'; return 'tag-selection-huge-sheet';
} else if (transactionTagsStore.allTransactionTags && transactionTagsStore.allTransactionTags.length > 6) { } else if (transactionTagsStore.allTransactionTags && transactionTagsStore.allTransactionTags.length > 4) {
return 'tag-selection-large-sheet'; return 'tag-selection-large-sheet';
} else { } else {
return ''; return '';
} }
}); }
function isChecked(itemId: string): boolean { function isChecked(itemId: string): boolean {
return selectedItemIds.value.indexOf(itemId) >= 0; return selectedItemIds.value.indexOf(itemId) >= 0;