mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
migrate transaction tag list page to composition API and typescript
This commit is contained in:
@@ -19,7 +19,7 @@ import { ref, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { isString } from '@/lib/common.ts';
|
||||
import { isString, isObject } from '@/lib/common.ts';
|
||||
|
||||
const props = defineProps<{
|
||||
show?: boolean
|
||||
@@ -42,16 +42,26 @@ const finalColor = ref<string>(props.color || 'primary');
|
||||
let resolveFunc: ((value?: unknown) => void) | null = null;
|
||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
||||
|
||||
function open(titleOrText: string, textOrOptions: string | Record<string, unknown>, options: Record<string, unknown>): Promise<unknown> {
|
||||
function open(titleOrText: string, textOrOptions?: string | Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown> {
|
||||
showState.value = true;
|
||||
|
||||
if (isString(textOrOptions)) { // second parameter is text
|
||||
titleContent.value = tt(titleOrText, options);
|
||||
textContent.value = tt(textOrOptions as string, options);
|
||||
} else { // second parameter is options
|
||||
const actualOptions = textOrOptions as Record<string, unknown>;
|
||||
if (!textOrOptions || isObject(textOrOptions)) { // only one parameter or second parameter is options
|
||||
titleContent.value = tt('global.app.title');
|
||||
textContent.value = tt(titleOrText, actualOptions);
|
||||
|
||||
if (!textOrOptions) {
|
||||
textContent.value = tt(titleOrText);
|
||||
} else {
|
||||
const actualOptions = textOrOptions as Record<string, unknown>;
|
||||
textContent.value = tt(titleOrText, actualOptions);
|
||||
}
|
||||
} else if (isString(textOrOptions)) { // second parameter is text
|
||||
if (!options) {
|
||||
titleContent.value = tt(titleOrText);
|
||||
textContent.value = tt(textOrOptions as string);
|
||||
} else {
|
||||
titleContent.value = tt(titleOrText, options);
|
||||
textContent.value = tt(textOrOptions as string, options);
|
||||
}
|
||||
}
|
||||
|
||||
if (options && isString(options.color)) {
|
||||
|
||||
@@ -24,9 +24,14 @@ const { tt, te } = useI18n();
|
||||
const showState= ref<boolean>(false);
|
||||
const messageContent = ref<string>('');
|
||||
|
||||
function showMessage(message: string, options: Record<string, unknown>): void {
|
||||
function showMessage(message: string, options?: Record<string, unknown>): void {
|
||||
showState.value = true;
|
||||
messageContent.value = tt(message, options);
|
||||
|
||||
if (options) {
|
||||
messageContent.value = tt(message, options);
|
||||
} else {
|
||||
messageContent.value = tt(message);
|
||||
}
|
||||
}
|
||||
|
||||
function showError(error: string | { message: string }): void {
|
||||
|
||||
Reference in New Issue
Block a user