From c619d2ecad54a7cf15800353b38f8204a1130271 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 25 Jan 2025 14:55:40 +0800 Subject: [PATCH] code refactor --- src/components/mobile/ListItemSelectionSheet.vue | 2 +- src/components/mobile/ScheduleFrequencySheet.vue | 6 +++--- src/components/mobile/TreeViewSelectionSheet.vue | 2 +- .../mobile/TwoColumnListItemSelectionSheet.vue | 4 ++-- src/lib/datetime.ts | 4 ++-- src/lib/ui/mobile.ts | 2 +- src/locales/helpers.ts | 14 +++++++------- src/stores/overview.ts | 2 +- .../categories/list/dialogs/PresetDialog.vue | 2 +- src/views/mobile/SettingsPage.vue | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/mobile/ListItemSelectionSheet.vue b/src/components/mobile/ListItemSelectionSheet.vue index 488b4ec7..2ffeea57 100644 --- a/src/components/mobile/ListItemSelectionSheet.vue +++ b/src/components/mobile/ListItemSelectionSheet.vue @@ -94,7 +94,7 @@ function getItemValue(item: unknown, index: number, fieldName: string | undefine } } -function close() { +function close(): void { emit('update:show', false); } diff --git a/src/components/mobile/ScheduleFrequencySheet.vue b/src/components/mobile/ScheduleFrequencySheet.vue index 563b82a2..08e4fc8f 100644 --- a/src/components/mobile/ScheduleFrequencySheet.vue +++ b/src/components/mobile/ScheduleFrequencySheet.vue @@ -136,13 +136,13 @@ function changeFrequencyValue(e: Event): void { } } -function save() { +function save(): void { emit('update:type', currentFrequencyType.value); emit('update:modelValue', sortNumbersArray(currentFrequencyValue.value).join(',')); emit('update:show', false); } -function close() { +function close(): void { emit('update:show', false); } @@ -152,7 +152,7 @@ function onSheetOpen(event: { $el: Framework7Dom }): void { scrollToSelectedItem(event.$el, '.schedule-frequency-value-container', 'li.list-item-selected'); } -function onSheetClosed() { +function onSheetClosed(): void { close(); } diff --git a/src/components/mobile/TreeViewSelectionSheet.vue b/src/components/mobile/TreeViewSelectionSheet.vue index 8377e991..0b19558e 100644 --- a/src/components/mobile/TreeViewSelectionSheet.vue +++ b/src/components/mobile/TreeViewSelectionSheet.vue @@ -151,7 +151,7 @@ function onSheetOpen(event: { $el: Framework7Dom }): void { scrollToSelectedItem(event.$el, '.page-content', '.treeview-item .treeview-item-selected'); } -function onSheetClosed() { +function onSheetClosed(): void { emit('update:show', false); } diff --git a/src/components/mobile/TwoColumnListItemSelectionSheet.vue b/src/components/mobile/TwoColumnListItemSelectionSheet.vue index fd08db06..2270292d 100644 --- a/src/components/mobile/TwoColumnListItemSelectionSheet.vue +++ b/src/components/mobile/TwoColumnListItemSelectionSheet.vue @@ -133,7 +133,7 @@ const selectedPrimaryItem = computed(() => { } }); -function close() { +function close(): void { emit('update:show', false); } @@ -163,7 +163,7 @@ function onSheetOpen(event: { $el: Framework7Dom }): void { scrollToSelectedItem(event.$el, '.secondary-list-container', 'li.secondary-list-item-selected'); } -function onSheetClosed() { +function onSheetClosed(): void { close(); } diff --git a/src/lib/datetime.ts b/src/lib/datetime.ts index 3a452384..d1060c31 100644 --- a/src/lib/datetime.ts +++ b/src/lib/datetime.ts @@ -143,11 +143,11 @@ export function getTimezoneOffsetMinutes(timezone?: string): number { } } -export function getBrowserTimezoneOffset() { +export function getBrowserTimezoneOffset(): string { return getUtcOffsetByUtcOffsetMinutes(getBrowserTimezoneOffsetMinutes()); } -export function getBrowserTimezoneOffsetMinutes() { +export function getBrowserTimezoneOffsetMinutes(): number { return -new Date().getTimezoneOffset(); } diff --git a/src/lib/ui/mobile.ts b/src/lib/ui/mobile.ts index f2635617..d7bd4c3a 100644 --- a/src/lib/ui/mobile.ts +++ b/src/lib/ui/mobile.ts @@ -84,7 +84,7 @@ export function showLoading(delayConditionFunc?: () => boolean, delayMills?: num }); } -export function hideLoading() { +export function hideLoading(): void { f7ready((f7) => { return f7.preloader.hide(); }); diff --git a/src/locales/helpers.ts b/src/locales/helpers.ts index 7b72aad4..d29fa89c 100644 --- a/src/locales/helpers.ts +++ b/src/locales/helpers.ts @@ -568,7 +568,7 @@ export function useI18n() { return getLanguageInfo(getDefaultLanguage()) as LanguageInfo; } - function getCurrentLanguageDisplayName() { + function getCurrentLanguageDisplayName(): string { const currentLanguageInfo = getCurrentLanguageInfo(); return currentLanguageInfo.displayName; } @@ -1175,27 +1175,27 @@ export function useI18n() { return t(`currency.name.${currencyCode}`); } - function isLongDateMonthAfterYear() { + function isLongDateMonthAfterYear():boolean { return getLocalizedDateTimeType(LongDateFormat.all(), LongDateFormat.values(), userStore.currentUserLongDateFormat, 'longDateFormat', LongDateFormat.Default).isMonthAfterYear; } - function isShortDateMonthAfterYear() { + function isShortDateMonthAfterYear():boolean { return getLocalizedDateTimeType(ShortDateFormat.all(), ShortDateFormat.values(), userStore.currentUserShortDateFormat, 'shortDateFormat', ShortDateFormat.Default).isMonthAfterYear; } - function isLongTime24HourFormat() { + function isLongTime24HourFormat():boolean { return getLocalizedDateTimeType(LongTimeFormat.all(), LongTimeFormat.values(), userStore.currentUserLongTimeFormat, 'longTimeFormat', LongTimeFormat.Default).is24HourFormat; } - function isLongTimeMeridiemIndicatorFirst() { + function isLongTimeMeridiemIndicatorFirst():boolean { return getLocalizedDateTimeType(LongTimeFormat.all(), LongTimeFormat.values(), userStore.currentUserLongTimeFormat, 'longTimeFormat', LongTimeFormat.Default).isMeridiemIndicatorFirst; } - function isShortTime24HourFormat() { + function isShortTime24HourFormat():boolean { return getLocalizedDateTimeType(ShortTimeFormat.all(), ShortTimeFormat.values(), userStore.currentUserShortTimeFormat, 'shortTimeFormat', ShortTimeFormat.Default).is24HourFormat; } - function isShortTimeMeridiemIndicatorFirst() { + function isShortTimeMeridiemIndicatorFirst():boolean { return getLocalizedDateTimeType(ShortTimeFormat.all(), ShortTimeFormat.values(), userStore.currentUserShortTimeFormat, 'shortTimeFormat', ShortTimeFormat.Default).isMeridiemIndicatorFirst; } diff --git a/src/stores/overview.ts b/src/stores/overview.ts index a41c786a..b8acd6f2 100644 --- a/src/stores/overview.ts +++ b/src/stores/overview.ts @@ -270,7 +270,7 @@ export const useOverviewStore = defineStore('overview', () => { transactionOverviewStateInvalid.value = invalidState; } - function resetTransactionOverview() { + function resetTransactionOverview(): void { updateTransactionDateRange(); transactionOverviewOptions.value.loadLast11Months = false; transactionOverviewData.value = {}; diff --git a/src/views/desktop/categories/list/dialogs/PresetDialog.vue b/src/views/desktop/categories/list/dialogs/PresetDialog.vue index cb223198..4cac72cc 100644 --- a/src/views/desktop/categories/list/dialogs/PresetDialog.vue +++ b/src/views/desktop/categories/list/dialogs/PresetDialog.vue @@ -133,7 +133,7 @@ function getCategoryTypeName(categoryType: CategoryType): string { } } -function save() { +function save(): void { submitting.value = true; const submitCategories = categorizedArrayToPlainArray(allPresetCategories.value); diff --git a/src/views/mobile/SettingsPage.vue b/src/views/mobile/SettingsPage.vue index 48870a58..a8c16422 100644 --- a/src/views/mobile/SettingsPage.vue +++ b/src/views/mobile/SettingsPage.vue @@ -134,13 +134,13 @@ const exchangeRatesLastUpdateDate = computed(() => { return exchangeRatesLastUpdateTime ? formatUnixTimeToLongDate(exchangeRatesLastUpdateTime) : ''; }); -function switchToDesktopVersion() { +function switchToDesktopVersion(): void { showConfirm('Are you sure you want to switch to desktop version?', () => { window.location.replace(getDesktopVersionPath()); }); } -function logout() { +function logout(): void { showConfirm('Are you sure you want to log out?', () => { logouting.value = true; showLoading(() => logouting.value);