From 89b233e51b580fba9dae2f7ed15f90cb62184b70 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 11 Jan 2025 13:59:47 +0800 Subject: [PATCH] code refactor --- src/DesktopApp.vue | 4 ++-- src/MobileApp.vue | 12 +++++------ src/components/common/MapView.vue | 10 +++++----- src/components/common/PinCodeInput.vue | 8 ++++---- src/components/desktop/BtnVerticalGroup.vue | 2 +- src/components/desktop/ColorSelect.vue | 6 +++--- src/components/desktop/ConfirmDialog.vue | 14 ++++++------- src/components/desktop/IconSelect.vue | 8 ++++---- src/components/desktop/SnackBar.vue | 10 +++++----- src/components/desktop/StepsBar.vue | 2 +- .../desktop/SwitchToMobileDialog.vue | 2 +- src/components/mobile/ColorSelectionSheet.vue | 20 +++++++++---------- src/components/mobile/IconSelectionSheet.vue | 20 +++++++++---------- src/components/mobile/InformationSheet.vue | 12 +++++------ src/components/mobile/MapSheet.vue | 12 +++++------ src/components/mobile/NumberPadSheet.vue | 12 +++++------ src/components/mobile/PasscodeInputSheet.vue | 20 +++++++++---------- src/components/mobile/PasswordInputSheet.vue | 20 +++++++++---------- src/components/mobile/PinCodeInputSheet.vue | 18 ++++++++--------- src/lib/ui/mobile.ts | 2 +- src/stores/exchangeRates.ts | 4 ++-- src/stores/overview.ts | 10 +++++----- src/stores/setting.ts | 6 +++--- src/stores/user.ts | 4 ++-- src/views/desktop/MainLayout.vue | 18 ++++++++--------- 25 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/DesktopApp.vue b/src/DesktopApp.vue index 1fd43ad1..ed2ab007 100644 --- a/src/DesktopApp.vue +++ b/src/DesktopApp.vue @@ -16,7 +16,7 @@ diff --git a/src/components/mobile/IconSelectionSheet.vue b/src/components/mobile/IconSelectionSheet.vue index 0bb129b4..476e22e9 100644 --- a/src/components/mobile/IconSelectionSheet.vue +++ b/src/components/mobile/IconSelectionSheet.vue @@ -29,14 +29,14 @@ diff --git a/src/components/mobile/InformationSheet.vue b/src/components/mobile/InformationSheet.vue index 7c70435d..b81b6019 100644 --- a/src/components/mobile/InformationSheet.vue +++ b/src/components/mobile/InformationSheet.vue @@ -41,17 +41,17 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'update:show', value: boolean): void - (e: 'info:copied'): void + (e: 'update:show', value: boolean): void; + (e: 'info:copied'): void; }>(); const { tt } = useI18n(); -const iconCopyToClipboard = useTemplateRef('copyToClipboardIcon'); +const iconCopyToClipboard = useTemplateRef('copyToClipboardIcon'); let clipboardHolder: ClipboardHolder | null = null; -function makeCopyToClipboardClickable() { +function makeCopyToClipboardClickable(): void { if (clipboardHolder) { return; } @@ -67,11 +67,11 @@ function makeCopyToClipboardClickable() { } } -function close() { +function close(): void { emit('update:show', false); } -function onSheetClosed() { +function onSheetClosed(): void { close(); } diff --git a/src/components/mobile/MapSheet.vue b/src/components/mobile/MapSheet.vue index 8f80c2d4..b9dc6f3c 100644 --- a/src/components/mobile/MapSheet.vue +++ b/src/components/mobile/MapSheet.vue @@ -46,8 +46,8 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'update:modelValue', value: MapPosition | undefined): void, - (e: 'update:show', value: boolean): void + (e: 'update:modelValue', value: MapPosition | undefined): void; + (e: 'update:show', value: boolean): void; }>(); const { tt } = useI18n(); @@ -63,21 +63,21 @@ const geoLocation = computed({ } }); -function save() { +function save(): void { emit('update:show', false); } -function close() { +function close(): void { emit('update:show', false); } -function onSheetOpen() { +function onSheetOpen(): void { if (map.value) { map.value.initMapView(); } } -function onSheetClosed() { +function onSheetClosed(): void { close(); } diff --git a/src/components/mobile/NumberPadSheet.vue b/src/components/mobile/NumberPadSheet.vue index 666b9d23..722f5748 100644 --- a/src/components/mobile/NumberPadSheet.vue +++ b/src/components/mobile/NumberPadSheet.vue @@ -66,7 +66,7 @@ diff --git a/src/components/mobile/PasswordInputSheet.vue b/src/components/mobile/PasswordInputSheet.vue index 360fce2d..9513fb4d 100644 --- a/src/components/mobile/PasswordInputSheet.vue +++ b/src/components/mobile/PasswordInputSheet.vue @@ -38,7 +38,7 @@ diff --git a/src/components/mobile/PinCodeInputSheet.vue b/src/components/mobile/PinCodeInputSheet.vue index 3feceff8..63595d5a 100644 --- a/src/components/mobile/PinCodeInputSheet.vue +++ b/src/components/mobile/PinCodeInputSheet.vue @@ -27,7 +27,7 @@ diff --git a/src/lib/ui/mobile.ts b/src/lib/ui/mobile.ts index 4225bc68..4c00c3d2 100644 --- a/src/lib/ui/mobile.ts +++ b/src/lib/ui/mobile.ts @@ -8,7 +8,7 @@ import { isEnableAnimate } from '../settings.ts'; // @ts-expect-error the above file is migrating to ts import { translateError } from '@/locales/helper.js'; -interface Framework7Dom { +export interface Framework7Dom { length: number; [index: number]: Element; find: (selector?: string) => Framework7Dom; diff --git a/src/stores/exchangeRates.ts b/src/stores/exchangeRates.ts index 1206c5c7..3412c65c 100644 --- a/src/stores/exchangeRates.ts +++ b/src/stores/exchangeRates.ts @@ -1,4 +1,4 @@ -import { type Ref, ref, computed } from 'vue'; +import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; import type { LatestExchangeRate, LatestExchangeRateResponse } from '@/models/exchange_rate.ts'; @@ -32,7 +32,7 @@ function clearExchangeRatesFromLocalStorage(): void { } export const useExchangeRatesStore = defineStore('exchangeRates', () => { - const latestExchangeRates: Ref = ref(getExchangeRatesFromLocalStorage()); + const latestExchangeRates = ref(getExchangeRatesFromLocalStorage()); const exchangeRatesLastUpdateTime = computed(() => { const exchangeRates = latestExchangeRates.value || {}; diff --git a/src/stores/overview.ts b/src/stores/overview.ts index b38b236b..818a4a5c 100644 --- a/src/stores/overview.ts +++ b/src/stores/overview.ts @@ -1,4 +1,4 @@ -import { type Ref, ref, computed } from 'vue'; +import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; import { useSettingsStore } from './setting.ts'; @@ -101,7 +101,7 @@ export const useOverviewStore = defineStore('overview', () => { const userStore = useUserStore(); const exchangeRatesStore = useExchangeRatesStore(); - const transactionDataRange: Ref = ref({ + const transactionDataRange = ref({ today: { startTime: getTodayFirstUnixTime(), endTime: getTodayLastUnixTime() @@ -164,12 +164,12 @@ export const useOverviewStore = defineStore('overview', () => { } }); - const transactionOverviewOptions: Ref = ref({ + const transactionOverviewOptions = ref({ loadLast11Months: false }); - const transactionOverviewData: Ref = ref({}); - const transactionOverviewStateInvalid: Ref = ref(true); + const transactionOverviewData = ref({}); + const transactionOverviewStateInvalid = ref(true); const transactionOverview = computed(() => { const overviewData = transactionOverviewData.value; diff --git a/src/stores/setting.ts b/src/stores/setting.ts index 596367f9..a01662c4 100644 --- a/src/stores/setting.ts +++ b/src/stores/setting.ts @@ -1,4 +1,4 @@ -import { type Ref, ref } from 'vue'; +import { ref } from 'vue'; import { defineStore } from 'pinia'; import type { ApplicationSettings, LocaleDefaultSettings } from '@/core/setting.ts'; @@ -11,8 +11,8 @@ import { } from '@/lib/settings.ts'; export const useSettingsStore = defineStore('settings', () => { - const appSettings: Ref = ref(getApplicationSettings()); - const localeDefaultSettings: Ref = ref(getLocaleDefaultSettings()); + const appSettings = ref(getApplicationSettings()); + const localeDefaultSettings = ref(getLocaleDefaultSettings()); function setTheme(value: string): void { updateApplicationSettingsValue('theme', value); diff --git a/src/stores/user.ts b/src/stores/user.ts index 3d5593d0..8e8f6861 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -1,4 +1,4 @@ -import { type Ref, ref, computed } from 'vue'; +import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; import { useSettingsStore } from './setting.ts'; @@ -33,7 +33,7 @@ import services from '@/lib/services.ts'; export const useUserStore = defineStore('user', () => { const settingsStore = useSettingsStore(); - const currentUserBasicInfo: Ref = ref(getCurrentUserInfo()); + const currentUserBasicInfo = ref(getCurrentUserInfo()); const currentUserNickname = computed(() => { const userInfo = currentUserBasicInfo.value || EMPTY_USER_BASIC_INFO; diff --git a/src/views/desktop/MainLayout.vue b/src/views/desktop/MainLayout.vue index f2bd8f95..d2101884 100644 --- a/src/views/desktop/MainLayout.vue +++ b/src/views/desktop/MainLayout.vue @@ -194,7 +194,7 @@