migrate consts/datetime.js to ts

This commit is contained in:
MaysWind
2025-01-02 00:31:28 +08:00
parent 5525635df1
commit ad9a390b58
22 changed files with 633 additions and 665 deletions
+3 -3
View File
@@ -91,7 +91,7 @@
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import datetimeConstants from '@/consts/datetime.js';
import { DateRangeScene } from '@/core/datetime.ts';
import statisticsConstants from '@/consts/statistics.js';
export default {
@@ -110,13 +110,13 @@ export default {
return this.$locale.getAllCategoricalChartTypes();
},
allCategoricalChartDateRanges() {
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.Normal, false);
return this.$locale.getAllDateRanges(DateRangeScene.Normal, false);
},
allTrendChartTypes() {
return this.$locale.getAllTrendChartTypes();
},
allTrendChartDateRanges() {
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.TrendAnalysis, false);
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, false);
},
defaultChartDataType: {
get: function () {
@@ -331,7 +331,7 @@ import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import datetimeConstants from '@/consts/datetime.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';
@@ -458,13 +458,13 @@ export default {
return this.$locale.getAllStatisticsDateAggregationTypes();
},
allDateRanges() {
return datetimeConstants.allDateRanges;
return DateRange.all();
},
allDateRangesArray() {
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.Normal, true);
return this.$locale.getAllDateRanges(DateRangeScene.Normal, true);
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.TrendAnalysis, true);
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, true);
} else {
return [];
}
@@ -711,7 +711,7 @@ export default {
let changed = false;
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
changed = this.statisticsStore.updateTransactionStatisticsFilter({
categoricalChartDateType: chartDateType,
@@ -721,7 +721,7 @@ export default {
this.showCustomDateRangeSheet = false;
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.TrendAnalysis);
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
this.statisticsStore.updateTransactionStatisticsFilter({
trendChartDateType: chartDateType,
@@ -766,7 +766,7 @@ export default {
let changed = false;
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
const newDateRange = getShiftedDateRangeAndDateType(query.categoricalChartStartTime, query.categoricalChartEndTime, scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
const newDateRange = getShiftedDateRangeAndDateType(query.categoricalChartStartTime, query.categoricalChartEndTime, scale, this.firstDayOfWeek, DateRangeScene.Normal);
changed = this.statisticsStore.updateTransactionStatisticsFilter({
categoricalChartDateType: newDateRange.dateType,
@@ -774,7 +774,7 @@ export default {
categoricalChartEndTime: newDateRange.maxTime
});
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth), scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.TrendAnalysis);
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth), scale, this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
changed = this.statisticsStore.updateTransactionStatisticsFilter({
trendChartDateType: newDateRange.dateType,