mirror of https://github.com/halo-dev/halo-admin
refactor: refine emits type declaration
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/599/head
parent
cf85449b25
commit
021e9a8a93
|
@ -31,7 +31,9 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const classes = computed(() => {
|
||||
return [`alert-${props.type}`];
|
||||
|
|
|
@ -61,7 +61,9 @@ const props = withDefaults(
|
|||
);
|
||||
|
||||
const router = useRouter();
|
||||
const emit = defineEmits(["click"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "click"): void;
|
||||
}>();
|
||||
|
||||
const classes = computed(() => {
|
||||
return [
|
||||
|
|
|
@ -15,7 +15,10 @@ const id = ["checkbox", props.name, props.value]
|
|||
.filter((item) => !!item)
|
||||
.join("-");
|
||||
|
||||
const emit = defineEmits(["update:checked", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:checked", value: boolean): void;
|
||||
(event: "change", value: Event): void;
|
||||
}>();
|
||||
|
||||
function handleChange(e: Event) {
|
||||
const { checked } = e.target as HTMLInputElement;
|
||||
|
|
|
@ -16,7 +16,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string[]): void;
|
||||
(event: "change", value: string[]): void;
|
||||
}>();
|
||||
|
||||
function handleChange(e: Event) {
|
||||
const { value, checked } = e.target as HTMLInputElement;
|
||||
|
|
|
@ -35,7 +35,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const icons = {
|
||||
success: {
|
||||
|
|
|
@ -15,7 +15,9 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string): void;
|
||||
}>();
|
||||
|
||||
const classes = computed(() => {
|
||||
return [`input-${props.size}`];
|
||||
|
|
|
@ -15,7 +15,9 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["select"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "select", id: string): void;
|
||||
}>();
|
||||
|
||||
const slots = useSlots();
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", value: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const rootVisible = ref(false);
|
||||
const modelWrapper = ref<HTMLElement>();
|
||||
|
|
|
@ -20,7 +20,11 @@ const { page, size, total } = toRefs(props);
|
|||
|
||||
const key = ref(Math.random());
|
||||
|
||||
const emit = defineEmits(["update:page", "update:size", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:page", page: number): void;
|
||||
(event: "update:size", size: number): void;
|
||||
(event: "change", value: { page: number; size: number }): void;
|
||||
}>();
|
||||
|
||||
const onPageChange = ({
|
||||
currentPage,
|
||||
|
|
|
@ -8,7 +8,10 @@ const props = defineProps<{
|
|||
name?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string | number | boolean): void;
|
||||
(event: "change", value: string | number | boolean): void;
|
||||
}>();
|
||||
|
||||
const id = ["radio", props.name, props.value]
|
||||
.filter((item) => !!item)
|
||||
|
|
|
@ -15,7 +15,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string | number | boolean): void;
|
||||
(event: "change", value: string | number | boolean): void;
|
||||
}>();
|
||||
|
||||
function handleChange(value: string | number | boolean) {
|
||||
emit("update:modelValue", value);
|
||||
|
|
|
@ -15,7 +15,9 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string): void;
|
||||
}>();
|
||||
|
||||
const classes = computed(() => {
|
||||
return [`select-${props.size}`];
|
||||
|
|
|
@ -8,7 +8,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: boolean): void;
|
||||
(event: "change", value: boolean): void;
|
||||
}>();
|
||||
|
||||
const handleChange = () => {
|
||||
emit("update:modelValue", !props.modelValue);
|
||||
|
|
|
@ -19,7 +19,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:activeId", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:activeId", value: number | string): void;
|
||||
(event: "change", value: number | string): void;
|
||||
}>();
|
||||
|
||||
const classes = computed(() => {
|
||||
return [`tabbar-${props.type}`, `tabbar-direction-${props.direction}`];
|
||||
|
|
|
@ -25,7 +25,10 @@ provide<ComputedRef<string | number | undefined>>(
|
|||
computed(() => props.activeId)
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:activeId", "change"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:activeId", value: number | string): void;
|
||||
(event: "change", value: number | string): void;
|
||||
}>();
|
||||
|
||||
const slots = useSlots();
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:modelValue", value: string): void;
|
||||
}>();
|
||||
|
||||
function handleInput(e: Event) {
|
||||
const { value } = e.target as HTMLInputElement;
|
||||
|
|
|
@ -10,7 +10,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -17,7 +17,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -10,7 +10,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -10,7 +10,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const attachments = Array.from(new Array(50), (_, index) => index).map(
|
||||
(index) => {
|
||||
|
|
|
@ -18,7 +18,11 @@ withDefaults(
|
|||
visible: false,
|
||||
}
|
||||
);
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const strategies = ref([
|
||||
{
|
||||
|
|
|
@ -17,7 +17,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const strategies = ref([
|
||||
{
|
||||
|
|
|
@ -12,7 +12,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -27,7 +27,12 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close", "previous", "next"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
(event: "previous"): void;
|
||||
(event: "next"): void;
|
||||
}>();
|
||||
|
||||
const settingActiveId = ref("general");
|
||||
const formState = ref<FormState>({
|
||||
|
|
|
@ -11,7 +11,11 @@ withDefaults(
|
|||
tag: undefined,
|
||||
}
|
||||
);
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -19,7 +19,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const initialFormState: Menu = {
|
||||
spec: {
|
||||
|
|
|
@ -19,7 +19,11 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close", "saved"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
(event: "saved", menuItem: MenuItem): void;
|
||||
}>();
|
||||
|
||||
const initialFormState: MenuItem = {
|
||||
spec: {
|
||||
|
|
|
@ -13,7 +13,11 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["change", "open-editing", "delete"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "change"): void;
|
||||
(event: "open-editing", menuItem: MenuTreeItem): void;
|
||||
(event: "delete", menuItem: MenuTreeItem): void;
|
||||
}>();
|
||||
|
||||
const isDragging = ref(false);
|
||||
|
||||
|
|
|
@ -21,7 +21,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["select", "update:selectedMenu"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "select", menu: Menu): void;
|
||||
(event: "update:selectedMenu", menu: Menu): void;
|
||||
}>();
|
||||
|
||||
const menus = ref<Menu[]>([] as Menu[]);
|
||||
const selectedMenuToUpdate = ref<Menu | null>(null);
|
||||
|
|
|
@ -15,7 +15,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const handleVisibleChange = (visible: boolean) => {
|
||||
emit("update:visible", visible);
|
||||
|
|
|
@ -26,7 +26,11 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close", "update:selectedTheme"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
(event: "update:selectedTheme", theme: Theme | null): void;
|
||||
}>();
|
||||
|
||||
const themes = ref<Theme[]>([]);
|
||||
const themeInstall = ref(false);
|
||||
|
|
|
@ -16,7 +16,10 @@ withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const dialog = useDialog();
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
|
||||
useRoleTemplateSelection();
|
||||
|
|
|
@ -29,7 +29,10 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
interface FormState {
|
||||
user: User;
|
||||
|
|
|
@ -16,7 +16,11 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(["update:visible", "close"]);
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", visible: boolean): void;
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
||||
const currentUser = inject<User>("currentUser");
|
||||
|
||||
interface PasswordChangeFormState {
|
||||
|
|
Loading…
Reference in New Issue