mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 16:24:25 +08:00
code refactor
This commit is contained in:
@@ -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<LatestExchangeRates> = ref(getExchangeRatesFromLocalStorage());
|
||||
const latestExchangeRates = ref<LatestExchangeRates>(getExchangeRatesFromLocalStorage());
|
||||
|
||||
const exchangeRatesLastUpdateTime = computed<number | null>(() => {
|
||||
const exchangeRates = latestExchangeRates.value || {};
|
||||
|
||||
@@ -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<TransactionDataRange> = ref({
|
||||
const transactionDataRange = ref<TransactionDataRange>({
|
||||
today: {
|
||||
startTime: getTodayFirstUnixTime(),
|
||||
endTime: getTodayLastUnixTime()
|
||||
@@ -164,12 +164,12 @@ export const useOverviewStore = defineStore('overview', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const transactionOverviewOptions: Ref<TransactionOverviewOptions> = ref({
|
||||
const transactionOverviewOptions = ref<TransactionOverviewOptions>({
|
||||
loadLast11Months: false
|
||||
});
|
||||
|
||||
const transactionOverviewData: Ref<TransactionAmountsResponse> = ref({});
|
||||
const transactionOverviewStateInvalid: Ref<boolean> = ref(true);
|
||||
const transactionOverviewData = ref<TransactionAmountsResponse>({});
|
||||
const transactionOverviewStateInvalid = ref<boolean>(true);
|
||||
|
||||
const transactionOverview = computed<TransactionOverviewResponse>(() => {
|
||||
const overviewData = transactionOverviewData.value;
|
||||
|
||||
@@ -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<ApplicationSettings> = ref(getApplicationSettings());
|
||||
const localeDefaultSettings: Ref<LocaleDefaultSettings> = ref(getLocaleDefaultSettings());
|
||||
const appSettings = ref<ApplicationSettings>(getApplicationSettings());
|
||||
const localeDefaultSettings = ref<LocaleDefaultSettings>(getLocaleDefaultSettings());
|
||||
|
||||
function setTheme(value: string): void {
|
||||
updateApplicationSettingsValue('theme', value);
|
||||
|
||||
+2
-2
@@ -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<UserBasicInfo | null> = ref(getCurrentUserInfo());
|
||||
const currentUserBasicInfo = ref<UserBasicInfo | null>(getCurrentUserInfo());
|
||||
|
||||
const currentUserNickname = computed<string | null>(() => {
|
||||
const userInfo = currentUserBasicInfo.value || EMPTY_USER_BASIC_INFO;
|
||||
|
||||
Reference in New Issue
Block a user