mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
code refactor
This commit is contained in:
@@ -41,11 +41,11 @@ export function useItemIconBase(props: CommonIconProps) {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!ALL_ACCOUNT_ICONS[iconId as string]) {
|
||||
if (!ALL_ACCOUNT_ICONS[iconId]) {
|
||||
return DEFAULT_ACCOUNT_ICON.icon;
|
||||
}
|
||||
|
||||
return ALL_ACCOUNT_ICONS[iconId as string].icon;
|
||||
return ALL_ACCOUNT_ICONS[iconId].icon;
|
||||
}
|
||||
|
||||
function getCategoryIcon(iconId: string | number): string {
|
||||
@@ -53,11 +53,11 @@ export function useItemIconBase(props: CommonIconProps) {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!ALL_CATEGORY_ICONS[iconId as string]) {
|
||||
if (!ALL_CATEGORY_ICONS[iconId]) {
|
||||
return DEFAULT_CATEGORY_ICON.icon;
|
||||
}
|
||||
|
||||
return ALL_CATEGORY_ICONS[iconId as string].icon;
|
||||
return ALL_CATEGORY_ICONS[iconId].icon;
|
||||
}
|
||||
|
||||
function getAccountIconStyle(color?: ColorValue | string, defaultColor?: ColorValue | string, additionalColorAttr?: string): Record<IconItemStyleName, IconItemStyleValue> {
|
||||
|
||||
@@ -57,15 +57,15 @@ function open(titleOrText: string, textOrOptions?: string | Record<string, unkno
|
||||
} else if (isString(textOrOptions)) { // second parameter is text
|
||||
if (!options) {
|
||||
titleContent.value = tt(titleOrText);
|
||||
textContent.value = tt(textOrOptions as string);
|
||||
textContent.value = tt(textOrOptions);
|
||||
} else {
|
||||
titleContent.value = tt(titleOrText, options);
|
||||
textContent.value = tt(textOrOptions as string, options);
|
||||
textContent.value = tt(textOrOptions, options);
|
||||
}
|
||||
}
|
||||
|
||||
if (options && isString(options.color)) {
|
||||
finalColor.value = (options.color as string) || 'primary';
|
||||
if (options && isString(options['color'])) {
|
||||
finalColor.value = (options['color'] as string) || 'primary';
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ref, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { isObject } from '@/lib/common.ts';
|
||||
import { isObject, isString } from '@/lib/common.ts';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void;
|
||||
@@ -37,10 +37,10 @@ function showMessage(message: string, options?: Record<string, unknown>): void {
|
||||
function showError(error: string | { message: string }): void {
|
||||
showState.value = true;
|
||||
|
||||
if (isObject(error) && (error as { message: string }).message) {
|
||||
messageContent.value = te((error as { message: string }).message);
|
||||
} else {
|
||||
messageContent.value = te(error as string);
|
||||
if (isObject(error) && error.message) {
|
||||
messageContent.value = te(error.message);
|
||||
} else if (isString(error)) {
|
||||
messageContent.value = te(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ function inputNum(num: number): void {
|
||||
if (isNumber(props.minValue)) {
|
||||
const current = parseAmount(newValue);
|
||||
|
||||
if (current < (props.minValue as number)) {
|
||||
if (current < (props.minValue)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ function inputNum(num: number): void {
|
||||
if (isNumber(props.maxValue)) {
|
||||
const current = parseAmount(newValue);
|
||||
|
||||
if (current > (props.maxValue as number)) {
|
||||
if (current > (props.maxValue)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -308,14 +308,14 @@ function confirm(): boolean {
|
||||
}
|
||||
|
||||
if (isNumber(props.minValue)) {
|
||||
if (finalValue < (props.minValue as number)) {
|
||||
if (finalValue < (props.minValue)) {
|
||||
showToast('Numeric Overflow');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNumber(props.maxValue)) {
|
||||
if (finalValue > (props.maxValue as number)) {
|
||||
if (finalValue > (props.maxValue)) {
|
||||
showToast('Numeric Overflow');
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user