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,60 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { selectPipelineDependencies } from '@/app/components/rag-pipeline/utils/query-select'
|
||||
import { toast } from '@/app/notifications'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { getErrorMessage } from '@/utils/error-message'
|
||||
import { useStore as usePluginDependenciesStore } from './store'
|
||||
|
||||
export const usePluginDependencies = () => {
|
||||
const { t } = useTranslation(['common'])
|
||||
const { mutateAsync: checkWorkflowDependencies } = useMutation(
|
||||
consoleQuery.apps.imports.byAppId.checkDependencies.get.mutationOptions({
|
||||
context: { silent: true },
|
||||
}),
|
||||
)
|
||||
const { mutateAsync: checkPipelineDependencies } = useMutation(
|
||||
consoleQuery.rag.pipelines.imports.byPipelineId.checkDependencies.get.mutationOptions(),
|
||||
)
|
||||
|
||||
const handleCheckPluginDependencies = useCallback(
|
||||
async (id: string, isPipeline = false) => {
|
||||
const { setDependencies } = usePluginDependenciesStore.getState()
|
||||
if (isPipeline) {
|
||||
setDependencies(
|
||||
selectPipelineDependencies(
|
||||
await checkPipelineDependencies({ params: { pipeline_id: id } }),
|
||||
),
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
const { leaked_dependencies } = await checkWorkflowDependencies({ params: { app_id: id } })
|
||||
setDependencies(
|
||||
(leaked_dependencies ?? []).map((dependency) => ({
|
||||
...dependency,
|
||||
// The legacy dependency store represents an absent version with undefined.
|
||||
value: { ...dependency.value, version: dependency.value.version ?? undefined },
|
||||
})),
|
||||
)
|
||||
return true
|
||||
} catch (error) {
|
||||
setDependencies([])
|
||||
toast.error(
|
||||
t(($) => $.error, { ns: 'common' }),
|
||||
{
|
||||
description: getErrorMessage(error),
|
||||
},
|
||||
)
|
||||
return false
|
||||
}
|
||||
},
|
||||
[checkWorkflowDependencies, checkPipelineDependencies, t],
|
||||
)
|
||||
|
||||
return {
|
||||
handleCheckPluginDependencies,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user