migrate user store to composition API and typescript

This commit is contained in:
MaysWind
2025-01-05 22:47:33 +08:00
parent 6dc0ebcac6
commit 5171f23c09
61 changed files with 449 additions and 346 deletions
+51
View File
@@ -1,5 +1,32 @@
import { LongDateFormat, ShortDateFormat, LongTimeFormat, ShortTimeFormat } from '@/core/datetime.ts';
import { DecimalSeparator, DigitGroupingSymbol, DigitGroupingType } from '@/core/numeral.ts';
import { CurrencyDisplayType } from '@/core/currency.ts';
import { PresetAmountColor } from '@/core/color.ts';
import { TransactionEditScopeType } from '@/core/transaction.ts';
import type { TransactionCategoryCreateBatchRequest } from './transaction_category.ts';
export class User {
username: string = '';
password: string = '';
confirmPassword: string = '';
email: string = '';
nickname: string = '';
language: string;
defaultCurrency: string;
firstDayOfWeek: number;
private constructor(language: string, defaultCurrency: string, firstDayOfWeek: number) {
this.language = language;
this.defaultCurrency = defaultCurrency;
this.firstDayOfWeek = firstDayOfWeek;
}
public static createNewUser(language: string, defaultCurrency: string, firstDayOfWeek: number): User {
return new User(language, defaultCurrency, firstDayOfWeek);
}
}
export interface UserBasicInfo {
readonly username: string;
readonly email: string;
@@ -81,3 +108,27 @@ export interface UserProfileUpdateResponse {
export interface UserProfileResponse extends UserBasicInfo {
readonly lastLoginAt: number;
}
export const EMPTY_USER_BASIC_INFO: UserBasicInfo = {
username: '',
email: '',
nickname: '',
avatar: '',
avatarProvider: undefined,
defaultAccountId: '',
transactionEditScope: TransactionEditScopeType.All.type,
language: '',
defaultCurrency: '',
firstDayOfWeek: -1,
longDateFormat: LongDateFormat.Default.type,
shortDateFormat: ShortDateFormat.Default.type,
longTimeFormat: LongTimeFormat.Default.type,
shortTimeFormat: ShortTimeFormat.Default.type,
decimalSeparator: DecimalSeparator.LanguageDefaultType,
digitGroupingSymbol: DigitGroupingSymbol.LanguageDefaultType,
digitGrouping: DigitGroupingType.LanguageDefaultType,
currencyDisplayType: CurrencyDisplayType.Default.type,
expenseAmountColor: PresetAmountColor.DefaultExpenseColor.type,
incomeAmountColor: PresetAmountColor.DefaultIncomeColor.type,
emailVerified: false
}