修复Local Ai Agent 列表页操作列点击流程编排无法加载流程数据的问题
This commit is contained in:
parent
1543ce0be2
commit
9e0c6e48c8
@ -31,6 +31,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useMessage } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
import { get_session_api_headers } from '@/shared/api/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
context: {
|
||||
@ -78,12 +80,36 @@ async function handleExecute() {
|
||||
|
||||
async function handleFlowBuilder() {
|
||||
try {
|
||||
const raw = props.context.row.agent_flow ?? {}
|
||||
let flowData: any = raw
|
||||
if (typeof raw === 'string') {
|
||||
try { flowData = JSON.parse(raw) } catch { flowData = {} }
|
||||
}
|
||||
const agentId = props.context.row.name
|
||||
let flowData: any = {}
|
||||
|
||||
// 如果列表数据中没有 agent_flow 字段,需要从API获取完整记录
|
||||
if (props.context.row.agent_flow !== undefined && props.context.row.agent_flow !== null) {
|
||||
const raw = props.context.row.agent_flow
|
||||
flowData = raw
|
||||
if (typeof raw === 'string') {
|
||||
try { flowData = JSON.parse(raw) } catch { flowData = {} }
|
||||
}
|
||||
} else {
|
||||
// 从API获取完整记录数据,包含 agent_flow 字段
|
||||
try {
|
||||
const response = await axios.get(`/api/data/${encodeURIComponent(props.context.entity)}/${encodeURIComponent(agentId)}`, {
|
||||
headers: get_session_api_headers(),
|
||||
withCredentials: true
|
||||
})
|
||||
|
||||
const record = response.data?.data || {}
|
||||
const raw = record.agent_flow ?? {}
|
||||
flowData = raw
|
||||
if (typeof raw === 'string') {
|
||||
try { flowData = JSON.parse(raw) } catch { flowData = {} }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取智能体数据失败:', error)
|
||||
message.error(props.context.t('Failed to load agent data'))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const { useFlowBuilderStore } = await import('@/shared/stores/flowBuilder')
|
||||
const flowBuilderStore = useFlowBuilderStore()
|
||||
@ -91,7 +117,10 @@ async function handleFlowBuilder() {
|
||||
flowBuilderStore.activateFlowBuilder(flowData, agentId)
|
||||
|
||||
props.context.router.push({ name: 'FlowBuilder', query: { agentId } })
|
||||
} catch (_) {}
|
||||
} catch (error: any) {
|
||||
console.error('打开流程编排失败:', error)
|
||||
message.error(error?.message || props.context.t('Failed to open flow builder'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user