refactor: define props with pure types via a generic type argument

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/599/head
Ryan Wang 2022-08-15 17:56:13 +08:00
parent 91ae05fc72
commit cf85449b25
44 changed files with 450 additions and 570 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { Component, PropType } from "vue";
import type { Component } from "vue";
import { computed } from "vue";
import type { Type } from "./interface";
import {
@ -18,22 +18,18 @@ const TypeIcons: Record<Type, Component> = {
error: IconCloseCircle,
};
const props = defineProps({
type: {
type: String as PropType<Type>,
default: "default",
},
title: {
type: String,
},
description: {
type: String,
},
closable: {
type: Boolean,
default: true,
},
});
const props = withDefaults(
defineProps<{
type?: Type;
title?: string;
description?: string;
closable?: boolean;
}>(),
{
type: "default",
closable: true,
}
);
const emit = defineEmits(["close"]);

View File

@ -35,41 +35,30 @@
</button>
</template>
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed } from "vue";
import type { RouteLocationRaw } from "vue-router";
import { useRouter } from "vue-router";
import type { Size, Type } from "./interface";
const props = defineProps({
type: {
type: String as PropType<Type>,
default: "default",
},
size: {
type: String as PropType<Size>,
default: "md",
},
circle: {
type: Boolean,
default: false,
},
block: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
loading: {
type: Boolean,
default: false,
},
route: {
type: Object as PropType<RouteLocationRaw>,
},
});
const props = withDefaults(
defineProps<{
type?: Type;
size?: Size;
circle?: boolean;
block?: boolean;
disabled?: boolean;
loading?: boolean;
route?: RouteLocationRaw;
}>(),
{
type: "default",
size: "md",
circle: false,
block: false,
disabled: false,
loading: false,
}
);
const router = useRouter();
const emit = defineEmits(["click"]);

View File

@ -1,14 +1,8 @@
<script lang="ts" setup>
import type { PropType } from "vue";
defineProps({
title: {
type: String,
},
bodyClass: {
type: Object as PropType<string[]>,
},
});
defineProps<{
title?: string;
bodyClass?: string[];
}>();
</script>
<template>

View File

@ -1,19 +1,15 @@
<script lang="ts" setup>
const props = defineProps({
checked: {
type: Boolean,
default: false,
},
value: {
type: [String, Number, Boolean],
},
label: {
type: String,
},
name: {
type: String,
},
});
const props = withDefaults(
defineProps<{
checked?: boolean;
value?: string | number | boolean;
label?: string;
name?: string;
}>(),
{
checked: false,
}
);
const id = ["checkbox", props.name, props.value]
.filter((item) => !!item)

View File

@ -1,29 +1,20 @@
<script lang="ts" setup>
import { VCheckbox } from "./index";
import type { PropType } from "vue";
const props = defineProps({
modelValue: {
type: Object as PropType<Array<string>>,
default: () => {
return [];
},
},
options: {
type: Object as PropType<Array<Record<string, string>>>,
},
valueKey: {
type: String,
default: "value",
},
labelKey: {
type: String,
default: "label",
},
name: {
type: String,
},
});
const props = withDefaults(
defineProps<{
modelValue?: string[];
options?: Array<Record<string, string>>;
valueKey?: string;
labelKey?: string;
name?: string;
}>(),
{
modelValue: () => [],
valueKey: "value",
labelKey: "label",
}
);
const emit = defineEmits(["update:modelValue", "change"]);

View File

