| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import CopyToClipboard from '@/components/copy-to-clipboard';
- import HightLightMarkdown from '@/components/highlight-markdown';
- import { SharedFrom } from '@/constants/chat';
- import { useTranslate } from '@/hooks/common-hooks';
- import { IModalProps } from '@/interfaces/common';
- import { Card, Modal, Tabs, TabsProps, Typography } from 'antd';
-
- import { useIsDarkTheme } from '@/components/theme-provider';
- import { cn } from '@/lib/utils';
- import styles from './index.less';
-
- const { Paragraph, Link } = Typography;
-
- const EmbedModal = ({
- visible,
- hideModal,
- token = '',
- form,
- beta = '',
- isAgent,
- }: IModalProps<any> & {
- token: string;
- form: SharedFrom;
- beta: string;
- isAgent: boolean;
- }) => {
- const { t } = useTranslate('chat');
- const isDarkTheme = useIsDarkTheme();
-
- const text = `
- ~~~ html
- <iframe
- src="${location.origin}/ss-ragflow/chat/share?shared_id=${token}&from=${form}&auth=${beta}"
- style="width: 100%; height: 100%; min-height: 600px"
- frameborder="0"
- >
- </iframe>
- ~~~
- `;
-
- const items: TabsProps['items'] = [
- {
- key: '1',
- label: t('fullScreenTitle'),
- children: (
- <Card
- title={t('fullScreenDescription')}
- extra={<CopyToClipboard text={text}></CopyToClipboard>}
- className={styles.codeCard}
- >
- <HightLightMarkdown>{text}</HightLightMarkdown>
- </Card>
- ),
- },
- {
- key: '2',
- label: t('partialTitle'),
- children: t('comingSoon'),
- },
- {
- key: '3',
- label: t('extensionTitle'),
- children: t('comingSoon'),
- },
- ];
-
- const onChange = (key: string) => {
- console.log(key);
- };
-
- return (
- <Modal
- title={t('embedIntoSite', { keyPrefix: 'common' })}
- open={visible}
- style={{ top: 300 }}
- width={'50vw'}
- onOk={hideModal}
- onCancel={hideModal}
- >
- <Tabs defaultActiveKey="1" items={items} onChange={onChange} />
- <div className="text-base font-medium mt-4 mb-1">
- {t(isAgent ? 'flow' : 'chat', { keyPrefix: 'header' })}
- <span className="ml-1 inline-block">ID</span>
- </div>
- <Paragraph
- copyable={{ text: token }}
- className={cn(styles.id, {
- [styles.darkId]: isDarkTheme,
- })}
- >
- {token}
- </Paragraph>
- <Link
- href={
- isAgent
- ? 'https://ragflow.io/docs/dev/http_api_reference#create-session-with-agent'
- : 'https://ragflow.io/docs/dev/http_api_reference#create-session-with-chat-assistant'
- }
- target="_blank"
- >
- {t('howUseId', { keyPrefix: isAgent ? 'flow' : 'chat' })}
- </Link>
- </Modal>
- );
- };
-
- export default EmbedModal;
|