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