code refactor

This commit is contained in:
MaysWind
2025-01-11 13:59:47 +08:00
parent 61f26e060e
commit 89b233e51b
25 changed files with 128 additions and 128 deletions
+1 -1
View File
@@ -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>({
+3 -3
View File
@@ -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);
+7 -7
View File
@@ -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
+4 -4
View File
@@ -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)
});
+5 -5
View File
@@ -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);
}
}
+1 -1
View File
@@ -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();