From afabffc54640fbe35c43985214e232714c4b48f0 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 27 May 2024 16:56:57 +0800 Subject: [PATCH] refactor: typing component template refs for VModal (#5994) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind improvement /milestone 2.16.x #### What this PR does / why we need it: 为 VModal 组件的引用添加类型。 See https://vuejs.org/guide/typescript/composition-api.html#typing-component-template-refs #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../AttachmentGroupEditingModal.vue | 6 ++--- .../components/AttachmentPoliciesModal.vue | 4 ++-- .../AttachmentPolicyEditingModal.vue | 6 ++--- .../components/AttachmentUploadModal.vue | 4 ++-- .../components/ReplyCreationModal.vue | 6 ++--- .../components/SinglePageSettingModal.vue | 24 +++++++++---------- .../components/CategoryEditingModal.vue | 6 ++--- .../posts/tags/components/TagEditingModal.vue | 6 ++--- .../menus/components/MenuEditingModal.vue | 6 ++--- .../menus/components/MenuItemEditingModal.vue | 6 ++--- .../themes/components/ThemeListModal.vue | 6 ++--- .../components/PluginInstallationModal.vue | 6 ++--- .../roles/components/RoleEditingModal.vue | 2 +- .../users/components/GrantPermissionModal.vue | 2 +- .../users/components/UserCreationModal.vue | 2 +- .../users/components/UserEditingModal.vue | 2 +- .../components/UserPasswordChangeModal.vue | 2 +- .../global-search/GlobalSearchModal.vue | 2 +- ui/src/components/login/LoginModal.vue | 2 +- .../posts/components/PostCreationModal.vue | 6 ++--- .../posts/components/PostSettingEditModal.vue | 6 ++--- .../profile/components/EmailVerifyModal.vue | 14 +++++------ .../components/PasswordChangeModal.vue | 2 +- .../PersonalAccessTokenCreationModal.vue | 4 ++-- .../components/ProfileEditingModal.vue | 2 +- .../tabs/components/TotpConfigureModal.vue | 6 ++--- .../tabs/components/TotpDeletionModal.vue | 6 ++--- .../tabs/components/TwoFactorDisableModal.vue | 6 ++--- .../tabs/components/TwoFactorEnableModal.vue | 6 ++--- 29 files changed, 79 insertions(+), 79 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index d91ef4670..6ef068d4f 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -23,7 +23,7 @@ const emit = defineEmits<{ const { t } = useI18n(); -const modal = ref(); +const modal = ref | null>(null); const formState = ref({ spec: { displayName: "", @@ -60,7 +60,7 @@ const handleSave = async () => { } Toast.success(t("core.common.toast.save_success")); - modal.value.close(); + modal.value?.close(); } catch (e) { console.error("Failed to save attachment group", e); } finally { @@ -112,7 +112,7 @@ onMounted(() => { @submit="$formkit.submit('attachment-group-form')" > - + {{ $t("core.common.buttons.cancel_and_shortcut") }} diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPoliciesModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPoliciesModal.vue index e3c2a8f83..c4c9e85d3 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPoliciesModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPoliciesModal.vue @@ -33,7 +33,7 @@ const { t } = useI18n(); const { policies, isLoading, handleFetchPolicies } = useFetchAttachmentPolicy(); const { policyTemplates } = useFetchAttachmentPolicyTemplate(); -const modal = ref(); +const modal = ref | null>(null); const selectedPolicy = ref(); const selectedTemplateName = ref(); @@ -200,7 +200,7 @@ function getPolicyTemplateDisplayName(templateName: string) { diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index 6e34053de..41a432041 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -29,7 +29,7 @@ const emit = defineEmits<{ const { t } = useI18n(); -const modal = ref(); +const modal = ref | null>(null); const formState = ref({ spec: { @@ -167,7 +167,7 @@ const handleSave = async () => { } Toast.success(t("core.common.toast.save_success")); - modal.value.close(); + modal.value?.close(); } catch (e) { console.error("Failed to save attachment policy", e); } finally { @@ -234,7 +234,7 @@ const modalTitle = props.policy @submit="$formkit.submit('attachment-policy-form')" > - + {{ $t("core.common.buttons.cancel_and_shortcut") }} diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue index 4b80b8b7f..241677284 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -26,7 +26,7 @@ const { groups } = useFetchAttachmentGroup(); const { policies, handleFetchPolicies } = useFetchAttachmentPolicy(); const { policyTemplates } = useFetchAttachmentPolicyTemplate(); -const modal = ref(); +const modal = ref | null>(null); const selectedGroupName = useLocalStorage("attachment-upload-group", ""); const selectedPolicyName = useLocalStorage("attachment-upload-policy", ""); const policyEditingModal = ref(false); @@ -169,7 +169,7 @@ const onEditingModalClose = async () => { ? '' : $t('core.attachment.upload_modal.filters.policy.not_select') " - :done-button-handler="() => modal.close()" + :done-button-handler="() => modal?.close()" /> diff --git a/ui/console-src/modules/contents/comments/components/ReplyCreationModal.vue b/ui/console-src/modules/contents/comments/components/ReplyCreationModal.vue index fca40eaef..f1e6d41c8 100644 --- a/ui/console-src/modules/contents/comments/components/ReplyCreationModal.vue +++ b/ui/console-src/modules/contents/comments/components/ReplyCreationModal.vue @@ -39,7 +39,7 @@ const emit = defineEmits<{ (event: "close"): void; }>(); -const modal = ref(); +const modal = ref | null>(null); const formState = ref({ raw: "", content: "", @@ -67,7 +67,7 @@ const handleCreateReply = async () => { replyRequest: formState.value, }); - modal.value.close(); + modal.value?.close(); Toast.success( t("core.comment.reply_modal.operations.submit.toast_success") @@ -149,7 +149,7 @@ const onEmojiSelect = (emoji: { native: string }) => { @submit="$formkit.submit('create-reply-form')" > - + {{ $t("core.common.buttons.cancel_and_shortcut") }} diff --git a/ui/console-src/modules/contents/pages/components/SinglePageSettingModal.vue b/ui/console-src/modules/contents/pages/components/SinglePageSettingModal.vue index 208b9e5a6..6907469d1 100644 --- a/ui/console-src/modules/contents/pages/components/SinglePageSettingModal.vue +++ b/ui/console-src/modules/contents/pages/components/SinglePageSettingModal.vue @@ -1,4 +1,14 @@ @@ -92,7 +92,7 @@ async function onSubmit(data: PostFormState) { > {{ $t("core.common.buttons.save") }} - + {{ $t("core.common.buttons.close") }} diff --git a/ui/uc-src/modules/profile/components/EmailVerifyModal.vue b/ui/uc-src/modules/profile/components/EmailVerifyModal.vue index 818ce8ddc..94efb0555 100644 --- a/ui/uc-src/modules/profile/components/EmailVerifyModal.vue +++ b/ui/uc-src/modules/profile/components/EmailVerifyModal.vue @@ -1,11 +1,11 @@