Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.tsx 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import ChatOverviewModal from '@/components/api-service/chat-overview-modal';
  2. import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
  3. import { useFetchFlow } from '@/hooks/flow-hooks';
  4. import { ArrowLeftOutlined } from '@ant-design/icons';
  5. import { Button, Flex, Space } from 'antd';
  6. import { Link, useParams } from 'umi';
  7. import FlowIdModal from '../flow-id-modal';
  8. import {
  9. useSaveGraph,
  10. useSaveGraphBeforeOpeningDebugDrawer,
  11. useWatchAgentChange,
  12. } from '../hooks';
  13. import styles from './index.less';
  14. interface IProps {
  15. showChatDrawer(): void;
  16. }
  17. const FlowHeader = ({ showChatDrawer }: IProps) => {
  18. const { saveGraph } = useSaveGraph();
  19. const handleRun = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer);
  20. const { data } = useFetchFlow();
  21. const { t } = useTranslate('flow');
  22. const {
  23. visible: overviewVisible,
  24. hideModal: hideOverviewModal,
  25. // showModal: showOverviewModal,
  26. } = useSetModalState();
  27. const { visible, hideModal, showModal } = useSetModalState();
  28. const { id } = useParams();
  29. const time = useWatchAgentChange();
  30. return (
  31. <>
  32. <Flex
  33. align="center"
  34. justify={'space-between'}
  35. gap={'large'}
  36. className={styles.flowHeader}
  37. >
  38. <Space size={'large'}>
  39. <Link to={`/flow`}>
  40. <ArrowLeftOutlined />
  41. </Link>
  42. <div className="flex flex-col">
  43. <span className="font-semibold text-[18px]">{data.title}</span>
  44. <span className="font-normal text-sm">已自动保存 {time}</span>
  45. </div>
  46. </Space>
  47. <Space size={'large'}>
  48. <Button onClick={handleRun}>
  49. <b>{t('run')}</b>
  50. </Button>
  51. <Button type="primary" onClick={saveGraph}>
  52. <b>{t('save')}</b>
  53. </Button>
  54. {/* <Button type="primary" onClick={showOverviewModal} disabled>
  55. <b>{t('publish')}</b>
  56. </Button> */}
  57. <Button type="primary" onClick={showModal}>
  58. <b>Agent ID</b>
  59. </Button>
  60. </Space>
  61. </Flex>
  62. {overviewVisible && (
  63. <ChatOverviewModal
  64. visible={overviewVisible}
  65. hideModal={hideOverviewModal}
  66. id={id!}
  67. idKey="canvasId"
  68. ></ChatOverviewModal>
  69. )}
  70. {visible && <FlowIdModal hideModal={hideModal}></FlowIdModal>}
  71. </>
  72. );
  73. };
  74. export default FlowHeader;