code refactor

This commit is contained in:
MaysWind
2025-01-18 22:45:16 +08:00
parent 20e95e35aa
commit c675057ab1
17 changed files with 58 additions and 68 deletions
+9 -9
View File
@@ -39,15 +39,6 @@ import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transac
import { removeAll } from '@/lib/common.ts';
import logger from '@/lib/logger.ts';
const {
tt,
getCurrentDecimalSeparator,
getCurrentDigitGroupingSymbol,
parseAmount,
formatAmount,
getAmountPrependAndAppendText
} = useI18n();
const props = defineProps<{
class?: string;
color?: string;
@@ -68,6 +59,15 @@ const emit = defineEmits<{
(e: 'update:modelValue', value: number): void;
}>();
const {
tt,
getCurrentDecimalSeparator,
getCurrentDigitGroupingSymbol,
parseAmount,
formatAmount,
getAmountPrependAndAppendText
} = useI18n();
const rules = [
(v: string) => {
if (v === '') {
@@ -56,9 +56,9 @@
import { computed, watch } from 'vue';
import { useTheme } from 'vuetify';
import { useI18n } from '@/locales/helpers.ts';
import { type CommonDateRangeSelectionProps, useDateRangeSelectionBase } from '@/components/base/DateRangeSelectionBase.ts';
import { useI18n } from '@/locales/helpers.ts';
import { useUserStore } from '@/stores/user.ts';
import { ThemeType } from '@/core/theme.ts';
@@ -82,12 +82,12 @@ const emit = defineEmits<{
}>();
const theme = useTheme();
const { tt, getMonthShortName } = useI18n();
const { yearRange, dateRange, dayNames, isYearFirst, is24Hour, beginDateTime, endDateTime, presetRanges, getFinalDateRange } = useDateRangeSelectionBase(props);
const userStore = useUserStore();
const { yearRange, dateRange, dayNames, isYearFirst, is24Hour, beginDateTime, endDateTime, presetRanges, getFinalDateRange } = useDateRangeSelectionBase(props);
const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType.Dark);
const firstDayOfWeek = computed<number>(() => userStore.currentUserFirstDayOfWeek);
const showState = computed<boolean>({
@@ -67,9 +67,8 @@
import { computed, watch } from 'vue';
import { useTheme } from 'vuetify';
import { type CommonMonthRangeSelectionProps, useMonthRangeSelectionBase } from '@/components/base/MonthRangeSelectionBase.ts';
import { useI18n } from '@/locales/helpers.ts';
import { type CommonMonthRangeSelectionProps, useMonthRangeSelectionBase } from '@/components/base/MonthRangeSelectionBase.ts';
import { ThemeType } from '@/core/theme.ts';
import { getYearMonthObjectFromString } from '@/lib/datetime.ts';
@@ -86,8 +85,8 @@ const emit = defineEmits<{
}>();
const theme = useTheme();
const { tt, getMonthShortName } = useI18n();
const { tt, getMonthShortName } = useI18n();
const { yearRange, dateRange, isYearFirst, beginDateTime, endDateTime, getFinalMonthRange } = useMonthRangeSelectionBase(props);
const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType.Dark);
@@ -57,9 +57,8 @@
<script setup lang="ts">
import { ref, computed, nextTick, useTemplateRef } from 'vue';
import { type CommonScheduleFrequencySelectionProps, useScheduleFrequencySelectionBase } from '@/components/base/ScheduleFrequencySelectionBase.ts';
import { useI18n } from '@/locales/helpers.ts';
import { type CommonScheduleFrequencySelectionProps, useScheduleFrequencySelectionBase } from '@/components/base/ScheduleFrequencySelectionBase.ts';
import { useUserStore } from '@/stores/user.ts';
@@ -74,11 +73,10 @@ const emit = defineEmits<{
}>();
const { tt, getMultiMonthdayShortNames, getMultiWeekdayLongNames } = useI18n();
const { allTransactionScheduledFrequencyTypes, allWeekDays, allAvailableMonthDays, getFrequencyValues } = useScheduleFrequencySelectionBase();
const userStore = useUserStore();
const { allTransactionScheduledFrequencyTypes, allWeekDays, allAvailableMonthDays, getFrequencyValues } = useScheduleFrequencySelectionBase();
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
const menuState = ref<boolean>(false);