pull/20801/head
Bowen Liang 12 months ago
parent eef7f7ccf5
commit 562f30237c

@ -31,7 +31,7 @@ import { useAppContext } from '@/context/app-context'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import LinkedAppsPanel from '@/app/components/base/linked-apps-panel' import LinkedAppsPanel from '@/app/components/base/linked-apps-panel'
import useDocumentTitle from '@/hooks/use-document-title' import useDocumentTitle from '@/hooks/use-document-title'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
export type IAppDetailLayoutProps = { export type IAppDetailLayoutProps = {
children: React.ReactNode children: React.ReactNode

@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import OperationBtn from '@/app/components/app/configuration/base/operation-btn' import OperationBtn from '@/app/components/app/configuration/base/operation-btn'
import Panel from '@/app/components/app/configuration/base/feature-panel' import Panel from '@/app/components/app/configuration/base/feature-panel'
import { MessageClockCircle } from '@/app/components/base/icons/src/vender/solid/general' import { MessageClockCircle } from '@/app/components/base/icons/src/vender/solid/general'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
type Props = { type Props = {
showWarning: boolean showWarning: boolean
@ -44,7 +44,7 @@ const HistoryPanel: FC<Props> = ({
<div className='flex justify-between rounded-b-xl bg-background-section-burn px-3 py-2 text-xs text-text-secondary'> <div className='flex justify-between rounded-b-xl bg-background-section-burn px-3 py-2 text-xs text-text-secondary'>
<div>{t('appDebug.feature.conversationHistory.tip')} <div>{t('appDebug.feature.conversationHistory.tip')}
<a href={docLink('/learn-more/extended-reading/what-is-llmops', <a href={docLink('/learn-more/extended-reading/what-is-llmops',
{ 'zh-hans': '/learn-more/extended-reading/prompt-engineering/README' })} { 'zh-Hans': '/learn-more/extended-reading/prompt-engineering/README' })}
target='_blank' rel='noopener noreferrer' target='_blank' rel='noopener noreferrer'
className='text-[#155EEF]'>{t('appDebug.feature.conversationHistory.learnMore')} className='text-[#155EEF]'>{t('appDebug.feature.conversationHistory.learnMore')}
</a> </a>

@ -31,7 +31,7 @@ import {
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { fetchMembers } from '@/service/common' import { fetchMembers } from '@/service/common'
import type { Member } from '@/models/common' import type { Member } from '@/models/common'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
type SettingsModalProps = { type SettingsModalProps = {
currentDataset: DataSet currentDataset: DataSet
onCancel: () => void onCancel: () => void

@ -29,7 +29,7 @@ import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { getRedirection } from '@/utils/app-redirection' import { getRedirection } from '@/utils/app-redirection'
import FullScreenModal from '@/app/components/base/fullscreen-modal' import FullScreenModal from '@/app/components/base/fullscreen-modal'
import useTheme from '@/hooks/use-theme' import useTheme from '@/hooks/use-theme'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
type CreateAppProps = { type CreateAppProps = {
onSuccess: () => void onSuccess: () => void

@ -24,8 +24,8 @@ import { useProviderContext } from '@/context/provider-context'
import { useModalContext } from '@/context/modal-context' import { useModalContext } from '@/context/modal-context'
import type { AppIconSelection } from '@/app/components/base/app-icon-picker' import type { AppIconSelection } from '@/app/components/base/app-icon-picker'
import AppIconPicker from '@/app/components/base/app-icon-picker' import AppIconPicker from '@/app/components/base/app-icon-picker'
import { useDocLink } from '@/i18n/language'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useDocLink } from '@/context/i18n'
export type ISettingsModalProps = { export type ISettingsModalProps = {
isChat: boolean isChat: boolean

@ -33,7 +33,7 @@ import { useModalContext } from '@/context/modal-context'
import { IS_CLOUD_EDITION } from '@/config' import { IS_CLOUD_EDITION } from '@/config'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useGlobalPublicStore } from '@/context/global-public-context' import { useGlobalPublicStore } from '@/context/global-public-context'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
export default function AppSelector() { export default function AppSelector() {
const itemClassName = ` const itemClassName = `

@ -25,7 +25,7 @@ import { EDUCATION_VERIFYING_LOCALSTORAGE_ITEM } from '@/app/education-apply/con
import { getLocaleOnClient } from '@/i18n' import { getLocaleOnClient } from '@/i18n'
import { noop } from 'lodash-es' import { noop } from 'lodash-es'
import DifyLogo from '../components/base/logo/dify-logo' import DifyLogo from '../components/base/logo/dify-logo'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
const EducationApplyAge = () => { const EducationApplyAge = () => {
const { t } = useTranslation() const { t } = useTranslation()
const locale = getLocaleOnClient() const locale = getLocaleOnClient()

@ -6,7 +6,7 @@ import {
} from '@remixicon/react' } from '@remixicon/react'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { getLocaleOnClient } from '@/i18n' import { getLocaleOnClient } from '@/i18n'
import { useDocLink } from '@/i18n/language' import { useDocLink } from '@/context/i18n'
export type IConfirm = { export type IConfirm = {
className?: string className?: string

@ -3,7 +3,6 @@ import {
useContext, useContext,
} from 'use-context-selector' } from 'use-context-selector'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n'
import { getLocaleOnClient } from '@/i18n'
import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n/language' import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n/language'
import { noop } from 'lodash-es' import { noop } from 'lodash-es'
@ -36,11 +35,14 @@ export const useGetPricingPageLanguage = () => {
return getPricingPageLanguage(locale) return getPricingPageLanguage(locale)
} }
const baseDocUrl = 'https://docs.dify.ai' const defaultDocBaseUrl = 'https://docs.dify.ai'
export const getDocLink = (path: string, pathMap?: { [index: string]: string }) => { export const useDocLink = (baseUrl?: string): ((path: string, pathMap?: { [index: string]: string }) => string) => {
const docLanguage = getLocaleOnClient() === 'zh-Hans' ? 'zh-hans' : 'en' const { locale } = useI18N()
const targetPath = (pathMap !== undefined) ? pathMap[docLanguage] || path : path return (path: string, pathMap?: { [index: string]: string }): string => {
const baseDocUrl = baseUrl || defaultDocBaseUrl
const docLanguage = getDocLanguage(locale)
const targetPath = (pathMap !== undefined) ? pathMap[locale] || path : path
return (targetPath.startsWith('/')) ? `${baseDocUrl}/${docLanguage}${targetPath}` : `${baseDocUrl}/${docLanguage}/${targetPath}` return (targetPath.startsWith('/')) ? `${baseDocUrl}/${docLanguage}${targetPath}` : `${baseDocUrl}/${docLanguage}/${targetPath}`
}
} }
export default I18NContext export default I18NContext

@ -1,5 +1,4 @@
import data from './languages.json' import data from './languages.json'
import { getLocaleOnClient } from '@/i18n/index'
export type Item = { export type Item = {
value: number | string value: number | string
name: string name: string
@ -50,17 +49,6 @@ export const getDocLanguage = (locale: string) => {
return DOC_LANGUAGE[locale] || 'en' return DOC_LANGUAGE[locale] || 'en'
} }
const officialDocBaseUrl = 'https://docs.dify.ai'
export const useDocLink = (baseUrl?: string): ((path: string, pathMap?: { [index: string]: string }) => string) => {
return (path: string, pathMap?: { [index: string]: string }): string => {
const baseDocUrl = baseUrl || officialDocBaseUrl
const locale = getLocaleOnClient()
const docLanguage = getDocLanguage(locale)
const targetPath = (pathMap !== undefined) ? pathMap[locale] || path : path
return (targetPath.startsWith('/')) ? `${baseDocUrl}/${docLanguage}${targetPath}` : `${baseDocUrl}/${docLanguage}/${targetPath}`
}
}
const PRICING_PAGE_LANGUAGE: Record<string, string> = { const PRICING_PAGE_LANGUAGE: Record<string, string> = {
'ja-JP': 'jp', 'ja-JP': 'jp',
} }

Loading…
Cancel
Save