migrate numeral.js to ts

This commit is contained in:
MaysWind
2025-01-04 14:47:52 +08:00
parent b9a3c384d9
commit 27f8c90dae
16 changed files with 269 additions and 266 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ import { useUserStore } from '@/stores/user.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
import { getConvertedAmount } from '@/lib/numeral.js';
import { getConvertedAmount } from '@/lib/numeral.ts';
export default {
data() {
@@ -334,7 +334,7 @@ import { useStatisticsStore } from '@/stores/statistics.js';
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
import statisticsConstants from '@/consts/statistics.js';
import { getNameByKeyValue, limitText } from '@/lib/common.ts';
import { formatPercent } from '@/lib/numeral.js';
import { formatPercent } from '@/lib/numeral.ts';
import {
getYearAndMonthFromUnixTime,
getYearMonthFirstUnixTime,
@@ -57,7 +57,7 @@ import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import numeralConstants from '@/consts/numeral.js';
import { AmountFilterType } from '@/core/numeral.ts';
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
import { isString } from '@/lib/common.ts';
import logger from '@/lib/logger.js';
@@ -79,7 +79,7 @@ export default {
computed: {
...mapStores(useSettingsStore, useUserStore, useTransactionsStore),
allAmountFilterTypes() {
return numeralConstants.allAmountFilterTypeArray;
return AmountFilterType.values();
},
allowedMinAmount() {
return TRANSACTION_MIN_AMOUNT;
@@ -91,24 +91,24 @@ export default {
return this.getAmountFilterParameterCount(this.type);
},
title() {
const amountFilterType = numeralConstants.allAmountFilterTypeMap[this.type];
const amountFilterType = AmountFilterType.valueOf(this.type);
return amountFilterType ? this.$t(amountFilterType.name) : this.$t('Amount');
},
amount1Header() {
if (this.type === numeralConstants.allAmountFilterType.GreaterThan.type
|| this.type === numeralConstants.allAmountFilterType.Between.type
|| this.type === numeralConstants.allAmountFilterType.NotBetween.type) {
if (this.type === AmountFilterType.GreaterThan.type
|| this.type === AmountFilterType.Between.type
|| this.type === AmountFilterType.NotBetween.type) {
return this.$t('Minimum Amount');
} else if (this.type === numeralConstants.allAmountFilterType.LessThan.type) {
} else if (this.type === AmountFilterType.LessThan.type) {
return this.$t('Maximum Amount');
} else {
return this.$t('Amount');
}
},
amount2Header() {
if (this.type === numeralConstants.allAmountFilterType.Between.type) {
if (this.type === AmountFilterType.Between.type) {
return this.$t('Maximum Amount');
} else if (this.type === numeralConstants.allAmountFilterType.NotBetween.type) {
} else if (this.type === AmountFilterType.NotBetween.type) {
return this.$t('Maximum Amount');
} else {
return this.$t('Amount');
@@ -176,7 +176,7 @@ export default {
return this.$locale.formatAmountWithCurrency(this.settingsStore, this.userStore, value, false);
},
getAmountFilterParameterCount(filterType) {
const amountFilterType = numeralConstants.allAmountFilterTypeMap[filterType];
const amountFilterType = AmountFilterType.valueOf(filterType);
return amountFilterType ? amountFilterType.paramCount : 0;
}
}
+2 -2
View File
@@ -529,9 +529,9 @@ import { useTransactionTagsStore } from '@/stores/transactionTag.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
import { AmountFilterType } from '@/core/numeral.ts';
import { AccountType } from '@/core/account.ts';
import { TransactionType } from '@/core/transaction.ts';
import numeralConstants from '@/consts/numeral.js';
import { getNameByKeyValue } from '@/lib/common.ts';
import {
getCurrentUnixTime,
@@ -677,7 +677,7 @@ export default {
return this.transactionsStore.hasMoreTransaction;
},
allAmountFilterTypes() {
return numeralConstants.allAmountFilterTypeArray;
return AmountFilterType.values();
},
allTransactionTypes() {
return TransactionType;