From 8f6adaa4179f1c85777e3672c74a82821a91d38f Mon Sep 17 00:00:00 2001 From: MaysWind Date: Fri, 29 Aug 2025 00:18:46 +0800 Subject: [PATCH] fix some numerals were not displayed according to the numerical system --- src/components/base/DateTimeSelectionBase.ts | 15 ++++-- src/components/desktop/PaginationButtons.vue | 24 ++++++---- src/components/desktop/StepsBar.vue | 15 +++++- src/core/base.ts | 5 ++ src/lib/datetime.ts | 12 ++--- src/locales/helpers.ts | 29 +++++++----- .../transactions/TransactionEditPageBase.ts | 9 +++- .../transactions/TransactionListPageBase.ts | 9 +++- src/views/desktop/HomePage.vue | 8 +++- .../dialogs/ReconciliationStatementDialog.vue | 24 +++++----- src/views/desktop/transactions/ListPage.vue | 27 +++++++++-- .../transactions/import/ImportDialog.vue | 47 ++++++++++--------- src/views/mobile/transactions/EditPage.vue | 4 +- 13 files changed, 145 insertions(+), 83 deletions(-) diff --git a/src/components/base/DateTimeSelectionBase.ts b/src/components/base/DateTimeSelectionBase.ts index 9ce10dc7..9c51afa0 100644 --- a/src/components/base/DateTimeSelectionBase.ts +++ b/src/components/base/DateTimeSelectionBase.ts @@ -3,6 +3,7 @@ import { ref, computed } from 'vue'; import { useI18n } from '@/locales/helpers.ts'; import { type NameValue } from '@/core/base.ts'; +import { NumeralSystem } from '@/core/numeral.ts'; export interface TimePickerValue { value: string; @@ -12,6 +13,7 @@ export interface TimePickerValue { export function useDateTimeSelectionBase() { const { getAllMeridiemIndicators, + getCurrentNumeralSystemType, isLongTime24HourFormat, isLongTimeMeridiemIndicatorFirst, isLongTimeHourTwoDigits, @@ -25,14 +27,17 @@ export function useDateTimeSelectionBase() { const isSecondTwoDigits = ref(isLongTimeSecondTwoDigits()); const isMeridiemIndicatorFirst = ref(isLongTimeMeridiemIndicatorFirst() || false); + const numeralSystem = computed(() => getCurrentNumeralSystemType()); const meridiemItems = computed(() => getAllMeridiemIndicators()); function getDisplayTimeValue(value: number, forceTwoDigits: boolean): string { - if (forceTwoDigits && value < 10) { - return `0${value}`; - } else { - return value.toString(); + let textualValue = value.toString(); + + if (forceTwoDigits) { + textualValue = textualValue.padStart(2, NumeralSystem.WesternArabicNumerals.digitZero); } + + return numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(textualValue); } function generateAllHours(count: number, forceTwoDigits: boolean): TimePickerValue[] { @@ -43,7 +48,7 @@ export function useDateTimeSelectionBase() { for (let i = 0; i < count; i++) { if (!is24Hour.value) { ret.push({ - value: '12', + value: getDisplayTimeValue(12, forceTwoDigits), itemsIndex: i }); } diff --git a/src/components/desktop/PaginationButtons.vue b/src/components/desktop/PaginationButtons.vue index b85aff56..27f484db 100644 --- a/src/components/desktop/PaginationButtons.vue +++ b/src/components/desktop/PaginationButtons.vue @@ -13,7 +13,7 @@ @click="currentPage = parseInt(page)" v-if="page !== '...'" > - {{ page }} + {{ getDisplayPage(page) }} (); -const { tt } = useI18n(); +const { tt, getCurrentNumeralSystemType } = useI18n(); const showMenus = ref>({}); -const allPages = computed<{ page: number }[]>(() => { - const pages = []; +const numeralSystem = computed(() => getCurrentNumeralSystemType()); + +function getDisplayPage(page: number | string): string { + return numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(page.toString()); +} + +const allPages = computed(() => { + const pages: NameNumeralValue[] = []; for (let i = 1; i <= props.totalPageCount; i++) { - pages.push({ - page: i - }); + pages.push({ value: i, name: getDisplayPage(i) }); } return pages; diff --git a/src/components/desktop/StepsBar.vue b/src/components/desktop/StepsBar.vue index 88edf412..4f485d90 100644 --- a/src/components/desktop/StepsBar.vue +++ b/src/components/desktop/StepsBar.vue @@ -10,7 +10,7 @@
-

{{ `0${idx + 1}` }}

+

{{ getDisplayStep(idx + 1) }}

{{ step.title }}
@@ -31,7 +31,7 @@
-

{{ `0${idx + 1}` }}

+

{{ getDisplayStep(idx + 1) }}

{{ step.title }}
@@ -46,6 +46,10 @@