code refactor

This commit is contained in:
MaysWind
2025-08-29 00:43:34 +08:00
parent 8f6adaa417
commit b79ffafaee
7 changed files with 49 additions and 54 deletions
+6 -6
View File
@@ -160,7 +160,7 @@ import ConfirmDialog from '@/components/desktop/ConfirmDialog.vue';
import SnackBar from '@/components/desktop/SnackBar.vue';
import UpdateDialog from './list/dialogs/UpdateDialog.vue';
import { ref, useTemplateRef, watch } from 'vue';
import { ref, computed, useTemplateRef, watch } from 'vue';
import { useDisplay } from 'vuetify';
import { useI18n } from '@/locales/helpers.ts';
@@ -212,6 +212,8 @@ const customExchangeRateRemoving = ref<Record<string, boolean>>({});
const alwaysShowNav = ref<boolean>(mdAndUp.value);
const showNav = ref<boolean>(mdAndUp.value);
const numeralSystem = computed<NumeralSystem>(() => getCurrentNumeralSystemType());
function reload(force: boolean): void {
loading.value = true;
@@ -286,11 +288,9 @@ function remove(currency: string): void {
}
function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, displayLocalizedDigits: boolean): string {
const numeralSystem = getCurrentNumeralSystemType();
if (!baseCurrency.value) {
if (displayLocalizedDigits) {
return numeralSystem.digitZero;
return numeralSystem.value.digitZero;
} else {
return NumeralSystem.WesternArabicNumerals.digitZero;
}
@@ -308,7 +308,7 @@ function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, di
if (!exchangeRateAmount) {
if (displayLocalizedDigits) {
return numeralSystem.digitZero;
return numeralSystem.value.digitZero;
} else {
return NumeralSystem.WesternArabicNumerals.digitZero;
}
@@ -317,7 +317,7 @@ function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, di
let ret = formatExchangeRateAmountToWesternArabicNumerals(exchangeRateAmount);
if (displayLocalizedDigits) {
ret = numeralSystem.replaceWesternArabicDigitsToLocalizedDigits(ret);
ret = numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(ret);
}
return ret;
+3 -3
View File
@@ -185,6 +185,7 @@ const customExchangeRateToDelete = ref<LocalizedLatestExchangeRate | null>(null)
const showDeleteActionSheet = ref<boolean>(false);
const textDirection = computed<TextDirection>(() => getCurrentLanguageTextDirection());
const numeralSystem = computed<NumeralSystem>(() => getCurrentNumeralSystemType());
const displayBaseAmount = computed<string>(() => formatAmountToLocalizedNumerals(baseAmount.value, baseCurrency.value));
const baseAmountFontSizeClass = computed<string>(() => {
if (baseAmount.value >= 100000000 || baseAmount.value <= -100000000) {
@@ -275,13 +276,12 @@ function remove(customExchangeRate: LocalizedLatestExchangeRate | null, confirm:
}
function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, displayLocalizedDigits: boolean): string {
const numeralSystem = getCurrentNumeralSystemType();
const fromExchangeRate = exchangeRatesStore.latestExchangeRateMap[baseCurrency.value];
const exchangeRateAmount = getConvertedAmount(baseAmount.value / 100, fromExchangeRate, toExchangeRate);
if (!exchangeRateAmount) {
if (displayLocalizedDigits) {
return numeralSystem.digitZero;
return numeralSystem.value.digitZero;
} else {
return NumeralSystem.WesternArabicNumerals.digitZero;
}
@@ -290,7 +290,7 @@ function getFinalConvertedAmount(toExchangeRate: LocalizedLatestExchangeRate, di
let ret = formatExchangeRateAmountToWesternArabicNumerals(exchangeRateAmount);
if (displayLocalizedDigits) {
ret = numeralSystem.replaceWesternArabicDigitsToLocalizedDigits(ret);
ret = numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(ret);
}
return ret;