mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 16:07:33 +08:00
code refactor
This commit is contained in:
@@ -25,7 +25,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: unknown): void
|
||||
(e: 'update:modelValue', value: unknown): void;
|
||||
}>();
|
||||
|
||||
const value = computed<unknown>({
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Ref, ref, computed, useTemplateRef, nextTick } from 'vue';
|
||||
import { ref, computed, useTemplateRef, nextTick } from 'vue';
|
||||
|
||||
import type { ColorValue, ColorInfo } from '@/core/color.ts';
|
||||
import { DEFAULT_ICON_COLOR } from '@/consts/color.ts';
|
||||
@@ -61,7 +61,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: ColorValue): void
|
||||
(e: 'update:modelValue', value: ColorValue): void;
|
||||
}>();
|
||||
|
||||
const icons = {
|
||||
@@ -70,7 +70,7 @@ const icons = {
|
||||
};
|
||||
|
||||
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
||||
const itemPerRow: Ref<number> = ref(props.columnCount || 7);
|
||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||
|
||||
const allColorRows = computed<ColorInfo[][]>(() => {
|
||||
return getColorsInRows(props.allColorInfos, itemPerRow.value);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Ref, ref, watch } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
@@ -29,20 +29,20 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const { tt } = useI18n();
|
||||
|
||||
const showState: Ref<boolean> = ref(false);
|
||||
const titleContent: Ref<string> = ref(props.title || tt('global.app.title'));
|
||||
const textContent: Ref<string> = ref(props.text || '');
|
||||
const finalColor: Ref<string> = ref(props.color || 'primary');
|
||||
const showState = ref<boolean>(false);
|
||||
const titleContent = ref<string>(props.title || tt('global.app.title'));
|
||||
const textContent = ref<string>(props.text || '');
|
||||
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>) {
|
||||
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
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Ref, ref, computed, useTemplateRef, nextTick } from 'vue';
|
||||
import { ref, computed, useTemplateRef, nextTick } from 'vue';
|
||||
|
||||
import type { ColorValue } from '@/core/color.ts';
|
||||
import type { IconInfo, IconInfoWithId } from '@/core/icon.ts';
|
||||
@@ -60,7 +60,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: string): void
|
||||
(e: 'update:modelValue', value: string): void;
|
||||
}>();
|
||||
|
||||
const icons = {
|
||||
@@ -68,13 +68,13 @@ const icons = {
|
||||
};
|
||||
|
||||
const dropdownMenu = useTemplateRef<HTMLElement>('dropdownMenu');
|
||||
const itemPerRow: Ref<number> = ref(props.columnCount || 7);
|
||||
const itemPerRow = ref<number>(props.columnCount || 7);
|
||||
|
||||
const allIconRows = computed<IconInfoWithId[][]>(() => {
|
||||
return getIconsInRows(props.allIconInfos, itemPerRow.value);
|
||||
});
|
||||
|
||||
const icon = computed({
|
||||
const icon = computed<string>({
|
||||
get: () => props.modelValue,
|
||||
set: (value: string) => emit('update:modelValue', value)
|
||||
});
|
||||
|
||||
@@ -9,20 +9,20 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Ref, ref, watch } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { isObject } from '@/lib/common.ts';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const { tt, te } = useI18n();
|
||||
|
||||
const showState: Ref<boolean> = ref(false);
|
||||
const messageContent: Ref<string> = ref('');
|
||||
const showState= ref<boolean>(false);
|
||||
const messageContent = ref<string>('');
|
||||
|
||||
function showMessage(message: string, options: Record<string, unknown>): void {
|
||||
showState.value = true;
|
||||
@@ -35,7 +35,7 @@ function showError(error: string | { message: string }): void {
|
||||
if (isObject(error) && (error as { message: string }).message) {
|
||||
messageContent.value = te((error as { message: string }).message);
|
||||
} else {
|
||||
messageContent.value = te(error);
|
||||
messageContent.value = te(error as string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'step:change', stepName: string): void
|
||||
(e: 'step:change', stepName: string): void;
|
||||
}>();
|
||||
|
||||
const isClickable = computed<boolean>(() => {
|
||||
|
||||
@@ -41,7 +41,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const { tt } = useI18n();
|
||||
|
||||
Reference in New Issue
Block a user