mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 11:56:55 +08:00
Merge remote-tracking branch 'origin/feat/rag-2' into feat/rag-2
This commit is contained in:
commit
64fc0c9073
@ -30,7 +30,7 @@ export const useWorkflowInit = () => {
|
|||||||
const [data, setData] = useState<FetchWorkflowDraftResponse>()
|
const [data, setData] = useState<FetchWorkflowDraftResponse>()
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
workflowStore.setState({ appId: appDetail.id })
|
workflowStore.setState({ appId: appDetail.id, appName: appDetail.name })
|
||||||
}, [appDetail.id, workflowStore])
|
}, [appDetail.id, workflowStore])
|
||||||
|
|
||||||
const handleUpdateWorkflowConfig = useCallback((config: Record<string, any>) => {
|
const handleUpdateWorkflowConfig = useCallback((config: Record<string, any>) => {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import type { StateCreator } from 'zustand'
|
|||||||
|
|
||||||
export type WorkflowSliceShape = {
|
export type WorkflowSliceShape = {
|
||||||
appId: string
|
appId: string
|
||||||
|
appName: string
|
||||||
notInitialWorkflow: boolean
|
notInitialWorkflow: boolean
|
||||||
setNotInitialWorkflow: (notInitialWorkflow: boolean) => void
|
setNotInitialWorkflow: (notInitialWorkflow: boolean) => void
|
||||||
nodesDefaultConfigs: Record<string, any>
|
nodesDefaultConfigs: Record<string, any>
|
||||||
@ -11,6 +12,7 @@ export type WorkflowSliceShape = {
|
|||||||
export type CreateWorkflowSlice = StateCreator<WorkflowSliceShape>
|
export type CreateWorkflowSlice = StateCreator<WorkflowSliceShape>
|
||||||
export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = set => ({
|
export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = set => ({
|
||||||
appId: '',
|
appId: '',
|
||||||
|
appName: '',
|
||||||
notInitialWorkflow: false,
|
notInitialWorkflow: false,
|
||||||
setNotInitialWorkflow: notInitialWorkflow => set(() => ({ notInitialWorkflow })),
|
setNotInitialWorkflow: notInitialWorkflow => set(() => ({ notInitialWorkflow })),
|
||||||
nodesDefaultConfigs: {},
|
nodesDefaultConfigs: {},
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { useNodesReadOnly } from '../hooks'
|
|||||||
import TipPopup from './tip-popup'
|
import TipPopup from './tip-popup'
|
||||||
import { RiExportLine } from '@remixicon/react'
|
import { RiExportLine } from '@remixicon/react'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
||||||
import {
|
import {
|
||||||
PortalToFollowElem,
|
PortalToFollowElem,
|
||||||
PortalToFollowElemContent,
|
PortalToFollowElemContent,
|
||||||
@ -25,14 +24,14 @@ const ExportImage: FC = () => {
|
|||||||
const { getNodesReadOnly } = useNodesReadOnly()
|
const { getNodesReadOnly } = useNodesReadOnly()
|
||||||
const reactFlow = useReactFlow()
|
const reactFlow = useReactFlow()
|
||||||
|
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [previewUrl, setPreviewUrl] = useState('')
|
const [previewUrl, setPreviewUrl] = useState('')
|
||||||
const [previewTitle, setPreviewTitle] = useState('')
|
const [previewTitle, setPreviewTitle] = useState('')
|
||||||
const knowledgeName = useStore(s => s.knowledgeName)
|
const knowledgeName = useStore(s => s.knowledgeName)
|
||||||
|
const appName = useStore(s => s.appName)
|
||||||
|
|
||||||
const handleExportImage = useCallback(async (type: 'png' | 'jpeg' | 'svg', currentWorkflow = false) => {
|
const handleExportImage = useCallback(async (type: 'png' | 'jpeg' | 'svg', currentWorkflow = false) => {
|
||||||
if (!appDetail && !knowledgeName)
|
if (!appName && !knowledgeName)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (getNodesReadOnly())
|
if (getNodesReadOnly())
|
||||||
@ -43,6 +42,7 @@ const ExportImage: FC = () => {
|
|||||||
if (!flowElement) return
|
if (!flowElement) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let filename = appName || knowledgeName
|
||||||
const filter = (node: HTMLElement) => {
|
const filter = (node: HTMLElement) => {
|
||||||
if (node instanceof HTMLImageElement)
|
if (node instanceof HTMLImageElement)
|
||||||
return node.complete && node.naturalHeight !== 0
|
return node.complete && node.naturalHeight !== 0
|
||||||
@ -51,7 +51,6 @@ const ExportImage: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let dataUrl
|
let dataUrl
|
||||||
let filename = `${appDetail.name}`
|
|
||||||
|
|
||||||
if (currentWorkflow) {
|
if (currentWorkflow) {
|
||||||
// Get all nodes and their bounds
|
// Get all nodes and their bounds
|
||||||
@ -158,7 +157,7 @@ const ExportImage: FC = () => {
|
|||||||
// For current view, just download
|
// For current view, just download
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = dataUrl
|
link.href = dataUrl
|
||||||
link.download = `${appDetail ? filename : knowledgeName}.${type}`
|
link.download = `${filename}.${type}`
|
||||||
document.body.appendChild(link)
|
document.body.appendChild(link)
|
||||||
link.click()
|
link.click()
|
||||||
document.body.removeChild(link)
|
document.body.removeChild(link)
|
||||||
@ -167,7 +166,7 @@ const ExportImage: FC = () => {
|
|||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('Export image failed:', error)
|
console.error('Export image failed:', error)
|
||||||
}
|
}
|
||||||
}, [getNodesReadOnly, appDetail, reactFlow, knowledgeName])
|
}, [getNodesReadOnly, appName, reactFlow, knowledgeName])
|
||||||
|
|
||||||
const handleTrigger = useCallback(() => {
|
const handleTrigger = useCallback(() => {
|
||||||
if (getNodesReadOnly())
|
if (getNodesReadOnly())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user