code refactor

This commit is contained in:
MaysWind
2025-09-09 00:01:15 +08:00
parent 642e51bc0c
commit d4603a1892
21 changed files with 189 additions and 159 deletions
@@ -52,11 +52,11 @@ export interface CommonAccountBalanceTrendsChartProps {
export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) {
const {
getCalendarShortYearFromUnixTime,
getCalendarShortYearMonthFromUnixTime,
getCalendarYearQuarterFromUnixTime,
getCalendarFiscalYearFromUnixTime,
formatUnixTimeToShortDate
formatUnixTimeToShortDate,
formatUnixTimeToGregorianLikeShortYear,
formatUnixTimeToGregorianLikeShortYearMonth,
formatUnixTimeToGregorianLikeYearQuarter,
formatUnixTimeToGregorianLikeFiscalYear
} = useI18n();
const dataDateRange = computed<AccountBalanceUnixTimeAndBalanceRange | null>(() => {
@@ -156,13 +156,13 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
let displayDate = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
displayDate = getCalendarShortYearFromUnixTime(dateRange.minUnixTime);
displayDate = formatUnixTimeToGregorianLikeShortYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) {
displayDate = getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime);
displayDate = formatUnixTimeToGregorianLikeFiscalYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) {
displayDate = getCalendarYearQuarterFromUnixTime(dateRange.minUnixTime);
displayDate = formatUnixTimeToGregorianLikeYearQuarter(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.Month.type) {
displayDate = getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime);
displayDate = formatUnixTimeToGregorianLikeShortYearMonth(dateRange.minUnixTime);
} else {
displayDate = formatUnixTimeToShortDate(dateRange.minUnixTime);
}
@@ -37,7 +37,7 @@ function getFiscalYearStartFromProps(props: CommonFiscalYearStartSelectionProps)
}
export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) {
const { getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay } = useI18n();
const { formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n();
const disabledDates = (date: Date) => {
// Disable February 29 (leap day)
@@ -71,7 +71,7 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele
fiscalYearStart = FiscalYearStart.Default;
}
return getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(fiscalYearStart.toMonthDashDayString());
return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString());
});
const allowedMinDate = computed<Date>(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime()));
@@ -49,7 +49,7 @@ function getMonthRangeFromProps(props: CommonMonthRangeSelectionProps): { minDat
}
export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps) {
const { getCalendarLongYearMonthFromUnixTime } = useI18n();
const { formatUnixTimeToGregorianLikeLongYearMonth } = useI18n();
const { minDate, maxDate } = getMonthRangeFromProps(props);
const dateRange = ref<Year0BasedMonth[]>([
@@ -57,8 +57,8 @@ export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps
maxDate
]);
const beginDateTime = computed<string>(() => getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(dateRange.value[0])));
const endDateTime = computed<string>(() => getCalendarLongYearMonthFromUnixTime(getYearMonthLastUnixTime(dateRange.value[1])));
const beginDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(dateRange.value[0])));
const endDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthLastUnixTime(dateRange.value[1])));
function getFinalMonthRange(): { minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | '' } | null {
if (!dateRange.value[0] || !dateRange.value[1]) {