diff --git a/src/components/form/AnnotationsForm.vue b/src/components/form/AnnotationsForm.vue index 2d640f3fd..5547fe012 100644 --- a/src/components/form/AnnotationsForm.vue +++ b/src/components/form/AnnotationsForm.vue @@ -148,7 +148,11 @@ const specFormInvalid = ref(true); const customFormInvalid = ref(true); const handleSubmit = async () => { - submitForm("specForm"); + if (avaliableAnnotationSettings.value.length) { + submitForm("specForm"); + } else { + specFormInvalid.value = false; + } submitForm("customForm"); await nextTick(); }; diff --git a/src/modules/contents/pages/components/SinglePageSettingModal.vue b/src/modules/contents/pages/components/SinglePageSettingModal.vue index bb31dd731..07d9e2f0e 100644 --- a/src/modules/contents/pages/components/SinglePageSettingModal.vue +++ b/src/modules/contents/pages/components/SinglePageSettingModal.vue @@ -9,6 +9,7 @@ import { singlePageLabels } from "@/constants/labels"; import { randomUUID } from "@/utils/id"; import { toDatetimeLocal, toISOString } from "@/utils/date"; import { submitForm } from "@formkit/core"; +import AnnotationsForm from "@/components/form/AnnotationsForm.vue"; const initialFormState: SinglePage = { spec: { @@ -75,6 +76,8 @@ const onVisibleChange = (visible: boolean) => { } }; +const annotationsFormRef = ref>(); + const handleSubmit = () => { if (submitType.value === "publish") { handlePublish(); @@ -101,6 +104,20 @@ const handlePublishClick = () => { }; const handleSave = async () => { + annotationsFormRef.value?.handleSubmit(); + await nextTick(); + + const { customAnnotations, annotations, customFormInvalid, specFormInvalid } = + annotationsFormRef.value || {}; + if (customFormInvalid || specFormInvalid) { + return; + } + + formState.value.metadata.annotations = { + ...annotations, + ...customAnnotations, + }; + if (props.onlyEmit) { emit("saved", formState.value); return; @@ -138,6 +155,20 @@ const handleSave = async () => { }; const handlePublish = async () => { + annotationsFormRef.value?.handleSubmit(); + await nextTick(); + + const { customAnnotations, annotations, customFormInvalid, specFormInvalid } = + annotationsFormRef.value || {}; + if (customFormInvalid || specFormInvalid) { + return; + } + + formState.value.metadata.annotations = { + ...annotations, + ...customAnnotations, + }; + if (props.onlyEmit) { emit("published", formState.value); return; @@ -364,6 +395,27 @@ const onPublishTimeChange = (value: string) => { +
+
+
+ +
+
+
+ 元数据 +
+
+
+ +
+
+