code refactor

This commit is contained in:
MaysWind
2025-01-14 00:14:07 +08:00
parent 593e123610
commit f4ea9a85f0
11 changed files with 73 additions and 73 deletions
+7 -7
View File
@@ -1,16 +1,16 @@
import type { ColorValue } from '@/core/color.ts';
export interface PresetCategory {
name: string;
categoryIconId: string;
color: ColorValue;
subCategories: PresetSubCategory[];
readonly name: string;
readonly categoryIconId: string;
readonly color: ColorValue;
readonly subCategories: PresetSubCategory[];
}
export interface PresetSubCategory {
name: string;
categoryIconId: string;
color: ColorValue;
readonly name: string;
readonly categoryIconId: string;
readonly color: ColorValue;
}
export const DEFAULT_EXPENSE_CATEGORIES: PresetCategory[] = [
+2 -2
View File
@@ -14,8 +14,8 @@ export enum CurrencyDisplayLocation {
}
export interface CurrencyPrependAndAppendText {
prependText?: string;
appendText?: string;
readonly prependText?: string;
readonly appendText?: string;
}
export class CurrencyDisplayType implements TypeAndName {
+5 -5
View File
@@ -1,11 +1,11 @@
import type { TypeAndName, TypeAndDisplayName } from '@/core/base.ts';
export interface NumberFormatOptions {
digitGrouping?: number;
digitGroupingSymbol?: string;
decimalNumberCount?: number;
decimalSeparator?: string;
trimTailZero?: boolean;
readonly digitGrouping?: number;
readonly digitGroupingSymbol?: string;
readonly decimalNumberCount?: number;
readonly decimalSeparator?: string;
readonly trimTailZero?: boolean;
}
export interface NumeralSymbolType {
+5 -5
View File
@@ -130,11 +130,11 @@ import { getTimezoneOffsetMinutes } from './datetime.ts';
import { generateRandomUUID } from './misc.ts';
interface ApiRequestConfig extends AxiosRequestConfig {
headers: AxiosRequestHeaders;
noAuth?: boolean;
ignoreBlocked?: boolean;
ignoreError?: boolean;
timeout?: number;
readonly headers: AxiosRequestHeaders;
readonly noAuth?: boolean;
readonly ignoreBlocked?: boolean;
readonly ignoreError?: boolean;
readonly timeout?: number;
}
export type ApiResponsePromise<T> = Promise<AxiosResponse<ApiResponse<T>>>;
+10 -10
View File
@@ -3,18 +3,18 @@ import uaParser from 'ua-parser-js';
import { TOKEN_CLI_USER_AGENT, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
interface UserAgentInfo {
device: {
vendor?: string;
model?: string;
type?: string;
readonly device: {
readonly vendor?: string;
readonly model?: string;
readonly type?: string;
};
os: {
name?: string;
version?: string;
readonly os: {
readonly name?: string;
readonly version?: string;
};
browser: {
name?: string;
version?: string;
readonly browser: {
readonly name?: string;
readonly version?: string;
};
}
+15 -15
View File
@@ -16,30 +16,30 @@ import {
import logger from './logger.ts';
interface ClientData {
challenge: string;
crossOrigin: boolean;
origin: string;
type: string;
readonly challenge: string;
readonly crossOrigin: boolean;
readonly origin: string;
readonly type: string;
}
interface AttestationData {
authData: Uint8Array;
fmt: string;
readonly authData: Uint8Array;
readonly fmt: string;
}
interface WebAuthnRegisterResponse {
id: string | null;
clientData: ClientData;
publicKey: Uint8Array | null;
rawCredential: Credential;
readonly id: string | null;
readonly clientData: ClientData;
readonly publicKey: Uint8Array | null;
readonly rawCredential: Credential;
}
interface WebAuthnVerifyResponse {
id: string | null;
userName: string;
userSecret: string;
clientData: ClientData;
rawCredential: Credential;
readonly id: string | null;
readonly userName: string;
readonly userSecret: string;
readonly clientData: ClientData;
readonly rawCredential: Credential;
}
const PUBLIC_KEY_CREDENTIAL_CREATION_OPTIONS_BASE_TEMPLATE = {
+5 -5
View File
@@ -116,14 +116,14 @@ import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
export interface LocalizedErrorParameter {
key: string;
localized: boolean;
value: string;
readonly key: string;
readonly localized: boolean;
readonly value: string;
}
export interface LocalizedError {
message: string;
parameters?: LocalizedErrorParameter[];
readonly message: string;
readonly parameters?: LocalizedErrorParameter[];
}
export function getI18nOptions(): object {
+5 -5
View File
@@ -3,11 +3,11 @@ import vi from './vi.json';
import zhHans from './zh_Hans.json';
export interface LanguageInfo {
name: string;
displayName: string;
alternativeLanguageTag: string;
aliases?: string[];
content: object;
readonly name: string;
readonly displayName: string;
readonly alternativeLanguageTag: string;
readonly aliases?: string[];
readonly content: object;
}
export const DEFAULT_LANGUAGE: string = 'en';
+6 -6
View File
@@ -1,13 +1,13 @@
import type { UserBasicInfo } from './user.ts';
export interface AuthResponse {
token: string;
need2FA: boolean;
user?: UserBasicInfo;
notificationContent?: string;
readonly token: string;
readonly need2FA: boolean;
readonly user?: UserBasicInfo;
readonly notificationContent?: string;
}
export interface RegisterResponse extends AuthResponse {
needVerifyEmail: boolean;
presetCategoriesSaved: boolean;
readonly needVerifyEmail: boolean;
readonly presetCategoriesSaved: boolean;
}
+11 -11
View File
@@ -227,18 +227,18 @@ export interface TransactionAmountsResponseItemAmountInfo {
export type TransactionOverviewResponse = PartialRecord<TransactionAmountsRequestType, TransactionOverviewResponseItem>;
export interface TransactionOverviewResponseItem {
valid: boolean;
incomeAmount: number;
expenseAmount: number;
incompleteIncomeAmount: boolean;
incompleteExpenseAmount: boolean;
amounts?: TransactionAmountsResponseItemAmountInfo[];
readonly valid: boolean;
readonly incomeAmount: number;
readonly expenseAmount: number;
readonly incompleteIncomeAmount: boolean;
readonly incompleteExpenseAmount: boolean;
readonly amounts?: TransactionAmountsResponseItemAmountInfo[];
}
export interface TransactionMonthlyIncomeAndExpenseData {
monthStartTime: number;
incomeAmount: number;
expenseAmount: number;
incompleteIncomeAmount: boolean;
incompleteExpenseAmount: boolean;
readonly monthStartTime: number;
readonly incomeAmount: number;
readonly expenseAmount: number;
readonly incompleteIncomeAmount: boolean;
readonly incompleteExpenseAmount: boolean;
}
+2 -2
View File
@@ -13,8 +13,8 @@ import services from '@/lib/services.ts';
const exchangeRatesLocalStorageKey = 'ebk_app_exchange_rates';
interface LatestExchangeRates {
time?: number;
data?: LatestExchangeRateResponse;
readonly time?: number;
readonly data?: LatestExchangeRateResponse;
}
function getExchangeRatesFromLocalStorage(): LatestExchangeRates {