From 8742560e6c320cce46d825c4a43a68447b28f3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Tue, 23 Sep 2025 11:20:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=A5=BD=E5=8F=8B=E6=8E=A5=E5=BE=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE):=20=E6=96=B0=E5=A2=9E=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E6=8E=A5=E5=BE=85=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E6=B5=81=E9=87=8F=E6=B1=A0=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在api.ts中新增了设置好友接待配置的API接口,并在ChatWindow组件中实现了配置选择功能,允许用户选择接待类型并保存配置。同时,新增了获取流量池列表的接口,优化了用户体验。 --- Touchkebao/src/pages/pc/ckbox/weChat/api.ts | 17 +++ .../components/ProfileCard/index.tsx | 109 ++++++++++-------- .../weChat/components/ChatWindow/index.tsx | 53 ++++++++- 3 files changed, 130 insertions(+), 49 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/api.ts b/Touchkebao/src/pages/pc/ckbox/weChat/api.ts index f7111dd1..6f283b5a 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/api.ts +++ b/Touchkebao/src/pages/pc/ckbox/weChat/api.ts @@ -11,7 +11,24 @@ import { QuickReply, ChatSettings, } from "./data"; +//流量池 +//好友接待配置 + +export function setFriendInjectConfig(params) { + return request("/v1/kefu/ai/friend/set", params, "POST"); +} + +export function getTrafficPoolList() { + return request( + "/v1/traffic/pool/getPackage", + { + page: 1, + limit: 9999, + }, + "GET", + ); +} // 好友列表 export function getWechatFriendList(params) { return request("/v1/kefu/wechatFriend/list", params, "GET"); diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx index b4526ef7..7fb6b475 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx @@ -84,7 +84,7 @@ const Person: React.FC = ({ 3. 鼓励大家积极交流 4. 保持群聊环境和谐 -请用温馨友好的语调,字数控制在200字以内。` +请用温馨友好的语调,字数控制在200字以内。`, ); const [aiGeneratedContent, setAiGeneratedContent] = useState(""); @@ -907,18 +907,21 @@ const Person: React.FC = ({ {/* 群公告 - 仅在群聊时显示 */} {isGroup && ( - + {/* 群聊简介(原群公告) */}
{ - setGroupNoticeValue(contractInfo.notice || ""); - setIsGroupNoticeModalVisible(true); - } : undefined} - style={{ cursor: hasGroupManagePermission() ? "pointer" : "default" }} + onClick={ + hasGroupManagePermission() + ? () => { + setGroupNoticeValue(contractInfo.notice || ""); + setIsGroupNoticeModalVisible(true); + } + : undefined + } + style={{ + cursor: hasGroupManagePermission() ? "pointer" : "default", + }} >
= ({ }} >
- {contractInfo.notice || "点击添加群公告"} -
+ className={styles.bioText} + style={{ + maxHeight: "120px", + overflowY: "auto", + paddingRight: "5px", + flex: 1, + whiteSpace: "pre-wrap", + wordBreak: "break-word", + lineHeight: "1.5", + }} + > + {contractInfo.notice || "点击添加群公告"} +
{hasGroupManagePermission() && ( ,
setAiPrompt(e.target.value)} - placeholder="请输入AI生成群公告的提示词..." - rows={6} - style={{ resize: "none" }} - /> + value={aiPrompt} + onChange={e => setAiPrompt(e.target.value)} + placeholder="请输入AI生成群公告的提示词..." + rows={6} + style={{ resize: "none" }} + />
💡 提示:详细的提示词能帮助AI生成更符合您需求的群公告内容
@@ -1293,13 +1302,19 @@ const Person: React.FC = ({ setAiGeneratedContent(e.target.value)} - placeholder={aiGenerating ? "AI正在生成中,请稍候..." : "点击上方'生成内容'按钮,AI将根据提示词生成群公告"} + placeholder={ + aiGenerating + ? "AI正在生成中,请稍候..." + : "点击上方'生成内容'按钮,AI将根据提示词生成群公告" + } rows={8} style={{ resize: "none" }} disabled={aiGenerating} /> {aiGeneratedContent && ( -
+
✅ 内容已生成,您可以编辑后点击"确认使用"应用到群公告
)} diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx index 39994b95..5202d089 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx @@ -1,9 +1,11 @@ import React, { useState } from "react"; -import { Layout, Button, Avatar, Space, Tooltip } from "antd"; +import { Layout, Button, Avatar, Space, Tooltip, Dropdown } from "antd"; import { UserOutlined, TeamOutlined, InfoCircleOutlined, + RobotOutlined, + DownOutlined, } from "@ant-design/icons"; import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; import styles from "./ChatWindow.module.scss"; @@ -11,7 +13,7 @@ import styles from "./ChatWindow.module.scss"; import ProfileCard from "./components/ProfileCard"; import MessageEnter from "./components/MessageEnter"; import MessageRecord from "./components/MessageRecord"; - +import { setFriendInjectConfig } from "@/pages/pc/ckbox/weChat/api"; const { Header, Content } = Layout; interface ChatWindowProps { @@ -24,6 +26,34 @@ const ChatWindow: React.FC = ({ contract }) => { setShowProfile(!showProfile); }; + const typeOptions = [ + { value: 0, label: "人工接待" }, + { value: 1, label: "AI辅助" }, + { value: 2, label: "AI接管" }, + ]; + + const [currentConfig, setCurrentConfig] = useState({ + value: 0, + label: "人工接待", + }); + + // 处理配置选择 + const handleConfigChange = option => { + setCurrentConfig({ + value: option.value, + label: option.label, + }); + + // 保存配置到后端 + setFriendInjectConfig({ + type: option.value, + wechatAccountId: contract.wechatAccountId, + friendId: contract.id, + }).then(res => { + console.log("配置保存成功:", res); + }); + }; + return ( {/* 聊天主体区域 */} @@ -45,6 +75,25 @@ const ChatWindow: React.FC = ({ contract }) => {
+ {!contract.chatroomId && ( + ({ + key: option.value, + label: option.label, + onClick: () => handleConfigChange(option), + })), + }} + trigger={["click"]} + placement="bottomRight" + > + + + )} +