mirror of https://github.com/langgenius/dify.git
fix
This commit is contained in:
parent
45c9b77e82
commit
55bff10f0d
|
|
@ -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<Record<CodeLanguage, CodeNodeType> | 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<CodeNodeType>(id, payload)
|
||||
const { handleVarListChange, handleAddVariable } = useVarList<CodeNodeType>({
|
||||
inputs,
|
||||
|
|
|
|||
|
|
@ -159,8 +159,9 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
|||
}
|
||||
<OutputVars>
|
||||
{
|
||||
COMMON_OUTPUT.map(item => (
|
||||
COMMON_OUTPUT.map((item, index) => (
|
||||
<VarItem
|
||||
key={index}
|
||||
name={item.name}
|
||||
type={item.type}
|
||||
description={item.description}
|
||||
|
|
@ -168,8 +169,9 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
|||
))
|
||||
}
|
||||
{
|
||||
isLocalFile && LOCAL_FILE_OUTPUT.map(item => (
|
||||
isLocalFile && LOCAL_FILE_OUTPUT.map((item, index) => (
|
||||
<VarItem
|
||||
key={index}
|
||||
name={item.name}
|
||||
type={item.type}
|
||||
description={item.description}
|
||||
|
|
@ -182,8 +184,9 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
|||
))
|
||||
}
|
||||
{
|
||||
isWebsiteCrawl && WEBSITE_CRAWL_OUTPUT.map(item => (
|
||||
isWebsiteCrawl && WEBSITE_CRAWL_OUTPUT.map((item, index) => (
|
||||
<VarItem
|
||||
key={index}
|
||||
name={item.name}
|
||||
type={item.type}
|
||||
description={item.description}
|
||||
|
|
@ -191,8 +194,9 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
|
|||
))
|
||||
}
|
||||
{
|
||||
isOnlineDocument && ONLINE_DOCUMENT_OUTPUT.map(item => (
|
||||
isOnlineDocument && ONLINE_DOCUMENT_OUTPUT.map((item, index) => (
|
||||
<VarItem
|
||||
key={index}
|
||||
name={item.name}
|
||||
type={item.type}
|
||||
description={item.description}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
PortalToFollowElemContent,
|
||||
PortalToFollowElemTrigger,
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
|
||||
const ExportImage: FC = () => {
|
||||
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())
|
||||
|
|
|
|||
Loading…
Reference in New Issue