2025-07-15 15:16:03 +08:00
|
|
|
<template>
|
2025-07-29 17:46:10 +08:00
|
|
|
<div>
|
|
|
|
|
<span class="back-wap" @click="goChatIndex"> <icon-left /> 返回空间 </span>
|
|
|
|
|
<div class="workflow-container">
|
|
|
|
|
<div class="left-wap" v-if="isCollapsed == false">
|
|
|
|
|
<div class="header">
|
|
|
|
|
<div class="image-body">
|
|
|
|
|
<img :src="cozeInfo.image_url" />
|
|
|
|
|
</div>
|
2025-07-28 17:07:49 +08:00
|
|
|
</div>
|
2025-07-29 17:46:10 +08:00
|
|
|
<div class="content">
|
|
|
|
|
<div class="title-body">
|
|
|
|
|
<div class="text">{{ cozeInfo.name }}</div>
|
|
|
|
|
<div data-尺寸="迷你-20px" data-颜色="red" class="tag-body">
|
|
|
|
|
<div class="">
|
|
|
|
|
<img class="status-icon" :src="workflow" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="text">工作流</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="use-body">
|
|
|
|
|
<div class="num">{{ cozeInfo.views }}</div>
|
|
|
|
|
<div class="text">次使用</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="description">
|
|
|
|
|
<div class="text">
|
|
|
|
|
{{ cozeInfo.description }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="out-line">
|
|
|
|
|
<div class="out-line-div"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="history">
|
|
|
|
|
<div class="section">
|
|
|
|
|
<div class="text">历史对话</div>
|
|
|
|
|
</div>
|
2025-07-29 19:30:52 +08:00
|
|
|
<div class="history-item" v-for="(item, index) in history">
|
2025-07-29 17:46:10 +08:00
|
|
|
<div class="item-body">
|
2025-07-29 19:30:52 +08:00
|
|
|
<div class="text" @click="getHistoryInfo(item)">{{ item.title }}</div>
|
2025-07-29 17:46:10 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="right-wap">
|
|
|
|
|
<div class="header">
|
|
|
|
|
<div class="body">
|
|
|
|
|
<div class="">
|
|
|
|
|
<div class="toggle-btn" @click="toggleCollapse">
|
|
|
|
|
<a-tooltip :content="isCollapsed ? '展开' : '折叠'">
|
|
|
|
|
<img class="status-icon" :src="isCollapsed ? menuUnfold : menuFold" />
|
|
|
|
|
</a-tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<div class="form">
|
|
|
|
|
<DynamicForm :formFields="formFields.form" :formData="formData" :loading="loading" @submit="handleSubmit" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="res">
|
|
|
|
|
<a-spin v-if="loading" class="spin-center" tip="生成中。。。" />
|
|
|
|
|
<div v-if="workFlowRes.output != '' && loading === false" v-html="renderedMarkdown"></div>
|
|
|
|
|
<NoData v-if="workFlowRes.output == '' && loading === false" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-07-15 15:16:03 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref, reactive } from 'vue';
|
|
|
|
|
import DynamicForm from './components/DynamicForm.vue';
|
2025-07-24 19:07:46 +08:00
|
|
|
import { executeWorkFlow, getWorkFlowInfo } from '@/api/all/agent';
|
2025-07-16 18:49:28 +08:00
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
2025-07-24 19:07:46 +08:00
|
|
|
import { marked } from 'marked';
|
|
|
|
|
import DOMPurify from 'dompurify';
|
2025-07-28 17:07:49 +08:00
|
|
|
import menuFold from '@/assets/svg/menu-fold.svg';
|
|
|
|
|
import menuUnfold from '@/assets/svg/menu-unfold.svg';
|
2025-07-29 17:46:10 +08:00
|
|
|
import workflow from '@/assets/svg/workflow.svg';
|
2025-07-15 15:16:03 +08:00
|
|
|
|
2025-07-25 17:00:38 +08:00
|
|
|
const formFields = ref({});
|
2025-07-29 19:30:52 +08:00
|
|
|
const history = ref([]);
|
2025-07-28 17:07:49 +08:00
|
|
|
// 是否折叠状态
|
|
|
|
|
const isCollapsed = ref(false);
|
2025-07-15 15:16:03 +08:00
|
|
|
|
2025-07-28 17:07:49 +08:00
|
|
|
// 切换折叠状态
|
|
|
|
|
const toggleCollapse = () => {
|
|
|
|
|
isCollapsed.value = !isCollapsed.value;
|
|
|
|
|
};
|
2025-07-15 15:16:03 +08:00
|
|
|
// 表单数据对象(动态生成初始值)
|
|
|
|
|
const formData = ref({});
|
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const id = route.query.id;
|
|
|
|
|
const query = reactive({
|
|
|
|
|
id: id,
|
|
|
|
|
});
|
2025-07-16 18:49:28 +08:00
|
|
|
const router = useRouter();
|
|
|
|
|
const goChatIndex = async () => {
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/agent/index',
|
|
|
|
|
});
|
|
|
|
|
};
|
2025-07-15 15:16:03 +08:00
|
|
|
const loading = ref(false);
|
|
|
|
|
|
|
|
|
|
const cozeInfo = reactive({
|
2025-07-24 19:07:46 +08:00
|
|
|
name: '',
|
2025-07-15 15:16:03 +08:00
|
|
|
description: '',
|
|
|
|
|
icon_url: '',
|
|
|
|
|
workflow_id: '',
|
|
|
|
|
});
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
const { code, data } = await getWorkFlowInfo(query.id);
|
|
|
|
|
Object.assign(cozeInfo, data.info);
|
|
|
|
|
formFields.value = data.form_config;
|
2025-07-29 19:30:52 +08:00
|
|
|
history.value = data.history;
|
2025-07-15 15:16:03 +08:00
|
|
|
};
|
2025-07-24 19:07:46 +08:00
|
|
|
const workFlowRes = reactive({
|
|
|
|
|
output: '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 渲染 Markdown 的计算属性
|
|
|
|
|
const renderedMarkdown = computed(() => {
|
|
|
|
|
if (workFlowRes?.output) {
|
|
|
|
|
const rawHtml = marked.parse(workFlowRes.output || '');
|
|
|
|
|
return DOMPurify.sanitize(rawHtml); // 防止 XSS 攻击
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
});
|
|
|
|
|
|
2025-07-15 15:16:03 +08:00
|
|
|
// 提交表单
|
|
|
|
|
const handleSubmit = async (formData) => {
|
2025-07-16 18:49:28 +08:00
|
|
|
try {
|
2025-07-25 17:00:38 +08:00
|
|
|
const param = { form_data: formData, workflow_id: cozeInfo.workflow_id, bot_id: formFields.value.bot_id };
|
2025-07-28 19:59:54 +08:00
|
|
|
workFlowRes.output = '';
|
2025-07-16 18:49:28 +08:00
|
|
|
loading.value = true;
|
|
|
|
|
const { code, data } = await executeWorkFlow(param);
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
Object.assign(workFlowRes, data.data);
|
|
|
|
|
loading.value = false;
|
2025-07-29 19:30:52 +08:00
|
|
|
console.log(data.history_item, 'data.history_item');
|
|
|
|
|
addHistoryItem(data.history_item);
|
2025-07-16 18:49:28 +08:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2025-07-15 15:16:03 +08:00
|
|
|
loading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-29 19:30:52 +08:00
|
|
|
const addHistoryItem = (item) => {
|
|
|
|
|
history.value.unshift(item);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getHistoryInfo = (item) => {
|
|
|
|
|
formData.value = item.param;
|
|
|
|
|
workFlowRes.output = item.result.output;
|
|
|
|
|
|
|
|
|
|
console.log(formData.value, 'formData');
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-15 15:16:03 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
getData();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@import './style.scss';
|
|
|
|
|
</style>
|