@ -1,5 +1,4 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
import type { EditorStateConfig } from "@codemirror/state";
import { EditorState } from "@codemirror/state";
@ -12,24 +11,20 @@ const languages = {
yaml: StreamLanguage.define(yaml),
};
const props = defineProps({
modelValue: {
type: String,
default: "",
},
height: {
type: String,
default: "auto",
},
language: {
type: String as PropType<"yaml">,
default: "yaml",
},
extensions: {
type: Array as PropType<EditorStateConfig["extensions"]>,
default: () => [],
},
});
const props = withDefaults(
defineProps<{
modelValue?: string;
height?: string;
language?: "yaml";
extensions?: EditorStateConfig["extensions"];
}>(),
{
modelValue: "",
height: "auto",
language: "yaml",
extensions: () => [],
}
);
const emit = defineEmits<{
(e: "update:modelValue", value: string): void;

View File

@ -8,47 +8,32 @@ import {
IconForbidLine,
IconInformation,
} from "@/icons/icons";
import type { PropType } from "vue";
import { computed, ref } from "vue";
import type { Type } from "@/components/dialog/interface";
import type { Type as ButtonType } from "@/components/button/interface";
const props = defineProps({
type: {
type: String as PropType<Type>,
default: "info",
},
title: {
type: String,
default: "提示",
},
description: {
type: String,
default: "",
},
confirmText: {
type: String,
default: "确定",
},
confirmType: {
type: String as PropType<ButtonType>,
default: "primary",
},
cancelText: {
type: String,
default: "取消",
},
visible: {
type: Boolean,
default: false,
},
onConfirm: {
type: Function as PropType<() => void>,
},
onCancel: {
type: Function as PropType<() => void>,
},
});
const props = withDefaults(
defineProps<{
type?: Type;
title?: string;
description?: string;
confirmText?: string;
confirmType?: ButtonType;
cancelText?: string;
visible?: boolean;
onConfirm?: () => void;
onCancel?: () => void;
}>(),
{
type: "info",
title: "提示",
description: "",
confirmText: "确定",
confirmType: "primary",
cancelText: "取消",
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,9 +1,7 @@
<script lang="ts" setup>
defineProps({
title: {
type: String,
},
});
defineProps<{
title?: string;
}>();
</script>
<template>
<div class="flex items-center justify-between bg-white p-4 h-14">

View File

@ -1,24 +1,19 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed } from "vue";
import type { Size } from "./interface";
const props = defineProps({
modelValue: {
type: String,
},
size: {
type: String as PropType<Size>,
default: "md",
},
disabled: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
},
});
const props = withDefaults(
defineProps<{
modelValue?: string;
size?: Size;
disabled?: boolean;
placeholder?: string;
}>(),
{
size: "md",
disabled: false,
}
);
const emit = defineEmits(["update:modelValue"]);

View File

@ -1,13 +1,9 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { provide } from "vue";
const props = defineProps({
openIds: {
type: Object as PropType<string[]>,
required: false,
},
});
const props = defineProps<{
openIds?: string[];
}>();
provide<string[] | undefined>("openIds", props.openIds);
</script>

View File

@ -2,20 +2,18 @@
import { IconArrowRight } from "../../icons/icons";
import { computed, inject, ref, useSlots } from "vue";
const props = defineProps({
id: {
type: String,
default: "",
},
title: {
type: String,
default: "",
},
active: {
type: Boolean,
default: false,
},
});
const props = withDefaults(
defineProps<{
id?: string;
title?: string;
active?: boolean;
}>(),
{
id: "",
title: "",
active: false,
}
);
const emit = defineEmits(["select"]);

View File

@ -1,28 +1,21 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed, nextTick, ref, watch } from "vue";
import { IconClose } from "../../icons/icons";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
},
width: {
type: Number,
default: 500,
},
fullscreen: {
type: Boolean,
default: false,
},
bodyClass: {
type: Object as PropType<string[]>,
},
});
const props = withDefaults(
defineProps<{
visible?: boolean;
title?: string;
width?: number;
fullscreen?: boolean;
bodyClass?: string[];
}>(),
{
visible: false,
width: 500,
fullscreen: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,22 +1,20 @@
<script lang="ts" setup>
import { UseOffsetPagination } from "@vueuse/components";
import { IconArrowLeft, IconArrowRight } from "../../icons/icons";
import { defineProps, ref, toRefs, watch } from "vue";
import { ref, toRefs, watch } from "vue";
const props = defineProps({
page: {
type: Number,
default: 1,
},
size: {
type: Number,
default: 10,
},
total: {
type: Number,
default: 0,
},
});
const props = withDefaults(
defineProps<{
page?: number;
size?: number;
total?: number;
}>(),
{
page: 1,
size: 10,
total: 0,
}
);
const { page, size, total } = toRefs(props);

View File

@ -1,20 +1,12 @@
<script lang="ts" setup>
import { computed } from "vue";
const props = defineProps({
modelValue: {
type: [String, Number, Boolean],
},
value: {
type: [String, Number, Boolean],
},
label: {
type: String,
},
name: {
type: String,
},
});
const props = defineProps<{
modelValue?: string | number | boolean;
value?: string | number | boolean;
label?: string;
name?: string;
}>();
const emit = defineEmits(["update:modelValue", "change"]);

View File

@ -1,26 +1,19 @@
<script lang="ts" setup>
import { VRadio } from "./index";
import type { PropType } from "vue";
defineProps({
modelValue: {
type: [String, Number, Boolean],
},
options: {
type: Object as PropType<Array<Record<string, string | number | boolean>>>,
},
valueKey: {
type: String,
default: "value",
},
labelKey: {
type: String,
default: "label",
},
name: {
type: String,
},
});
withDefaults(
defineProps<{
modelValue?: string | number | boolean;
options?: Array<Record<string, string | number | boolean>>;
valueKey?: string;
labelKey?: string;
name?: string;
}>(),
{
valueKey: "value",
labelKey: "label",
}
);
const emit = defineEmits(["update:modelValue", "change"]);

View File

@ -1,9 +1,7 @@
<script lang="ts" setup>
defineProps({
value: {
type: [String, Number, Boolean],
},
});
defineProps<{
value?: string | number | boolean;
}>();
</script>
<template>

View File

@ -1,24 +1,19 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed } from "vue";
import type { Size } from "./interface";
const props = defineProps({
modelValue: {
type: String,
},
size: {
type: String as PropType<Size>,
default: "md",
},
disabled: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
},
});
const props = withDefaults(
defineProps<{
modelValue?: string;
size?: Size;
disabled?: boolean;
placeholder?: string;
}>(),
{
size: "md",
disabled: false,
}
);
const emit = defineEmits(["update:modelValue"]);

