chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,96 @@
|
||||
'use client'
|
||||
import type { ButtonProps } from '@langgenius/dify-ui/button'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
import { useDebugKey } from '@/service/use-plugins'
|
||||
import KeyValueItem from '../base/key-value-item'
|
||||
import { PluginSidecarPanel } from './plugin-sidecar-panel'
|
||||
|
||||
const i18nPrefix = 'debugInfo'
|
||||
|
||||
type DebugInfoProps = {
|
||||
triggerClassName?: string
|
||||
triggerContent?: ReactNode
|
||||
triggerVariant?: ButtonProps['variant']
|
||||
}
|
||||
|
||||
function DebugInfo({
|
||||
triggerClassName,
|
||||
triggerContent,
|
||||
triggerVariant = 'secondary',
|
||||
}: DebugInfoProps) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const docLink = useDocLink()
|
||||
const { data: info, isLoading } = useDebugKey()
|
||||
const title = t(($) => $[`${i18nPrefix}.title`], { ns: 'plugin' })
|
||||
const trigger = triggerContent ?? <span aria-hidden className="i-ri-bug-line size-4" />
|
||||
const triggerClassNames = cn(
|
||||
!triggerClassName && 'size-full p-2 text-components-button-secondary-text',
|
||||
triggerClassName,
|
||||
)
|
||||
|
||||
// info.key likes 4580bdb7-b878-471c-a8a4-bfd760263a53 mask the middle part using *.
|
||||
const maskedKey = info?.key?.replace(/(.{8})(.*)(.{8})/, '$1********$3')
|
||||
|
||||
if (isLoading) return null
|
||||
|
||||
if (!info) {
|
||||
return (
|
||||
<Button variant={triggerVariant} className={triggerClassNames} aria-label={title} disabled>
|
||||
{trigger}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button variant={triggerVariant} className={triggerClassNames} aria-label={title}>
|
||||
{trigger}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<PopoverContent side="top" align="start" className="border-0 bg-transparent p-0 shadow-none">
|
||||
<PluginSidecarPanel
|
||||
title={title}
|
||||
footer={
|
||||
<div className="flex w-full shrink-0 flex-col items-start">
|
||||
<div className="flex w-full shrink-0 items-center justify-end gap-2 px-4 pt-2 pb-4">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1">
|
||||
<a
|
||||
href={docLink(
|
||||
'/develop-plugin/features-and-specs/plugin-types/remote-debug-a-plugin',
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex cursor-pointer items-center gap-1 rounded-xs system-xs-regular text-text-accent focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
|
||||
>
|
||||
<span>{t(($) => $[`${i18nPrefix}.viewDocs`], { ns: 'plugin' })}</span>
|
||||
<span aria-hidden className="i-ri-arrow-right-up-line size-3" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="flex w-full shrink-0 flex-col items-start justify-center gap-1 px-4 py-2">
|
||||
<KeyValueItem label="Port" value={`${info.host}:${info.port}`} />
|
||||
<KeyValueItem
|
||||
label="Key"
|
||||
value={info.key || ''}
|
||||
maskedValue={maskedKey}
|
||||
valueMaxWidthClassName="max-w-[224px]"
|
||||
/>
|
||||
</div>
|
||||
</PluginSidecarPanel>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
export default DebugInfo
|
||||
Reference in new issue
Block a user