|
|
@@ -40,110 +40,116 @@ const Widget = ({
|
|
|
labelCol: { span: 4 },
|
|
|
wrapperCol: { span: 20 },
|
|
|
};
|
|
|
- return (
|
|
|
- <div>
|
|
|
- <div>{_currUser?.nickName}:</div>
|
|
|
+ if (typeof _currUser === "undefined") {
|
|
|
+ return <></>;
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
<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);
|
|
|
- console.log("value", values);
|
|
|
- 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);
|
|
|
- }
|
|
|
+ <div>{_currUser?.nickName}:</div>
|
|
|
+ <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);
|
|
|
+ console.log("value", values);
|
|
|
+ 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 位"
|
|
|
- placeholder={intl.formatMessage({
|
|
|
- id: "forms.message.title.required",
|
|
|
- })}
|
|
|
- rules={[{ required: true, message: "这是必填项" }]}
|
|
|
- />
|
|
|
- )}
|
|
|
- {editor === "text" ? (
|
|
|
- <ProFormTextArea
|
|
|
- name="content"
|
|
|
- label={intl.formatMessage({ id: "forms.fields.content.label" })}
|
|
|
- placeholder={intl.formatMessage({
|
|
|
- id: "forms.fields.content.placeholder",
|
|
|
- })}
|
|
|
- />
|
|
|
- ) : editor === "html" ? (
|
|
|
- <Form.Item
|
|
|
- name="content"
|
|
|
- label={intl.formatMessage({ id: "forms.fields.content.label" })}
|
|
|
- tooltip="可以直接粘贴屏幕截图"
|
|
|
- >
|
|
|
- <ReactQuill theme="snow" style={{ height: 220 }} />
|
|
|
- </Form.Item>
|
|
|
- ) : (
|
|
|
- <></>
|
|
|
- )}
|
|
|
- </ProForm>
|
|
|
+ .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: "这是必填项" }]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ {editor === "text" ? (
|
|
|
+ <ProFormTextArea
|
|
|
+ name="content"
|
|
|
+ label={intl.formatMessage({ id: "forms.fields.content.label" })}
|
|
|
+ placeholder={intl.formatMessage({
|
|
|
+ id: "forms.fields.content.placeholder",
|
|
|
+ })}
|
|
|
+ />
|
|
|
+ ) : editor === "html" ? (
|
|
|
+ <Form.Item
|
|
|
+ name="content"
|
|
|
+ label={intl.formatMessage({ id: "forms.fields.content.label" })}
|
|
|
+ tooltip="可以直接粘贴屏幕截图"
|
|
|
+ >
|
|
|
+ <ReactQuill theme="snow" style={{ height: 220 }} />
|
|
|
+ </Form.Item>
|
|
|
+ ) : (
|
|
|
+ <></>
|
|
|
+ )}
|
|
|
+ </ProForm>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- );
|
|
|
+ );
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
export default Widget;
|