View File

@ -1,23 +1,20 @@
<script lang="ts" setup>
import type { Align, Direction, Spacing } from "./interface";
import { SpacingSize } from "./interface";
import type { PropType } from "vue";
import { computed } from "vue";
const props = defineProps({
spacing: {
type: String as PropType<Spacing>,
default: "xs",
},
direction: {
type: String as PropType<Direction>,
default: "row",
},
align: {
type: String as PropType<Align>,
default: "center",
},
});
const props = withDefaults(
defineProps<{
spacing?: Spacing;
direction?: Direction;
align?: Align;
}>(),
{
spacing: "xs",
direction: "row",
align: "center",
}
);
const wrapperClasses = computed(() => {
const { direction, align } = props;

View File

@ -1,10 +1,12 @@
<script lang="ts" setup>
const props = defineProps({
modelValue: {
type: Boolean,
default: false,
},
});
const props = withDefaults(
defineProps<{
modelValue?: boolean;
}>(),
{
modelValue: false,
}
);
const emit = defineEmits(["update:modelValue", "change"]);

View File

@ -2,14 +2,10 @@
import type { ComputedRef } from "vue";
import { computed, inject } from "vue";
const props = defineProps({
id: {
type: String,
},
label: {
type: String,
},
});
const props = defineProps<{
id?: string;
label?: string;
}>();
const activeId = inject<ComputedRef<string | number | undefined>>("activeId");

View File

@ -1,32 +1,23 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed } from "vue";
import type { Direction, Type } from "./interface";
const props = defineProps({
activeId: {
type: [Number, String],
},
items: {
type: Object as PropType<Array<Record<string, string>>>,
},
type: {
type: String as PropType<Type>,
default: "default",
},
direction: {
type: String as PropType<Direction>,
default: "row",
},
idKey: {
type: String,
default: "id",
},
labelKey: {
type: String,
default: "label",
},
});
const props = withDefaults(
defineProps<{
activeId?: number | string;
items?: Array<Record<string, string>>;
type?: Type;
direction?: Direction;
idKey?: string;
labelKey?: string;
}>(),
{
type: "default",
direction: "row",
idKey: "id",
labelKey: "label",
}
);
const emit = defineEmits(["update:activeId", "change"]);

View File

@ -1,30 +1,24 @@
<script lang="ts" setup>
import type { ComputedRef, PropType } from "vue";
import type { ComputedRef } from "vue";
import { computed, provide, useSlots } from "vue";
import { VTabbar } from "./index";
import type { Direction, Type } from "./interface";
const props = defineProps({
activeId: {
type: [Number, String],
},
type: {
type: String as PropType<Type>,
default: "default",
},
direction: {
type: String as PropType<Direction>,
default: "row",
},
idKey: {
type: String,
default: "id",
},
labelKey: {
type: String,
default: "label",
},
});
const props = withDefaults(
defineProps<{
activeId?: number | string;
type?: Type;
direction?: Direction;
idKey?: string;
labelKey?: string;
}>(),
{
type: "default",
direction: "row",
idKey: "id",
labelKey: "label",
}
);
provide<ComputedRef<string | number | undefined>>(
"activeId",

View File

@ -1,18 +1,17 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed } from "vue";
import type { Theme } from "./interface";
const props = defineProps({
theme: {
type: String as PropType<Theme>,
default: "default",
},
rounded: {
type: Boolean,
default: false,
},
});
const props = withDefaults(
defineProps<{
theme?: Theme;
rounded?: boolean;
}>(),
{
theme: "default",
rounded: false,
}
);
const classes = computed(() => {
return [`tag-${props.theme}`, { "tag-rounded": props.rounded }];

View File

@ -1,20 +1,16 @@
<script lang="ts" setup>
defineProps({
modelValue: {
type: String,
},
disabled: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
},
rows: {
type: Number,
default: 3,
},
});
withDefaults(
defineProps<{
modelValue?: string;
disabled?: boolean;
placeholder?: string;
rows?: number;
}>(),
{
disabled: false,
rows: 3,
}
);
const emit = defineEmits(["update:modelValue"]);

View File

@ -1,12 +1,14 @@
<script lang="ts" setup>
import { VAlert, VButton, VModal, VSpace } from "@halo-dev/components";
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -8,12 +8,14 @@ import {
VTag,
} from "@halo-dev/components";
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,12 +1,14 @@
<script lang="ts" setup>
import { VButton, VModal, VSpace } from "@halo-dev/components";
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,12 +1,14 @@
<script lang="ts" setup>
import { VButton, VCard, VModal } from "@halo-dev/components";
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -10,13 +10,14 @@ import AttachmentLocalStrategyEditingModal from "./AttachmentLocalStrategyEditin
import AttachmentAliOSSStrategyEditingModal from "./AttachmentAliOSSStrategyEditingModal.vue";
import { ref } from "vue";
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);
const strategies = ref([

View File

@ -8,12 +8,14 @@ import { ref } from "vue";
const FilePond = vueFilePond(FilePondPluginImagePreview);
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,17 +1,16 @@
<script lang="ts" setup>
import { VButton, VModal, VSpace } from "@halo-dev/components";
import type { PropType } from "vue";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
category: {
type: Object as PropType<unknown | null>,
default: null,
},
});
withDefaults(
defineProps<{
visible: boolean;
category: unknown | null;
}>(),
{
visible: false,
category: undefined,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -8,7 +8,6 @@ import {
VTabItem,
VTabs,
} from "@halo-dev/components";
import type { PropType } from "vue";
import { ref, unref, watch } from "vue";
import type { Post } from "@halo-dev/admin-api";
@ -17,16 +16,16 @@ interface FormState {
saving: boolean;
}
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
post: {
type: Object as PropType<Post | Record<string, unknown> | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
post: Post | Record<string, unknown> | null;
}>(),
{
visible: false,
post: null,
}
);
const emit = defineEmits(["update:visible", "close", "previous", "next"]);

View File

@ -1,18 +1,16 @@
<script lang="ts" setup>
import { VButton, VModal, VSpace } from "@halo-dev/components";
import type { PropType } from "vue";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
tag: {
type: Object as PropType<unknown | null>,
default: null,
},
});
withDefaults(
defineProps<{
visible: boolean;
tag: unknown | null;
}>(),
{
visible: false,
tag: undefined,
}
);
const emit = defineEmits(["update:visible", "close"]);
const onVisibleChange = (visible: boolean) => {

View File

@ -2,24 +2,22 @@
import { VButton, VModal, VSpace } from "@halo-dev/components";
import type { Menu } from "@halo-dev/api-client";
import { v4 as uuid } from "uuid";
import type { PropType } from "vue";
import { computed, ref, watch } from "vue";
import { apiClient } from "@halo-dev/admin-shared";
import { submitForm } from "@formkit/core";
import { reset, submitForm } from "@formkit/core";
import cloneDeep from "lodash.clonedeep";
import { useMagicKeys } from "@vueuse/core";
import { reset } from "@formkit/core";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
menu: {
type: Object as PropType<Menu | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
menu: Menu | null;
}>(),
{
visible: false,
menu: null,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,25 +1,23 @@
<script lang="ts" setup>
import { VButton, VModal, VSpace } from "@halo-dev/components";
import type { PropType } from "vue";
import { computed, ref, watch, watchEffect } from "vue";
import type { MenuItem } from "@halo-dev/api-client";
import { v4 as uuid } from "uuid";
import { apiClient } from "@halo-dev/admin-shared";
import { submitForm } from "@formkit/core";
import { reset, submitForm } from "@formkit/core";
import cloneDeep from "lodash.clonedeep";
import { useMagicKeys } from "@vueuse/core";
import { reset } from "@formkit/core";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
menuItem: {
type: Object as PropType<MenuItem | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
menuItem: MenuItem | null;
}>(),
{
visible: false,
menuItem: null,
}
);
const emit = defineEmits(["update:visible", "close", "saved"]);

View File

@ -1,16 +1,17 @@
<script lang="ts" setup>
import { IconList, IconSettings, VButton, VSpace } from "@halo-dev/components";
import Draggable from "vuedraggable";
import type { PropType } from "vue";
import { ref } from "vue";
import type { MenuTreeItem } from "@/modules/interface/menus/utils";
defineProps({
menuTreeItems: {
type: Array as PropType<MenuTreeItem[]>,
default: () => [],
},
});
withDefaults(
defineProps<{
menuTreeItems: MenuTreeItem[];
}>(),
{
menuTreeItems: () => [],
}
);
const emit = defineEmits(["change", "open-editing", "delete"]);

View File

@ -7,18 +7,19 @@ import {
VSpace,
} from "@halo-dev/components";
import MenuEditingModal from "./MenuEditingModal.vue";
import type { PropType } from "vue";
import { defineExpose, onMounted, ref } from "vue";
import type { Menu } from "@halo-dev/api-client";
import { apiClient } from "@halo-dev/admin-shared";
import { useRouteQuery } from "@vueuse/router";
const props = defineProps({
selectedMenu: {
type: Object as PropType<Menu | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
selectedMenu: Menu | null;
}>(),
{
selectedMenu: null,
}
);
const emit = defineEmits(["select", "update:selectedMenu"]);

View File

@ -6,12 +6,14 @@ import { apiClient } from "@halo-dev/admin-shared";
const FilePond = VueFilePond();
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -9,25 +9,22 @@ import {
VTag,
} from "@halo-dev/components";
import ThemeInstallModal from "./ThemeInstallModal.vue";
import type { PropType } from "vue";
import { onMounted, ref } from "vue";
import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@halo-dev/admin-shared";
defineProps({
visible: {
type: Boolean,
default: false,
},
selectedTheme: {
type: Object as PropType<Theme | null>,
default: null,
},
activatedTheme: {
type: Object as PropType<Theme | null>,
default: null,
},
});
withDefaults(
defineProps<{
visible: boolean;
selectedTheme: Theme | null;
activatedTheme: Theme | null;
}>(),
{
visible: false,
selectedTheme: null,
activatedTheme: null,
}
);
const emit = defineEmits(["update:visible", "close", "update:selectedTheme"]);

View File

@ -7,12 +7,14 @@ import type { Plugin } from "@halo-dev/api-client";
const FilePond = VueFilePond();
defineProps({
visible: {
type: Boolean,
default: false,
},
});
withDefaults(
defineProps<{
visible: boolean;
}>(),
{
visible: false,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -6,17 +6,18 @@ import {
VSwitch,
VTag,
} from "@halo-dev/components";
import type { PropType } from "vue";
import { toRefs } from "vue";
import { usePluginLifeCycle } from "../composables/use-plugin";
import type { Plugin } from "@halo-dev/api-client";
const props = defineProps({
plugin: {
type: Object as PropType<Plugin | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
plugin: Plugin | null;
}>(),
{
plugin: null,
}
);
const { plugin } = toRefs(props);

View File

@ -1,6 +1,5 @@
<script lang="ts" setup>
import { VButton, VModal, VSpace, VTabItem, VTabs } from "@halo-dev/components";
import type { PropType } from "vue";
import { computed, ref, watch } from "vue";
import { rbacAnnotations } from "@/constants/annotations";
import type { Role } from "@halo-dev/api-client";
@ -9,20 +8,19 @@ import {
useRoleTemplateSelection,
} from "@/modules/system/roles/composables/use-role";
import cloneDeep from "lodash.clonedeep";
import { submitForm } from "@formkit/core";
import { reset, submitForm } from "@formkit/core";
import { useMagicKeys } from "@vueuse/core";
import { reset } from "@formkit/core";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
role: {
type: Object as PropType<Role | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
role: Role | null;
}>(),
{
visible: false,
role: null,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,5 +1,4 @@
<script lang="ts" name="UserEditingModal" setup>
import type { PropType } from "vue";
import { computed, onMounted, ref, watch } from "vue";
import { apiClient } from "@halo-dev/admin-shared";
import type { Role, User } from "@halo-dev/api-client";
@ -19,16 +18,16 @@ import cloneDeep from "lodash.clonedeep";
import { useMagicKeys } from "@vueuse/core";
import { reset, submitForm } from "@formkit/core";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
user: {
type: Object as PropType<User | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
user: User | null;
}>(),
{
visible: false,
user: null,
}
);
const emit = defineEmits(["update:visible", "close"]);

View File

@ -1,21 +1,20 @@
<script lang="ts" setup>
import { VModal, VButton, IconSave } from "@halo-dev/components";
import { IconSave, VButton, VModal } from "@halo-dev/components";
import { inject, ref } from "vue";
import type { User } from "@halo-dev/api-client";
import type { PropType } from "vue";
import { apiClient } from "@halo-dev/admin-shared";
import cloneDeep from "lodash.clonedeep";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
user: {
type: Object as PropType<User | null>,
default: null,
},
});
const props = withDefaults(
defineProps<{
visible: boolean;
user: User | null;
}>(),
{
visible: false,
user: null,
}
);
const emit = defineEmits(["update:visible", "close"]);
const currentUser = inject<User>("currentUser");