Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import React from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { RiBookReadLine } from '@remixicon/react'
|
|
import cn from '@/utils/classnames'
|
|
import { ReadmeShowType, useReadmePanelStore } from './store'
|
|
import { BUILTIN_TOOLS_ARRAY } from './constants'
|
|
import type { PluginDetail } from '../types'
|
|
|
|
export const ReadmeEntrance = ({
|
|
pluginDetail,
|
|
showType = ReadmeShowType.drawer,
|
|
className,
|
|
showShortTip = false,
|
|
}: {
|
|
pluginDetail: PluginDetail
|
|
showType?: ReadmeShowType
|
|
className?: string
|
|
showShortTip?: boolean
|
|
}) => {
|
|
const { t } = useTranslation()
|
|
const { setCurrentPluginDetail } = useReadmePanelStore()
|
|
|
|
const handleReadmeClick = () => {
|
|
if (pluginDetail)
|
|
setCurrentPluginDetail(pluginDetail, showType)
|
|
}
|
|
if (!pluginDetail || BUILTIN_TOOLS_ARRAY.includes(pluginDetail.id))
|
|
return null
|
|
|
|
return (
|
|
<div className={cn('flex flex-col items-start justify-center gap-2 pb-4 pt-0', showType === ReadmeShowType.drawer && 'px-4', className)}>
|
|
{!showShortTip && <div className="relative h-1 w-8 shrink-0">
|
|
<div className="h-px w-full bg-divider-regular"></div>
|
|
</div>}
|
|
|
|
<button
|
|
onClick={handleReadmeClick}
|
|
className="flex w-full items-center justify-start gap-1 text-text-tertiary transition-opacity hover:text-text-accent-light-mode-only"
|
|
>
|
|
<div className="relative flex h-3 w-3 items-center justify-center overflow-hidden">
|
|
<RiBookReadLine className="h-3 w-3" />
|
|
</div>
|
|
<span className="text-xs font-normal leading-4">
|
|
{!showShortTip ? t('plugin.readmeInfo.needHelpCheckReadme') : t('plugin.readmeInfo.title')}
|
|
</span>
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|