style: interface Emits 先于 defineEmits

This commit is contained in:
dhb52 2024-05-05 01:22:46 +08:00
parent 0e8af7d19b
commit 88ba7406c0
7 changed files with 23 additions and 25 deletions

View File

@ -4,16 +4,16 @@ import { $t } from '@/locales';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import { operationReasonOptions } from '@/constants/business'; import { operationReasonOptions } from '@/constants/business';
const operationReasonRef = ref<Api.Common.OperationReason>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:value', value: Api.Common.OperationReason): void; (e: 'update:value', value: Api.Common.OperationReason): void;
} }
const emit = defineEmits<Emits>();
const handleUpdate = (operationReason: Api.Common.OperationReason) => { const handleUpdate = (operationReason: Api.Common.OperationReason) => {
emit('update:value', operationReason); emit('update:value', operationReason);
}; };
const operationReasonRef = ref<Api.Common.OperationReason>();
</script> </script>
<template> <template>

View File

@ -8,12 +8,12 @@ defineOptions({
name: 'RouterKey' name: 'RouterKey'
}); });
const routeKeyRef = ref<Api.Common.RouteKey>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:value', value: Api.Common.RouteKey): void; (e: 'update:value', value: Api.Common.RouteKey): void;
} }
const emit = defineEmits<Emits>();
const routeKeyRef = ref<Api.Common.RouteKey>();
const handleUpdate = (routeKey: Api.Common.RouteKey) => { const handleUpdate = (routeKey: Api.Common.RouteKey) => {
emit('update:value', routeKey); emit('update:value', routeKey);

View File

@ -8,17 +8,11 @@ defineOptions({
name: 'SelectGroup' name: 'SelectGroup'
}); });
interface Props { const model = defineModel<string | null>();
modelValue?: string | null;
}
const props = defineProps<Props>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:modelValue', value: string): void; (e: 'update:modelValue', value: string): void;
} }
const emit = defineEmits<Emits>();
/** 组列表 */ /** 组列表 */
const groupNameList = ref<string[]>([]); const groupNameList = ref<string[]>([]);
@ -35,9 +29,9 @@ async function getGroupNameList() {
getGroupNameList(); getGroupNameList();
watch( watch(
() => props.modelValue, () => model,
() => { () => {
groupName.value = props.modelValue!; groupName.value = model.value!;
}, },
{ immediate: true } { immediate: true }
); );

View File

@ -4,6 +4,10 @@ import { $t } from '@/locales';
import { translateOptions2 } from '@/utils/common'; import { translateOptions2 } from '@/utils/common';
import { fetchGetRetrySceneList } from '@/service/api'; import { fetchGetRetrySceneList } from '@/service/api';
defineOptions({
name: 'SelectScene'
});
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
interface Props { interface Props {

View File

@ -4,12 +4,12 @@ import { $t } from '@/locales';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import { taskBatchStatusRecordOptions } from '@/constants/business'; import { taskBatchStatusRecordOptions } from '@/constants/business';
const taskBatchStatusRef = ref<Api.Common.TaskBatchStatus>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:value', value: Api.Common.TaskBatchStatus): void; (e: 'update:value', value: Api.Common.TaskBatchStatus): void;
} }
const emit = defineEmits<Emits>();
const taskBatchStatusRef = ref<Api.Common.TaskBatchStatus>();
const handleUpdate = (taskBatchStatus: Api.Common.TaskBatchStatus) => { const handleUpdate = (taskBatchStatus: Api.Common.TaskBatchStatus) => {
emit('update:value', taskBatchStatus); emit('update:value', taskBatchStatus);

View File

@ -8,12 +8,12 @@ defineOptions({
name: 'TaskType' name: 'TaskType'
}); });
const valueRef = ref<Api.Common.BlockStrategy>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:value', value: Api.Common.BlockStrategy): void; (e: 'update:value', value: Api.Common.BlockStrategy): void;
} }
const emit = defineEmits<Emits>();
const valueRef = ref<Api.Common.BlockStrategy>();
const handleUpdate = (value: Api.Common.BlockStrategy) => { const handleUpdate = (value: Api.Common.BlockStrategy) => {
emit('update:value', value); emit('update:value', value);

View File

@ -8,12 +8,12 @@ defineOptions({
name: 'TriggerType' name: 'TriggerType'
}); });
const valueRef = ref<Api.Common.TriggerType>();
const emit = defineEmits<Emits>();
interface Emits { interface Emits {
(e: 'update:value', value: Api.Common.TriggerType): void; (e: 'update:value', value: Api.Common.TriggerType): void;
} }
const emit = defineEmits<Emits>();
const valueRef = ref<Api.Common.TriggerType>();
const handleUpdate = (value: Api.Common.TriggerType) => { const handleUpdate = (value: Api.Common.TriggerType) => {
emit('update:value', value); emit('update:value', value);