From 55bff10f0dcc59b5246c49912e08f653fdf070df Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Fri, 13 Jun 2025 14:42:27 +0800 Subject: [PATCH] fix --- web/app/components/workflow/nodes/code/use-config.ts | 5 ++--- .../components/workflow/nodes/data-source/panel.tsx | 12 ++++++++---- .../components/workflow/operator/export-image.tsx | 8 +++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/web/app/components/workflow/nodes/code/use-config.ts b/web/app/components/workflow/nodes/code/use-config.ts index 13b8962439..16f06c18ce 100644 --- a/web/app/components/workflow/nodes/code/use-config.ts +++ b/web/app/components/workflow/nodes/code/use-config.ts @@ -10,7 +10,6 @@ import { CodeLanguage } from './types' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run' import { fetchNodeDefault } from '@/service/workflow' -import { useStore as useAppStore } from '@/app/components/app/store' import { useNodesReadOnly, } from '@/app/components/workflow/hooks' @@ -18,7 +17,7 @@ import { const useConfig = (id: string, payload: CodeNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() - const appId = useAppStore.getState().appDetail?.id + const appId = useStore(s => s.appId) const [allLanguageDefault, setAllLanguageDefault] = useState | null>(null) useEffect(() => { @@ -34,7 +33,7 @@ const useConfig = (id: string, payload: CodeNodeType) => { } }, [appId]) - const defaultConfig = useStore(s => s.nodesDefaultConfigs)[payload.type] + const defaultConfig = useStore(s => s.nodesDefaultConfigs)?.[payload.type] const { inputs, setInputs } = useNodeCrud(id, payload) const { handleVarListChange, handleAddVariable } = useVarList({ inputs, diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx index 1d79e5a119..4e498fd780 100644 --- a/web/app/components/workflow/nodes/data-source/panel.tsx +++ b/web/app/components/workflow/nodes/data-source/panel.tsx @@ -159,8 +159,9 @@ const Panel: FC> = ({ id, data }) => { } { - COMMON_OUTPUT.map(item => ( + COMMON_OUTPUT.map((item, index) => ( > = ({ id, data }) => { )) } { - isLocalFile && LOCAL_FILE_OUTPUT.map(item => ( + isLocalFile && LOCAL_FILE_OUTPUT.map((item, index) => ( > = ({ id, data }) => { )) } { - isWebsiteCrawl && WEBSITE_CRAWL_OUTPUT.map(item => ( + isWebsiteCrawl && WEBSITE_CRAWL_OUTPUT.map((item, index) => ( > = ({ id, data }) => { )) } { - isOnlineDocument && ONLINE_DOCUMENT_OUTPUT.map(item => ( + isOnlineDocument && ONLINE_DOCUMENT_OUTPUT.map((item, index) => ( { const { t } = useTranslation() @@ -23,9 +24,10 @@ const ExportImage: FC = () => { const appDetail = useAppStore(s => s.appDetail) const [open, setOpen] = useState(false) + const knowledgeName = useStore(s => s.knowledgeName) const handleExportImage = useCallback(async (type: 'png' | 'jpeg' | 'svg') => { - if (!appDetail) + if (!appDetail && !knowledgeName) return if (getNodesReadOnly()) @@ -60,7 +62,7 @@ const ExportImage: FC = () => { const link = document.createElement('a') link.href = dataUrl - link.download = `${appDetail.name}.${type}` + link.download = `${appDetail ? appDetail.name : knowledgeName}.${type}` document.body.appendChild(link) link.click() document.body.removeChild(link) @@ -68,7 +70,7 @@ const ExportImage: FC = () => { catch (error) { console.error('Export image failed:', error) } - }, [getNodesReadOnly, appDetail]) + }, [getNodesReadOnly, appDetail, knowledgeName]) const handleTrigger = useCallback(() => { if (getNodesReadOnly())