diff --git a/web/app/components/develop/doc.tsx b/web/app/components/develop/doc.tsx index abf54fd39dd9d7..ce5471676dba51 100644 --- a/web/app/components/develop/doc.tsx +++ b/web/app/components/develop/doc.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import { useContext } from 'use-context-selector' import { useTranslation } from 'react-i18next' +import { RiListUnordered } from '@remixicon/react' import TemplateEn from './template/template.en.mdx' import TemplateZh from './template/template.zh.mdx' import TemplateAdvancedChatEn from './template/template_advanced_chat.en.mdx' @@ -21,6 +22,7 @@ const Doc = ({ appDetail }: IDocProps) => { const { locale } = useContext(I18n) const { t } = useTranslation() const [toc, setToc] = useState>([]) + const [isTocExpanded, setIsTocExpanded] = useState(false) const variables = appDetail?.model_config?.configs?.prompt_variables || [] const inputs = variables.reduce((res: any, variable: any) => { @@ -28,6 +30,11 @@ const Doc = ({ appDetail }: IDocProps) => { return res }, {}) + useEffect(() => { + const mediaQuery = window.matchMedia('(min-width: 1280px)') + setIsTocExpanded(mediaQuery.matches) + }, []) + useEffect(() => { const extractTOC = () => { const article = document.querySelector('article') @@ -53,21 +60,42 @@ const Doc = ({ appDetail }: IDocProps) => { return (
- +
+ {isTocExpanded + ? ( + + ) + : ( + + )} +
{(appDetail?.mode === 'chat' || appDetail?.mode === 'agent-chat') && ( locale !== LanguagesSupported[1] ? :