code refactor

This commit is contained in:
MaysWind
2025-01-15 23:15:42 +08:00
parent dc4310c301
commit 922c338387
11 changed files with 65 additions and 64 deletions
+4 -4
View File
@@ -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) => {
+5 -5
View File
@@ -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);
}
}