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

View File

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