feat(dify): 把本地控制台的中文与去外链改动入库

这些界面改动和专家服务草稿停在工作区,没有随上一笔主分支提交进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-23 09:44:09 +08:00
1 parent 9c7c80e194
commit c2cb845a32
211 files changed
+3030 -2794

No files matched your search

@@ -3,6 +3,7 @@ import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiBookOpenLine, RiEqualizer2Line } from '@remixicon/react'
import * as React from 'react'
import { isOfficialDifyUrl } from '@/utils/official-link'
type HeaderProps = {
isInPipeline?: boolean
@@ -43,17 +44,19 @@ const Header = ({
{!isInPipeline && <span className="system-xs-medium">{buttonText}</span>}
</Button>
</div>
<a
className="flex items-center gap-x-1 overflow-hidden system-xs-medium text-text-accent"
href={docLink}
target="_blank"
rel="noopener noreferrer"
>
<RiBookOpenLine className="size-3.5 shrink-0" />
<span className="grow truncate" title={docTitle}>
{docTitle}
</span>
</a>
{docLink && !isOfficialDifyUrl(docLink) && (
<a
className="flex items-center gap-x-1 overflow-hidden system-xs-medium text-text-accent"
href={docLink}
target="_blank"
rel="noopener noreferrer"
>
<RiBookOpenLine className="size-3.5 shrink-0" />
<span className="grow truncate" title={docTitle}>
{docTitle}
</span>
</a>
)}
</div>
)
}
@@ -4,7 +4,6 @@ import { Button } from '@langgenius/dify-ui/button'
import * as React from 'react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDocLink } from '@/context/i18n'
import Input from './text-input'
const I18N_PREFIX = 'stepOne.website'
@@ -16,7 +15,6 @@ type Props = Readonly<{
const UrlInput: FC<Props> = ({ isRunning, onRun }) => {
const { t } = useTranslation(['datasetCreation'])
const docLink = useDocLink()
const [url, setUrl] = useState('')
const handleUrlChange = useCallback((url: string | number) => {
setUrl(url as string)
@@ -28,7 +26,7 @@ const UrlInput: FC<Props> = ({ isRunning, onRun }) => {
return (
<div className="flex items-center justify-between gap-x-2">
<Input value={url} onChange={handleUrlChange} placeholder={docLink()} />
<Input value={url} onChange={handleUrlChange} placeholder="https://example.com" />
<Button variant="primary" onClick={handleOnRun} loading={isRunning}>
{t(($) => $[`${I18N_PREFIX}.run`], { ns: 'datasetCreation' })}
</Button>
@@ -30,7 +30,7 @@ vi.mock('@/utils', () => ({
// Mock i18n context
vi.mock('@/context/i18n', () => ({
useDocLink: () => (path?: string) =>
path ? `https://docs.dify.ai/en${path}` : 'https://docs.dify.ai/en/',
path ? `https://docs.dify.ai/en${path}` : 'https://example.com',
}))
// Note: limit and max_depth are typed as `number | string` in CrawlOptions
@@ -138,7 +138,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const urlInput = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const urlInput = screen.getByPlaceholderText('https://example.com')
await user.type(urlInput, 'https://example.com')
const runButton = screen.getByRole('button', { name: /run/i })
@@ -173,7 +173,7 @@ describe('WaterCrawl', () => {
// Options should be visible initially
expect(screen.getByText('datasetCreation.stepOne.website.crawlSubPage'))!.toBeInTheDocument()
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://example.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -273,7 +273,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps({ crawlOptions })
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://api-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -302,7 +302,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps({ crawlOptions })
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -327,7 +327,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://fail-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -353,7 +353,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://error-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -386,7 +386,7 @@ describe('WaterCrawl', () => {
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })
render(<WaterCrawl {...props} />)
await user.type(
screen.getByPlaceholderText('https://docs.dify.ai/en/'),
screen.getByPlaceholderText('https://example.com'),
'https://example.com',
)
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -411,7 +411,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://no-status-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -443,7 +443,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'invalid-url')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -457,7 +457,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'example.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -482,7 +482,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'http://example.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -498,7 +498,7 @@ describe('WaterCrawl', () => {
})
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://example.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -517,7 +517,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://exception-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -544,7 +544,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://empty-error-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -572,7 +572,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps({ onCheckedCrawlResultChange })
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://empty-data-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -605,7 +605,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps({ onCheckedCrawlResultChange })
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://null-data-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -631,7 +631,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps({ onCheckedCrawlResultChange })
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://undefined-data-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -658,7 +658,7 @@ describe('WaterCrawl', () => {
})
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://zero-current-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -686,7 +686,7 @@ describe('WaterCrawl', () => {
})
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://zero-total-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -721,7 +721,7 @@ describe('WaterCrawl', () => {
})
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://both-zero-test.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -750,7 +750,7 @@ describe('WaterCrawl', () => {
const props = createDefaultProps()
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://time.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -801,7 +801,7 @@ describe('WaterCrawl', () => {
})
render(<WaterCrawl {...props} />)
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://full-workflow.com')
await user.click(screen.getByRole('button', { name: /run/i }))
@@ -863,7 +863,7 @@ describe('WaterCrawl', () => {
render(<WaterCrawl {...props} />)
// Step 1: Enter URL
const input = screen.getByPlaceholderText('https://docs.dify.ai/en/')
const input = screen.getByPlaceholderText('https://example.com')
await user.type(input, 'https://preview.com')
// Step 2: Run crawl