From 9fa28c76cc9a6b9d713124013a24f12b55d04155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=BF=97=E5=86=9B?= <543024265@qq.com> Date: Thu, 24 Jul 2025 19:07:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Agent/Chat):=20=E4=BD=BF=E7=94=A8=20co?= =?UTF-8?q?zeInfo=20=E6=9B=BF=E4=BB=A3=20botId=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 HistoryChat 组件中的 botId属性 - 使用 cozeInfo.bot_id 替代 botId 获取历史聊天数据 --- README.md | 2 +- package.json | 2 + src/components/upload/FileUpload.vue | 137 + src/router/index.ts | 13 +- src/router/routes/modules/agent.ts | 61 +- src/views/Agent/Chat/components/ChatBox.vue | 36 - src/views/Agent/Chat/components/CozeChat.vue | 217 -- .../Agent/work-flow/components/WorkFlow.vue | 217 -- src/views/{Agent => agent}/AgentConstants.ts | 0 .../chat}/components/HistoryChat.vue | 0 .../{Agent/Chat => agent/chat}/index.vue | 8 +- .../{Agent/Chat => agent/chat}/style.scss | 0 .../{Agent/Index => agent/index}/index.vue | 4 +- .../{Agent/Index => agent/index}/style.scss | 0 .../work-flow/components/DynamicForm.vue | 35 +- .../work-flow/components/HistoryChat.vue | 12 +- .../{Agent => agent}/work-flow/index.vue | 26 +- .../{Agent => agent}/work-flow/style.scss | 0 vite.config.ts | 2 +- yarn.lock | 3350 ++++++++++++++++- 20 files changed, 3470 insertions(+), 652 deletions(-) create mode 100644 src/components/upload/FileUpload.vue delete mode 100644 src/views/Agent/Chat/components/ChatBox.vue delete mode 100644 src/views/Agent/Chat/components/CozeChat.vue delete mode 100644 src/views/Agent/work-flow/components/WorkFlow.vue rename src/views/{Agent => agent}/AgentConstants.ts (100%) rename src/views/{Agent/Chat => agent/chat}/components/HistoryChat.vue (100%) rename src/views/{Agent/Chat => agent/chat}/index.vue (93%) rename src/views/{Agent/Chat => agent/chat}/style.scss (100%) rename src/views/{Agent/Index => agent/index}/index.vue (98%) rename src/views/{Agent/Index => agent/index}/style.scss (100%) rename src/views/{Agent => agent}/work-flow/components/DynamicForm.vue (55%) rename src/views/{Agent => agent}/work-flow/components/HistoryChat.vue (72%) rename src/views/{Agent => agent}/work-flow/index.vue (81%) rename src/views/{Agent => agent}/work-flow/style.scss (100%) diff --git a/README.md b/README.md index 9d094c7..5fa330d 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ const str: string = join(['a', 'b', 'c'], '~'); > 命名导出: `Comp/Index.js` ```js -// Comp/Index.js +// Comp/index.js export { CompA, CompB, CompC }; ``` diff --git a/package.json b/package.json index 8082532..1b334c3 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,12 @@ "ali-oss": "^6.17.1", "axios": "^1.3.0", "dayjs": "^1.11.7", + "dompurify": "^3.2.6", "echarts": "^5.6.0", "html2canvas": "^1.4.1", "jspdf": "^3.0.1", "lodash-es": "^4.17.21", + "marked": "^16.1.1", "mitt": "^3.0.0", "normalize.css": "^8.0.1", "pinia": "^2.0.29", diff --git a/src/components/upload/FileUpload.vue b/src/components/upload/FileUpload.vue new file mode 100644 index 0000000..e37922b --- /dev/null +++ b/src/components/upload/FileUpload.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index af3a60b..93c5b5c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -38,7 +38,18 @@ export const router = createRouter({ { path: '/agent/chat', name: 'Chat', - component: () => import('@/views/Agent/chat'), + component: () => import('@/views/agent/chat'), + meta: { + hideSidebar: true, + requiresAuth: false, + requireLogin: true, + id: MENU_GROUP_IDS.WORK_BENCH_ID, + }, + }, + { + path: '/agent/workFlow', + name: 'WorkFlow', + component: () => import('@/views/agent/work-flow'), meta: { hideSidebar: true, requiresAuth: false, diff --git a/src/router/routes/modules/agent.ts b/src/router/routes/modules/agent.ts index 24544a0..b7619da 100644 --- a/src/router/routes/modules/agent.ts +++ b/src/router/routes/modules/agent.ts @@ -4,42 +4,31 @@ import { MENU_GROUP_IDS } from '@/router/constants'; import IconRepository from '@/assets/svg/icon-repository.svg'; const COMPONENTS: AppRouteRecordRaw[] = [ - { - path: '/agent', - name: 'Agent', - redirect: 'agent/index', - meta: { - locale: '扣子智能体', - icon: IconRepository, - requiresAuth: true, - requireLogin: true, - roles: ['*'], - id: MENU_GROUP_IDS.PROPERTY_ID, - }, - children: [ - { - path: 'index', - name: 'AgentIndex', - component: () => import('@/views/agent/index'), - meta: { - requiresAuth: false, - requireLogin: true, - id: MENU_GROUP_IDS.WORK_BENCH_ID, - }, - }, - { - path: 'chat', - name: 'Chat', - component: () => import('@/views/agent/chat'), - meta: { - hideSidebar: true, - requiresAuth: false, - requireLogin: true, - id: MENU_GROUP_IDS.WORK_BENCH_ID, - }, - }, - ], - }, + // { + // path: '/agent', + // name: 'Agent', + // redirect: 'agent/index', + // meta: { + // locale: '扣子智能体', + // icon: IconRepository, + // requiresAuth: true, + // requireLogin: true, + // roles: ['*'], + // id: MENU_GROUP_IDS.AGENT, + // }, + // children: [ + // { + // path: 'index', + // name: 'AgentIndex', + // component: () => import('@/views/agent/index'), + // meta: { + // requiresAuth: false, + // requireLogin: true, + // }, + // } + // + // ], + // }, ]; export default COMPONENTS; diff --git a/src/views/Agent/Chat/components/ChatBox.vue b/src/views/Agent/Chat/components/ChatBox.vue deleted file mode 100644 index b2f5b32..0000000 --- a/src/views/Agent/Chat/components/ChatBox.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/src/views/Agent/Chat/components/CozeChat.vue b/src/views/Agent/Chat/components/CozeChat.vue deleted file mode 100644 index 66d02e2..0000000 --- a/src/views/Agent/Chat/components/CozeChat.vue +++ /dev/null @@ -1,217 +0,0 @@ - - - - - diff --git a/src/views/Agent/work-flow/components/WorkFlow.vue b/src/views/Agent/work-flow/components/WorkFlow.vue deleted file mode 100644 index 66d02e2..0000000 --- a/src/views/Agent/work-flow/components/WorkFlow.vue +++ /dev/null @@ -1,217 +0,0 @@ - - - - - diff --git a/src/views/Agent/AgentConstants.ts b/src/views/agent/AgentConstants.ts similarity index 100% rename from src/views/Agent/AgentConstants.ts rename to src/views/agent/AgentConstants.ts diff --git a/src/views/Agent/Chat/components/HistoryChat.vue b/src/views/agent/chat/components/HistoryChat.vue similarity index 100% rename from src/views/Agent/Chat/components/HistoryChat.vue rename to src/views/agent/chat/components/HistoryChat.vue diff --git a/src/views/Agent/Chat/index.vue b/src/views/agent/chat/index.vue similarity index 93% rename from src/views/Agent/Chat/index.vue rename to src/views/agent/chat/index.vue index 5f42670..542333c 100644 --- a/src/views/Agent/Chat/index.vue +++ b/src/views/agent/chat/index.vue @@ -27,7 +27,7 @@ import { useRouter } from 'vue-router'; const router = useRouter(); // 存储认证令牌 -const authToken = ref('pat_tuIM7jubM1hLXaIWzbWg1U15lBe66AlYwu9BkXMQXInh8VdPszRFTwlTPmdziHwg'); +const authToken = ref(''); // 模拟从API获取token const fetchToken = async () => { @@ -89,9 +89,8 @@ const initChat = async () => { }; const cozeWebSdkConfig = (botId, name, auth) => { - console.log(name, 'title'); auth.onRefreshToken = function () { - return 'pat_tuIM7jubM1hLXaIWzbWg1U15lBe66AlYwu9BkXMQXInh8VdPszRFTwlTPmdziHwg'; + return ''; }; let config = { config: { @@ -105,6 +104,9 @@ const cozeWebSdkConfig = (botId, name, auth) => { title: name, isNeedFunctionCallMessage: true, }, + footer:{ + expressionText:"内容由AI生成,无法确保真实准确,仅供参考。", + }, }, auth: auth, base: { diff --git a/src/views/Agent/Chat/style.scss b/src/views/agent/chat/style.scss similarity index 100% rename from src/views/Agent/Chat/style.scss rename to src/views/agent/chat/style.scss diff --git a/src/views/Agent/Index/index.vue b/src/views/agent/index/index.vue similarity index 98% rename from src/views/Agent/Index/index.vue rename to src/views/agent/index/index.vue index ea730a0..c81addc 100644 --- a/src/views/Agent/Index/index.vue +++ b/src/views/agent/index/index.vue @@ -2,7 +2,7 @@
{ }; const query = reactive({ - title: '', + name: '', }); const goDetail = (type: number, id: number) => { if (type === 1) { diff --git a/src/views/Agent/Index/style.scss b/src/views/agent/index/style.scss similarity index 100% rename from src/views/Agent/Index/style.scss rename to src/views/agent/index/style.scss diff --git a/src/views/Agent/work-flow/components/DynamicForm.vue b/src/views/agent/work-flow/components/DynamicForm.vue similarity index 55% rename from src/views/Agent/work-flow/components/DynamicForm.vue rename to src/views/agent/work-flow/components/DynamicForm.vue index 73ea51f..2dbe195 100644 --- a/src/views/Agent/work-flow/components/DynamicForm.vue +++ b/src/views/agent/work-flow/components/DynamicForm.vue @@ -4,16 +4,30 @@ - - - - - - + + + + + + {{ option.label }} @@ -25,6 +39,7 @@ diff --git a/src/views/Agent/work-flow/components/HistoryChat.vue b/src/views/agent/work-flow/components/HistoryChat.vue similarity index 72% rename from src/views/Agent/work-flow/components/HistoryChat.vue rename to src/views/agent/work-flow/components/HistoryChat.vue index 671927f..a9c7d0b 100644 --- a/src/views/Agent/work-flow/components/HistoryChat.vue +++ b/src/views/agent/work-flow/components/HistoryChat.vue @@ -5,11 +5,10 @@
- {{ cozeInfo.title }} + {{ cozeInfo.name }} {{ cozeInfo.type == 1 ? '智能体' : '对话式' }} - {{ cozeInfo.views }}次使用 + {{ cozeInfo.views }}次使用 - 历史对话 @@ -28,15 +27,8 @@ const props = defineProps({ default: '', }, }); -console.log(props.cozeInfo, 'cozeInfo'); -const getHistoryChat = async () => { - const { code, data } = await getHistoryChat({ botId: props.botId }); - console.log(data, 'data'); - // 获取历史对话 -}; onMounted(() => { - getHistoryChat(); }); diff --git a/src/views/Agent/work-flow/index.vue b/src/views/agent/work-flow/index.vue similarity index 81% rename from src/views/Agent/work-flow/index.vue rename to src/views/agent/work-flow/index.vue index 824ae77..4349dbd 100644 --- a/src/views/Agent/work-flow/index.vue +++ b/src/views/agent/work-flow/index.vue @@ -13,9 +13,8 @@ -
- {{ workFlowRes?.output }} -
+
+
@@ -26,9 +25,11 @@