You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import CopyToClipboard from '@/components/copy-to-clipboard';
  2. import HightLightMarkdown from '@/components/highlight-markdown';
  3. import { SharedFrom } from '@/constants/chat';
  4. import { useTranslate } from '@/hooks/common-hooks';
  5. import { IModalProps } from '@/interfaces/common';
  6. import { Card, Modal, Tabs, TabsProps, Typography } from 'antd';
  7. import { useIsDarkTheme } from '@/components/theme-provider';
  8. import { cn } from '@/lib/utils';
  9. import styles from './index.less';
  10. const { Paragraph, Link } = Typography;
  11. const EmbedModal = ({
  12. visible,
  13. hideModal,
  14. token = '',
  15. form,
  16. beta = '',
  17. isAgent,
  18. }: IModalProps<any> & {
  19. token: string;
  20. form: SharedFrom;
  21. beta: string;
  22. isAgent: boolean;
  23. }) => {
  24. const { t } = useTranslate('chat');
  25. const isDarkTheme = useIsDarkTheme();
  26. const text = `
  27. ~~~ html
  28. <iframe
  29. src="${location.origin}/ss-ragflow/chat/share?shared_id=${token}&from=${form}&auth=${beta}"
  30. style="width: 100%; height: 100%; min-height: 600px"
  31. frameborder="0"
  32. >
  33. </iframe>
  34. ~~~
  35. `;
  36. const items: TabsProps['items'] = [
  37. {
  38. key: '1',
  39. label: t('fullScreenTitle'),
  40. children: (
  41. <Card
  42. title={t('fullScreenDescription')}
  43. extra={<CopyToClipboard text={text}></CopyToClipboard>}
  44. className={styles.codeCard}
  45. >
  46. <HightLightMarkdown>{text}</HightLightMarkdown>
  47. </Card>
  48. ),
  49. },
  50. {
  51. key: '2',
  52. label: t('partialTitle'),
  53. children: t('comingSoon'),
  54. },
  55. {
  56. key: '3',
  57. label: t('extensionTitle'),
  58. children: t('comingSoon'),
  59. },
  60. ];
  61. const onChange = (key: string) => {
  62. console.log(key);
  63. };
  64. return (
  65. <Modal
  66. title={t('embedIntoSite', { keyPrefix: 'common' })}
  67. open={visible}
  68. style={{ top: 300 }}
  69. width={'50vw'}
  70. onOk={hideModal}
  71. onCancel={hideModal}
  72. >
  73. <Tabs defaultActiveKey="1" items={items} onChange={onChange} />
  74. <div className="text-base font-medium mt-4 mb-1">
  75. {t(isAgent ? 'flow' : 'chat', { keyPrefix: 'header' })}
  76. <span className="ml-1 inline-block">ID</span>
  77. </div>
  78. <Paragraph
  79. copyable={{ text: token }}
  80. className={cn(styles.id, {
  81. [styles.darkId]: isDarkTheme,
  82. })}
  83. >
  84. {token}
  85. </Paragraph>
  86. <Link
  87. href={
  88. isAgent
  89. ? 'https://ragflow.io/docs/dev/http_api_reference#create-session-with-agent'
  90. : 'https://ragflow.io/docs/dev/http_api_reference#create-session-with-chat-assistant'
  91. }
  92. target="_blank"
  93. >
  94. {t('howUseId', { keyPrefix: isAgent ? 'flow' : 'chat' })}
  95. </Link>
  96. </Modal>
  97. );
  98. };
  99. export default EmbedModal;