From 8368b02be8b3ec434bdba356d211e2456ef88c0a Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 6 Sep 2025 01:06:31 +0800 Subject: [PATCH] calendar display type supports Gregorian with Chinese --- pkg/core/calendar.go | 11 +- pkg/models/user.go | 2 +- pkg/services/users.go | 2 +- src/components/common/DateTimePicker.vue | 60 +- src/components/common/TransactionCalendar.vue | 40 +- .../desktop/DateRangeSelectionDialog.vue | 1 + src/components/desktop/DateSelect.vue | 1 + src/components/desktop/DateTimeSelect.vue | 1 + .../mobile/DateRangeSelectionSheet.vue | 1 + src/components/mobile/DateSelectionSheet.vue | 1 + .../mobile/DateTimeSelectionSheet.vue | 1 + src/core/calendar.ts | 12 +- src/core/datetime.ts | 8 +- .../calendar/__tests__/chinese_calendar.ts | 152 + .../__tests__/chinese_calendar_all_data.txt | 36893 ++++++++++++++++ src/lib/calendar/chinese_calendar.ts | 431 + src/lib/calendar/chinese_calendar_data.ts | 455 + src/lib/datetime.ts | 58 +- src/locales/calendar/chinese/index.ts | 14 + src/locales/calendar/chinese/zh_Hans.json | 88 + src/locales/calendar/chinese/zh_Hant.json | 88 + src/locales/de.json | 3 +- src/locales/en.json | 3 +- src/locales/es.json | 3 +- src/locales/helpers.ts | 84 +- src/locales/it.json | 3 +- src/locales/ja.json | 3 +- src/locales/nl.json | 3 +- src/locales/pt_BR.json | 3 +- src/locales/ru.json | 3 +- src/locales/uk.json | 3 +- src/locales/vi.json | 3 +- src/locales/zh_Hans.json | 5 +- src/locales/zh_Hant.json | 5 +- src/stores/user.ts | 5 +- src/styles/mobile/font-size-default.scss | 3 + src/styles/mobile/font-size-large.scss | 3 + src/styles/mobile/font-size-small.scss | 3 + src/styles/mobile/font-size-x-large.scss | 3 + src/styles/mobile/font-size-xx-large.scss | 3 + src/styles/mobile/font-size-xxx-large.scss | 3 + src/styles/mobile/font-size-xxxx-large.scss | 3 + src/styles/mobile/global.scss | 4 + src/views/desktop/transactions/ListPage.vue | 12 + src/views/mobile/transactions/ListPage.vue | 8 + 45 files changed, 38451 insertions(+), 43 deletions(-) create mode 100644 src/lib/calendar/__tests__/chinese_calendar.ts create mode 100644 src/lib/calendar/__tests__/chinese_calendar_all_data.txt create mode 100644 src/lib/calendar/chinese_calendar.ts create mode 100644 src/lib/calendar/chinese_calendar_data.ts create mode 100644 src/locales/calendar/chinese/index.ts create mode 100644 src/locales/calendar/chinese/zh_Hans.json create mode 100644 src/locales/calendar/chinese/zh_Hant.json diff --git a/pkg/core/calendar.go b/pkg/core/calendar.go index 4aba05e2..07a34390 100644 --- a/pkg/core/calendar.go +++ b/pkg/core/calendar.go @@ -7,10 +7,11 @@ type CalendarDisplayType byte // Calendar Display Type const ( - CALENDAR_DISPLAY_TYPE_DEFAULT CalendarDisplayType = 0 - CALENDAR_DISPLAY_TYPE_GREGORAIN CalendarDisplayType = 1 - CALENDAR_DISPLAY_TYPE_BUDDHIST CalendarDisplayType = 2 - CALENDAR_DISPLAY_TYPE_INVALID CalendarDisplayType = 255 + CALENDAR_DISPLAY_TYPE_DEFAULT CalendarDisplayType = 0 + CALENDAR_DISPLAY_TYPE_GREGORAIN CalendarDisplayType = 1 + CALENDAR_DISPLAY_TYPE_BUDDHIST CalendarDisplayType = 2 + CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE CalendarDisplayType = 3 + CALENDAR_DISPLAY_TYPE_INVALID CalendarDisplayType = 255 ) // String returns a textual representation of the calendar display type enum @@ -22,6 +23,8 @@ func (f CalendarDisplayType) String() string { return "Gregorian" case CALENDAR_DISPLAY_TYPE_BUDDHIST: return "Buddhist" + case CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE: + return "Gregorian with Chinese" case CALENDAR_DISPLAY_TYPE_INVALID: return "Invalid" default: diff --git a/pkg/models/user.go b/pkg/models/user.go index cb4a2465..b984af1f 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -199,7 +199,7 @@ type UserProfileUpdateRequest struct { DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"` FirstDayOfWeek *core.WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"` FiscalYearStart *core.FiscalYearStart `json:"fiscalYearStart" binding:"omitempty,validFiscalYearStart"` - CalendarDisplayType *core.CalendarDisplayType `json:"calendarDisplayType" binding:"omitempty,min=0,max=2"` + CalendarDisplayType *core.CalendarDisplayType `json:"calendarDisplayType" binding:"omitempty,min=0,max=3"` DateDisplayType *core.DateDisplayType `json:"dateDisplayType" binding:"omitempty,min=0,max=2"` LongDateFormat *core.LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"` ShortDateFormat *core.ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"` diff --git a/pkg/services/users.go b/pkg/services/users.go index 07ab1593..dea64afc 100644 --- a/pkg/services/users.go +++ b/pkg/services/users.go @@ -293,7 +293,7 @@ func (s *UserService) UpdateUser(c core.Context, user *models.User, modifyUserLa updateCols = append(updateCols, "fiscal_year_start") } - if core.CALENDAR_DISPLAY_TYPE_DEFAULT <= user.CalendarDisplayType && user.CalendarDisplayType <= core.CALENDAR_DISPLAY_TYPE_BUDDHIST { + if core.CALENDAR_DISPLAY_TYPE_DEFAULT <= user.CalendarDisplayType && user.CalendarDisplayType <= core.CALENDAR_DISPLAY_TYPE_GREGORAIN_WITH_CHINESE { updateCols = append(updateCols, "calendar_display_type") } diff --git a/src/components/common/DateTimePicker.vue b/src/components/common/DateTimePicker.vue index 6797d98a..3b269d56 100644 --- a/src/components/common/DateTimePicker.vue +++ b/src/components/common/DateTimePicker.vue @@ -3,7 +3,7 @@ inline auto-apply enable-seconds six-weeks="center" - :class="datetimePickerClass" + :class="`datetime-picker ${showAlternateDates && alternateCalendarType ? 'datetime-picker-with-alternate-date' : ''} ${datetimePickerClass}`" :config="noSwipeAndScroll ? { noSwipe: true } : undefined" :dark="isDarkMode" :vertical="vertical" @@ -35,7 +35,10 @@ {{ getDisplayMonth(value) }}