feat(agent): 新增智能体应用功能

- 添加智能体列表页面和相关API
- 实现聊天功能,包括历史对话和当前对话
- 新增工作流功能,包括表单提交和结果展示- 优化路由配置,增加智能体相关路由
- 添加全局常量和枚举,用于智能体类型区分
This commit is contained in:
林志军
2025-07-16 18:49:28 +08:00
parent 616665d219
commit b3af007dd2
15 changed files with 412 additions and 182 deletions

View File

@ -1,9 +1,15 @@
<template>
<div class="chat-wrap">
<span class="span-back"> <icon-left /> 返回空间 </span>
<span class="" @click="goChatIndex"> <icon-left /> 返回空间 </span>
<div class="chat-contain">
<a-layout>
<HistoryChat :cozeInfo="cozeInfo" :botId="cozeWebSDKConfig?.config?.bot_id" />
<a-layout-sider width="15%" style="background: #fff">
<HistoryChat
v-if="cozeWebSDKConfig?.config?.bot_id"
:cozeInfo="cozeInfo"
:botId="cozeWebSDKConfig?.config?.bot_id"
/>
</a-layout-sider>
<a-layout>
<a-layout-content style="padding: 24px; background: #fff; min-height: 280px">
<a-card :bordered="false">
@ -20,8 +26,9 @@
import { ref, onMounted } from 'vue';
import { getChatAgent } from '@/api/all/agent';
import HistoryChat from './components/HistoryChat.vue';
import ChatBox from './components/ChatBox.vue';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
const router = useRouter();
// 存储认证令牌
const authToken = ref('pat_tuIM7jubM1hLXaIWzbWg1U15lBe66AlYwu9BkXMQXInh8VdPszRFTwlTPmdziHwg');
@ -40,6 +47,12 @@ const refreshToken = async () => {
authToken.value = await fetchToken();
};
const goChatIndex = async () => {
router.push({
path: '/agent/index',
});
};
// 动态加载脚本函数
const loadScript = (src) =>
new Promise((resolve, reject) => {
@ -51,7 +64,7 @@ const loadScript = (src) =>
});
const route = useRoute();
const id = route.params.id;
const id = route.query.id;
const query = reactive({
id: id,
});
@ -78,10 +91,10 @@ const initChat = async () => {
}
Object.assign(cozeWebSDKConfig, data.cozeConfig);
Object.assign(cozeInfo, data.info);
console.log(cozeWebSDKConfig?.config?.bot_id, 'cozeWebSDKConfig?.config?.bot_id');
await loadScript('https://lf-cdn.coze.cn/obj/unpkg/flow-platform/chat-app-sdk/1.2.0-beta.10/libs/cn/index.js');
let config = data.cozeConfig;
config.ui.chatBot.el = document.getElementById('coze-chat-container');
config.ui.width = '900px';
config.ui = editUi(data);
config.auth.onRefreshToken = function () {
return 'pat_tuIM7jubM1hLXaIWzbWg1U15lBe66AlYwu9BkXMQXInh8VdPszRFTwlTPmdziHwg';
};
@ -89,9 +102,28 @@ const initChat = async () => {
showChatPage();
};
const editUi = (config) => {
let uiConfig = {
chatBot: {
el: document.getElementById('coze-chat-container'),
width: '70%',
height: '100%',
title: config?.info?.title,
isNeedFunctionCallMessage: true,
},
base: {
icon: '',
zIndex: 1000,
},
header: {
isShow: true,
isNeedClose: false,
},
};
return uiConfig;
};
const showChatPage = () => {
// 显示聊天页面
console.log(cozeWebSDK, 'chatClient');
cozeWebSDK.showChatBot();
};