Parcourir la source

:art: formatting

visuddhinanda il y a 3 ans
Parent
commit
43ec6808f7
1 fichiers modifiés avec 83 ajouts et 81 suppressions
  1. 83 81
      dashboard/src/components/comment/CommentCreate.tsx

+ 83 - 81
dashboard/src/components/comment/CommentCreate.tsx

@@ -32,92 +32,94 @@ const Widget = ({ resId = "", resType = "", parent, onCreated }: IWidget) => {
   return (
     <div>
       <div>{_currUser?.nickName}:</div>
-      <ProForm<IComment>
-        {...formItemLayout}
-        layout="horizontal"
-        formRef={formRef}
-        submitter={{
-          render: (props, doms) => {
-            return (
-              <Row>
-                <Col span={14} offset={4}>
-                  <Space>{doms}</Space>
-                </Col>
-              </Row>
-            );
-          },
-        }}
-        onFinish={async (values) => {
-          //新建
-          console.log("create", resId, resType, parent);
+      <div>
+        <ProForm<IComment>
+          {...formItemLayout}
+          layout="horizontal"
+          formRef={formRef}
+          submitter={{
+            render: (props, doms) => {
+              return (
+                <Row>
+                  <Col span={14} offset={4}>
+                    <Space>{doms}</Space>
+                  </Col>
+                </Row>
+              );
+            },
+          }}
+          onFinish={async (values) => {
+            //新建
+            console.log("create", resId, resType, parent);
 
-          post<ICommentRequest, ICommentResponse>(`/v2/discussion`, {
-            res_id: resId,
-            res_type: resType,
-            parent: parent,
-            title: values.title,
-            content: values.content,
-          })
-            .then((json) => {
-              console.log("new discussion", json);
-              if (json.ok) {
-                formRef.current?.resetFields();
-                if (typeof onCreated !== "undefined") {
-                  onCreated({
-                    id: json.data.id,
-                    resId: json.data.res_id,
-                    resType: json.data.res_type,
-                    user: {
-                      id: json.data.editor?.id ? json.data.editor.id : "null",
-                      nickName: json.data.editor?.nickName
-                        ? json.data.editor.nickName
-                        : "null",
-                      realName: json.data.editor?.userName
-                        ? json.data.editor.userName
-                        : "null",
-                      avatar: json.data.editor?.avatar
-                        ? json.data.editor.avatar
-                        : "null",
-                    },
-                    title: json.data.title,
-                    parent: json.data.parent,
-                    content: json.data.content,
-                    createdAt: json.data.created_at,
-                    updatedAt: json.data.updated_at,
-                  });
-                }
-              } else {
-                message.error(json.message);
-              }
+            post<ICommentRequest, ICommentResponse>(`/v2/discussion`, {
+              res_id: resId,
+              res_type: resType,
+              parent: parent,
+              title: values.title,
+              content: values.content,
             })
-            .catch((e) => {
-              message.error(e.message);
-            });
-        }}
-        params={{}}
-      >
-        {parent ? (
-          <></>
-        ) : (
-          <ProFormText
-            name="title"
-            label={intl.formatMessage({ id: "forms.fields.title.label" })}
-            tooltip="最长为 24 位"
+              .then((json) => {
+                console.log("new discussion", json);
+                if (json.ok) {
+                  formRef.current?.resetFields();
+                  if (typeof onCreated !== "undefined") {
+                    onCreated({
+                      id: json.data.id,
+                      resId: json.data.res_id,
+                      resType: json.data.res_type,
+                      user: {
+                        id: json.data.editor?.id ? json.data.editor.id : "null",
+                        nickName: json.data.editor?.nickName
+                          ? json.data.editor.nickName
+                          : "null",
+                        realName: json.data.editor?.userName
+                          ? json.data.editor.userName
+                          : "null",
+                        avatar: json.data.editor?.avatar
+                          ? json.data.editor.avatar
+                          : "null",
+                      },
+                      title: json.data.title,
+                      parent: json.data.parent,
+                      content: json.data.content,
+                      createdAt: json.data.created_at,
+                      updatedAt: json.data.updated_at,
+                    });
+                  }
+                } else {
+                  message.error(json.message);
+                }
+              })
+              .catch((e) => {
+                message.error(e.message);
+              });
+          }}
+          params={{}}
+        >
+          {parent ? (
+            <></>
+          ) : (
+            <ProFormText
+              name="title"
+              label={intl.formatMessage({ id: "forms.fields.title.label" })}
+              tooltip="最长为 24 位"
+              placeholder={intl.formatMessage({
+                id: "forms.message.title.required",
+              })}
+              rules={[{ required: true, message: "这是必填项" }]}
+            />
+          )}
+
+          <ProFormTextArea
+            name="content"
+            label={intl.formatMessage({ id: "forms.fields.content.label" })}
             placeholder={intl.formatMessage({
-              id: "forms.message.title.required",
+              id: "forms.fields.content.placeholder",
             })}
-            rules={[{ required: true, message: "这是必填项" }]}
           />
-        )}
-
-        <ProFormTextArea
-          name="content"
-          label={intl.formatMessage({ id: "forms.fields.content.label" })}
-          placeholder={intl.formatMessage({
-            id: "forms.fields.content.placeholder",
-          })}
-        />
-      </ProForm>
+        </ProForm>
+      </div>
     </div>
   );
 };