feat: change show publish

This commit is contained in:
xion 2024-10-27 17:47:20 +08:00
parent ce3c29ca0d
commit 1bc7494e4f
2 changed files with 19 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { Button, Input, message, Modal, Select, Table, Tooltip } from 'antd'; import { Button, Input, message, Modal, Select, Switch, Table, Tooltip } from 'antd';
import { Fragment, useEffect, useMemo, useState } from 'react'; import { Fragment, useEffect, useMemo, useState } from 'react';
import { TextArea } from '../components/TextArea'; import { TextArea } from '../components/TextArea';
import { useContainerStore } from '../store'; import { useContainerStore } from '../store';
@ -22,6 +22,7 @@ import clsx from 'clsx';
import { isObjectNull } from '@/utils/is-null'; import { isObjectNull } from '@/utils/is-null';
import { CardBlank } from '@/components/card/CardBlank'; import { CardBlank } from '@/components/card/CardBlank';
import { useAiStore } from '@/pages/ai-chat'; import { useAiStore } from '@/pages/ai-chat';
import { update } from 'lodash-es';
const FormModal = () => { const FormModal = () => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const containerStore = useContainerStore( const containerStore = useContainerStore(
@ -106,7 +107,8 @@ const PublishFormModal = () => {
showEdit: state.showPublish, showEdit: state.showPublish,
setShowEdit: state.setShowPublish, setShowEdit: state.setShowPublish,
formData: state.formData, formData: state.formData,
updateData: state.publishData, publishData: state.publishData,
updateData: state.updateData,
}; };
}), }),
); );
@ -122,6 +124,10 @@ const PublishFormModal = () => {
} }
}, [containerStore.showEdit]); }, [containerStore.showEdit]);
const onFinish = async (values: any) => { const onFinish = async (values: any) => {
containerStore.publishData(values);
};
const onUpdate = async () => {
const values = form.getFieldsValue();
containerStore.updateData(values); containerStore.updateData(values);
}; };
const onClose = () => { const onClose = () => {
@ -165,13 +171,17 @@ const PublishFormModal = () => {
<Form.Item name={['publish', 'fileName']} label='file name' required> <Form.Item name={['publish', 'fileName']} label='file name' required>
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item name={['publish', 'saveHTML']} label='save html'>
<Switch />
</Form.Item>
<Form.Item label=' ' colon={false}> <Form.Item label=' ' colon={false}>
<Button type='primary' htmlType='submit'> <div className='flex gap-3'>
Submit <Button type='primary' htmlType='submit'>
</Button> Save And Publish
<Button className='ml-2' htmlType='reset' onClick={onClose}> </Button>
Cancel <Button onClick={onUpdate}> Save</Button>
</Button> <Button onClick={onClose}>Cancel</Button>
</div>
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>

View File

@ -49,7 +49,7 @@ export const useContainerStore = create<ContainerStore>((set, get) => {
}); });
if (res.code === 200) { if (res.code === 200) {
message.success('Success'); message.success('Success');
set({ showEdit: false, formData: res.data }); set({ showEdit: false, showPublish: false, formData: res.data });
getList(); getList();
} else { } else {
message.error(res.message || 'Request failed'); message.error(res.message || 'Request failed');