diff --git a/src/modules/system/users/components/UserEditingModal.vue b/src/modules/system/users/components/UserEditingModal.vue index de585e807..39932fa60 100644 --- a/src/modules/system/users/components/UserEditingModal.vue +++ b/src/modules/system/users/components/UserEditingModal.vue @@ -6,16 +6,18 @@ import type { Role, User } from "@halo-dev/api-client"; import { IconCodeBoxLine, IconEye, - IconSave, VButton, VCodemirror, VModal, + VSpace, } from "@halo-dev/components"; import { v4 as uuid } from "uuid"; import { roleLabels } from "@/constants/labels"; import { rbacAnnotations } from "@/constants/annotations"; import YAML from "yaml"; import cloneDeep from "lodash.clonedeep"; +import { useMagicKeys } from "@vueuse/core"; +import { submitForm } from "@formkit/core"; const props = defineProps({ visible: { @@ -82,7 +84,20 @@ const basicRoles = computed(() => { ); }); +const { Command_Enter } = useMagicKeys(); + watch(props, (newVal) => { + let keyboardWatcher; + if (newVal.visible) { + keyboardWatcher = watch(Command_Enter, (v) => { + if (v) { + submitForm("user-form"); + } + }); + } else { + keyboardWatcher?.unwatch(); + } + if (newVal.visible && props.user) { formState.value.user = cloneDeep(props.user); return; @@ -148,6 +163,7 @@ const handleRawModeChange = () => { formState.value.user = YAML.parse(formState.value.raw); } }; + onMounted(handleFetchRoles);