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

@@ -277,16 +277,16 @@ it('closes compact navigation after changing the settings section', async () =>
})
it('preserves the host title in settings and updates it for route navigation', () => {
document.title = 'Workspace settings - Dify'
document.title = 'Workspace settings - 甘肃省房地产价格评估行业协会'
const view = renderPage()
expect(document.title).toBe('Workspace settings - Dify')
expect(document.title).toBe('Workspace settings - 甘肃省房地产价格评估行业协会')
view.rerender(<IntegrationsPage section="provider" syncDocumentTitle />)
expect(document.title).toBe(
'navigation.settings.provider · navigation.mainNav.integrations - Dify',
'navigation.settings.provider · navigation.mainNav.integrations - 甘肃省房地产价格评估行业协会',
)
view.rerender(<IntegrationsPage section="data-source" syncDocumentTitle />)
expect(document.title).toBe(
'navigation.settings.dataSource · navigation.mainNav.integrations - Dify',
'navigation.settings.dataSource · navigation.mainNav.integrations - 甘肃省房地产价格评估行业协会',
)
})
@@ -362,31 +362,24 @@ it.each([
expect(screen.getByRole('link', { name: heading })).toHaveAttribute('aria-current', 'page')
})
it.each([
['provider', '/plugins/model'],
['data-source', '/plugins/datasource'],
] as const)('opens the %s marketplace from its actual section action', async (section, path) => {
const user = userEvent.setup()
renderPage({ props: { section } })
const action = 'plugin.marketplace.difyMarketplace'
await user.click(await screen.findByRole('button', { name: action }))
expect(window.open).toHaveBeenCalledWith(
expect.stringContaining(`${path}?source=`),
'_blank',
'noopener,noreferrer',
)
})
it.each(['provider', 'data-source'] as const)(
'does not open the official %s marketplace',
async (section) => {
renderPage({ props: { section } })
expect(
screen.queryByRole('button', { name: 'plugin.marketplace.difyMarketplace' }),
).not.toBeInTheDocument()
expect(window.open).not.toHaveBeenCalled()
},
)
it('opens the category marketplace path from the install menu', async () => {
it('opens the in-app marketplace from the install menu', async () => {
const user = userEvent.setup()
renderPage({ props: { section: 'trigger' } })
await user.click(await screen.findByRole('button', { name: 'plugin.installAction' }))
await user.click(screen.getByRole('menuitem', { name: 'plugin.source.marketplace' }))
expect(window.open).toHaveBeenCalledExactlyOnceWith(
expect.stringContaining('/plugins/trigger?source='),
'_blank',
'noopener,noreferrer',
)
expect(api.push).toHaveBeenCalledExactlyOnceWith('/marketplace')
expect(window.open).not.toHaveBeenCalled()
})
it('saves category-specific automatic update settings from the toolbar', async () => {
@@ -579,17 +579,11 @@ it.each([
},
)
it('loads the tool marketplace when the user expands it', async () => {
const user = userEvent.setup()
it('does not show the marketplace catalog on builtin tools', async () => {
renderProviderList({ marketplace: true })
await user.click(screen.getByRole('button', { name: 'plugin.marketplace.moreFrom' }))
await waitFor(() =>
expect(api.collections).toHaveBeenCalledWith(
{ query: expect.objectContaining({ category: 'tool', exclude: [] }) },
expect.anything(),
),
)
expect(screen.getByText('plugin.marketplace.moreFrom')).toBeInTheDocument()
await act(async () => {})
expect(screen.queryByText('plugin.marketplace.moreFrom')).not.toBeInTheDocument()
expect(api.collections).not.toHaveBeenCalled()
})
it('loads an installed plugin detail and closes it without losing the catalog', async () => {
@@ -29,13 +29,9 @@ import {
import { Suspense, useId, useRef, useState, useSyncExternalStore } from 'react'
import { useTranslation } from 'react-i18next'
import { UpdateSettingDialog } from '@/app/components/header/account-setting/update-setting-dialog'
import {
buildIntegrationPath,
buildMarketplaceUrlPathByIntegrationSection,
toolCategoryBySection,
} from '@/app/components/integrations/routes'
import { buildIntegrationPath, toolCategoryBySection } from '@/app/components/integrations/routes'
import { useDocLink } from '@/context/i18n'
import { useMarketplace } from '@/features/marketplace/client'
import { isOfficialDifyUrl } from '@/utils/official-link'
import useDocumentTitle from '@/hooks/use-document-title'
import Link from '@/next/link'
import { useRouter } from '@/next/navigation'
@@ -100,15 +96,17 @@ const DescriptionWithLearnMore = ({ children, href, label }: DescriptionWithLear
<span className="min-w-0 break-words whitespace-normal sm:truncate" title={title}>
{children}
</span>
<Link
className="inline-flex shrink-0 items-center text-text-accent"
href={href}
target="_blank"
rel="noopener noreferrer"
>
{label}
<span aria-hidden className="i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100" />
</Link>
{href && !isOfficialDifyUrl(href) ? (
<Link
className="inline-flex shrink-0 items-center text-text-accent"
href={href}
target="_blank"
rel="noopener noreferrer"
>
{label}
<span aria-hidden className="i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100" />
</Link>
) : null}
</span>
)
}
@@ -214,8 +212,6 @@ export default function IntegrationsPage({
<UpdateSettingDialog category={pluginSettingCategory} />
</div>
) : undefined
const marketplace = useMarketplace()
const marketplaceUrlPath = buildMarketplaceUrlPathByIntegrationSection(section)
const headerDescription =
integrationHeader?.description ??
(section === 'provider'
@@ -234,13 +230,7 @@ export default function IntegrationsPage({
headerDescription
)
const handleSwitchToMarketplace = () => {
if (!marketplace) return
window.open(
marketplace.page(marketplaceUrlPath, undefined, window.location.origin),
'_blank',
'noopener,noreferrer',
)
router.push('/marketplace')
}
const handleSelectSection = (nextSection: IntegrationSection) => {
if (onSectionChange) {
@@ -9,6 +9,7 @@ import Icon from '@/app/components/plugins/card/base/card-icon'
import CornerMark from '@/app/components/plugins/card/base/corner-mark'
import { useGetLanguage } from '@/context/i18n'
import { renderI18nObject } from '@/i18n/metadata'
import { visibleAuthorName } from '@/utils/visible-author'
const getCollectionPluginIdentity = (collection: Collection) => {
const [org, ...nameParts] = collection.plugin_id?.split('/').filter(Boolean) ?? []
@@ -43,6 +44,10 @@ function IntegrationsToolProviderCard({
const { t } = useTranslation(['dataset', 'tools'])
const title = renderI18nObject(collection.label, language)
const description = renderI18nObject(collection.description, language)
const authorName = visibleAuthorName(collection.author)
const authorLabel = authorName
? `${t(($) => $.author, { ns: 'tools' })} ${authorName}`
: undefined
const { org, name } = getCollectionPluginIdentity(collection)
const toolsCount = collection.tools?.length ?? 0
const builtInLabel = t(($) => $['metadata.datasetMetadata.builtIn'], { ns: 'dataset' })
@@ -69,13 +74,9 @@ function IntegrationsToolProviderCard({
</div>
<div
className="h-4 truncate system-xs-regular text-text-tertiary"
title={
collection.author
? `${t(($) => $.author, { ns: 'tools' })} ${collection.author}`
: undefined
}
title={authorLabel}
>
{collection.author && `${t(($) => $.author, { ns: 'tools' })} ${collection.author}`}
{authorLabel}
</div>
</div>
</div>
@@ -129,10 +130,10 @@ function IntegrationsToolProviderCard({
</div>
<div className="flex h-6.5 w-full items-center gap-2 px-3 pt-1.5 pb-1">
<div className="flex h-4 min-w-0 flex-1 items-center gap-0.5 system-xs-regular">
{!!org && (
{!!visibleAuthorName(org) && (
<>
<div className="min-w-0 shrink truncate text-text-tertiary" title={org}>
{org}
<div className="min-w-0 shrink truncate text-text-tertiary" title={visibleAuthorName(org)}>
{visibleAuthorName(org)}
</div>
<div className="shrink-0 text-text-quaternary">/</div>
</>
@@ -28,7 +28,6 @@ import {
useCanManageMCP,
useCanManageTools,
} from '@/app/components/tools/hooks/use-tool-permissions'
import { BuiltinMarketplacePanel } from '@/app/components/tools/marketplace/builtin-marketplace-panel'
import MCPList from '@/app/components/tools/mcp'
import ProviderDetail from '@/app/components/tools/provider/detail'
import { ToolProviderGrid } from '@/app/components/tools/tool-provider-grid'
@@ -36,7 +35,6 @@ import {
selectToolCollections,
selectToolsWithProvider,
} from '@/app/components/tools/utils/query-select'
import { useMarketplace } from '@/features/marketplace/client'
import { consoleQuery } from '@/service/console'
import { useCheckInstalled, useInvalidateInstalledPluginList } from '@/service/use-plugins'
import { useToolProviderCategory } from './hooks/use-tool-provider-category'
@@ -59,7 +57,6 @@ const ProviderList = ({ category, contentInset = 'default', layout }: ProviderLi
const { canDeletePlugin, canSetPluginPreferences, canUpdatePlugin } = usePluginSettingsAccess()
const canManageTools = useCanManageTools()
const canManageMCP = useCanManageMCP()
const marketplace = useMarketplace()
const { activeTab, handleCategoryChange, isRouteCategory } = useToolProviderCategory(category)
const contentPaddingClassName = toolsContentInsetClassNames[contentInset]
const toolListFrameClassName = cn(contentPaddingClassName, toolsUnifiedContentFrameClassName)
@@ -234,15 +231,6 @@ const ProviderList = ({ category, contentInset = 'default', layout }: ProviderLi
{isCollectionSearchEmpty && activeTab === 'builtin' && (
<div className={cn('h-56 shrink-0', toolListFrameClassName)} />
)}
{marketplace && activeTab === 'builtin' && (
<BuiltinMarketplacePanel
marketplace={marketplace}
containerRef={containerRef}
contentInset={contentInset}
keywords={keywords}
tagFilterValue={tagFilterValue}
/>
)}
{activeTab === 'mcp' && (
<MCPList
providers={activeTabCollectionList}