diff --git a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js
index 1a57c80..83705c1 100644
--- a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js
+++ b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js
@@ -128,6 +128,9 @@ Component({
},
voiceRecognizing: false,
speedList: [2, 1.5, 1.25, 1, 0.75],
+
+ showActionMenu: false, // 是否显示操作菜单
+ selectedConversation: null, // 当前选中的会话
},
attached: async function () {
const chatMode = this.data.chatMode;
@@ -482,7 +485,7 @@ Component({
});
commonRequest({
- path: `conversation/?botId=${botId}&limit=${limit}&offset=${offset}&isDefault=${isDefault}`,
+ path: `bots/${botId}/conversation/?limit=${limit}&offset=${offset}&isDefault=${isDefault}`,
method: "GET",
header: {},
success: (res) => {
@@ -506,7 +509,7 @@ Component({
// const { token } = await cloudInstance.extend.AI.bot.tokenManager.getToken();
return new Promise((resolve, reject) => {
commonRequest({
- path: `conversation`,
+ path: `bots/${this.data.agentConfig.botId}/conversation`,
header: {
// Authorization: `Bearer ${token}`,
},
@@ -524,6 +527,101 @@ Component({
});
});
},
+ deleteConversation: async function (conversationId) {
+ return new Promise((resolve, reject) => {
+ commonRequest({
+ path: `bots/${this.data.agentConfig.botId}/conversation/${conversationId}`,
+ method: "DELETE",
+ success: (res) => {
+ resolve(res);
+ },
+ fail(e) {
+ console.log("delete conversation e", e);
+ reject(e);
+ },
+ });
+ });
+ },
+ handleDeleteConversation: async function (e) {
+ const { conversation } = e.currentTarget.dataset;
+ const that = this;
+
+ this.hideActionMenu();
+
+ wx.showModal({
+ title: "提示",
+ content: "确认删除当前会话?",
+ confirmText: "删除",
+ confirmColor: "#ff303b",
+ success: async function(res){
+ if (res.confirm) {
+ // 删除会话
+ try{
+ const deleteRes = await that.deleteConversation(conversation.conversationId);
+
+ if (deleteRes && !deleteRes.code) {
+ // 删除成功后更新本地数据
+ const updatedConversations = that.data.conversations.filter(
+ item => item.conversationId !== conversation.conversationId
+ );
+ that.setData({
+ conversations: updatedConversations,
+ transformConversations: that.transformConversationList(updatedConversations),
+ });
+
+ if (that.data.conversation?.conversationId === conversation.conversationId) {
+ that.clearChatRecords();
+ if (updatedConversations.length > 0) {
+ that.handleClickConversation({
+ currentTarget: {
+ dataset: {
+ conversation: updatedConversations[0],
+ },
+ },
+ });
+ } else {
+ that.setData({
+ conversation: null,
+ });
+ }
+ }
+
+ wx.showToast({
+ title: "删除成功",
+ icon: "success",
+ });
+ } else {
+ wx.showToast({
+ title: "删除失败,请稍后重试",
+ icon: "error",
+ });
+ }
+ } catch (error) {
+ console.error("删除会话失败", error);
+ wx.showToast({
+ title: "删除失败,请稍后重试",
+ icon: "error",
+ });
+ }
+ }
+ },
+ });
+ },
+ handleLongPressConversation: function (e) {
+ // 长按会话,显示操作菜单
+ const { conversation } = e.currentTarget.dataset;
+ this.setData({
+ showActionMenu: true,
+ selectedConversation: conversation,
+ });
+ },
+ hideActionMenu: function () {
+ // 隐藏操作菜单
+ this.setData({
+ showActionMenu: false,
+ selectedConversation: null,
+ });
+ },
clickCreateInDrawer: function () {
this.setData({
isDrawerShow: false,
diff --git a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxml b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxml
index d370acc..b2a057a 100644
--- a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxml
+++ b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxml
@@ -20,19 +20,40 @@
今天
- {{item.title}}
+
+ {{item.title}}
+
本月
- {{item.title}}
+
+ {{item.title}}
+
更早
- {{item.title}}
+
+ {{item.title}}
+
@@ -277,4 +298,15 @@
+
+
\ No newline at end of file
diff --git a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss
index c4309b9..2e37b00 100644
--- a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss
+++ b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss
@@ -742,4 +742,72 @@
.speed-option:active {
background: #f0f0f0;
-}
\ No newline at end of file
+}
+
+/* 底部操作菜单弹窗 */
+.action-menu-modal {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.4);
+ z-index: 1001;
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+ animation: fadeIn 0.3s ease-out;
+}
+
+.action-menu {
+ background: #ffffff;
+ border-radius: 24rpx 24rpx 0 0;
+ overflow: hidden;
+ animation: slideUp 0.3s ease-out;
+ margin: 0 20rpx 20rpx 20rpx;
+ box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
+}
+
+.action-item {
+ padding: 32rpx 0;
+ text-align: center;
+ font-size: 32rpx;
+ color: #333333;
+ background: #ffffff;
+ border-bottom: 1rpx solid #f0f0f0;
+ position: relative;
+}
+
+.action-item:last-child {
+ border-bottom: none;
+}
+
+.action-item:active {
+ background: #f8f8f8;
+}
+
+.cancel-item {
+ margin-top: 20rpx;
+ border-radius: 24rpx;
+ border-bottom: none;
+ color: #666666;
+}
+
+/* 动画效果 */
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: 1;
+ }
+}
+
+@keyframes slideUp {
+ from {
+ transform: translateY(100%);
+ }
+ to {
+ transform: translateY(0);
+ }
+}
diff --git a/apps/miniprogram-agent-ui/project.config.json b/apps/miniprogram-agent-ui/project.config.json
index d7d2503..16586a8 100644
--- a/apps/miniprogram-agent-ui/project.config.json
+++ b/apps/miniprogram-agent-ui/project.config.json
@@ -72,6 +72,6 @@
"include": []
},
"appid": "wx5ceb4e4809aa1d28",
- "libVersion": "3.7.10",
+ "libVersion": "3.8.1",
"simulatorPluginLibVersion": {}
}
\ No newline at end of file
diff --git a/apps/miniprogram-agent-ui/project.private.config.json b/apps/miniprogram-agent-ui/project.private.config.json
index 6c39a57..e1e9919 100644
--- a/apps/miniprogram-agent-ui/project.private.config.json
+++ b/apps/miniprogram-agent-ui/project.private.config.json
@@ -20,5 +20,6 @@
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "cloudbase-agent-ui",
- "libVersion": "3.8.1"
-}
+ "libVersion": "3.9.0",
+ "condition": {}
+}
\ No newline at end of file
diff --git a/components/agent-ui/index.js b/components/agent-ui/index.js
index 1a57c80..83705c1 100644
--- a/components/agent-ui/index.js
+++ b/components/agent-ui/index.js
@@ -128,6 +128,9 @@ Component({
},
voiceRecognizing: false,
speedList: [2, 1.5, 1.25, 1, 0.75],
+
+ showActionMenu: false, // 是否显示操作菜单
+ selectedConversation: null, // 当前选中的会话
},
attached: async function () {
const chatMode = this.data.chatMode;
@@ -482,7 +485,7 @@ Component({
});
commonRequest({
- path: `conversation/?botId=${botId}&limit=${limit}&offset=${offset}&isDefault=${isDefault}`,
+ path: `bots/${botId}/conversation/?limit=${limit}&offset=${offset}&isDefault=${isDefault}`,
method: "GET",
header: {},
success: (res) => {
@@ -506,7 +509,7 @@ Component({
// const { token } = await cloudInstance.extend.AI.bot.tokenManager.getToken();
return new Promise((resolve, reject) => {
commonRequest({
- path: `conversation`,
+ path: `bots/${this.data.agentConfig.botId}/conversation`,
header: {
// Authorization: `Bearer ${token}`,
},
@@ -524,6 +527,101 @@ Component({
});
});
},
+ deleteConversation: async function (conversationId) {
+ return new Promise((resolve, reject) => {
+ commonRequest({
+ path: `bots/${this.data.agentConfig.botId}/conversation/${conversationId}`,
+ method: "DELETE",
+ success: (res) => {
+ resolve(res);
+ },
+ fail(e) {
+ console.log("delete conversation e", e);
+ reject(e);
+ },
+ });
+ });
+ },
+ handleDeleteConversation: async function (e) {
+ const { conversation } = e.currentTarget.dataset;
+ const that = this;
+
+ this.hideActionMenu();
+
+ wx.showModal({
+ title: "提示",
+ content: "确认删除当前会话?",
+ confirmText: "删除",
+ confirmColor: "#ff303b",
+ success: async function(res){
+ if (res.confirm) {
+ // 删除会话
+ try{
+ const deleteRes = await that.deleteConversation(conversation.conversationId);
+
+ if (deleteRes && !deleteRes.code) {
+ // 删除成功后更新本地数据
+ const updatedConversations = that.data.conversations.filter(
+ item => item.conversationId !== conversation.conversationId
+ );
+ that.setData({
+ conversations: updatedConversations,
+ transformConversations: that.transformConversationList(updatedConversations),
+ });
+
+ if (that.data.conversation?.conversationId === conversation.conversationId) {
+ that.clearChatRecords();
+ if (updatedConversations.length > 0) {
+ that.handleClickConversation({
+ currentTarget: {
+ dataset: {
+ conversation: updatedConversations[0],
+ },
+ },
+ });
+ } else {
+ that.setData({
+ conversation: null,
+ });
+ }
+ }
+
+ wx.showToast({
+ title: "删除成功",
+ icon: "success",
+ });
+ } else {
+ wx.showToast({
+ title: "删除失败,请稍后重试",
+ icon: "error",
+ });
+ }
+ } catch (error) {
+ console.error("删除会话失败", error);
+ wx.showToast({
+ title: "删除失败,请稍后重试",
+ icon: "error",
+ });
+ }
+ }
+ },
+ });
+ },
+ handleLongPressConversation: function (e) {
+ // 长按会话,显示操作菜单
+ const { conversation } = e.currentTarget.dataset;
+ this.setData({
+ showActionMenu: true,
+ selectedConversation: conversation,
+ });
+ },
+ hideActionMenu: function () {
+ // 隐藏操作菜单
+ this.setData({
+ showActionMenu: false,
+ selectedConversation: null,
+ });
+ },
clickCreateInDrawer: function () {
this.setData({
isDrawerShow: false,
diff --git a/components/agent-ui/index.wxml b/components/agent-ui/index.wxml
index d370acc..b2a057a 100644
--- a/components/agent-ui/index.wxml
+++ b/components/agent-ui/index.wxml
@@ -20,19 +20,40 @@
今天
- {{item.title}}
+
+ {{item.title}}
+
本月
- {{item.title}}
+
+ {{item.title}}
+
更早
- {{item.title}}
+
+ {{item.title}}
+
@@ -277,4 +298,15 @@
+
+
\ No newline at end of file
diff --git a/components/agent-ui/index.wxss b/components/agent-ui/index.wxss
index c4309b9..2e37b00 100644
--- a/components/agent-ui/index.wxss
+++ b/components/agent-ui/index.wxss
@@ -742,4 +742,72 @@
.speed-option:active {
background: #f0f0f0;
-}
\ No newline at end of file
+}
+
+/* 底部操作菜单弹窗 */
+.action-menu-modal {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.4);
+ z-index: 1001;
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+ animation: fadeIn 0.3s ease-out;
+}
+
+.action-menu {
+ background: #ffffff;
+ border-radius: 24rpx 24rpx 0 0;
+ overflow: hidden;
+ animation: slideUp 0.3s ease-out;
+ margin: 0 20rpx 20rpx 20rpx;
+ box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
+}
+
+.action-item {
+ padding: 32rpx 0;
+ text-align: center;
+ font-size: 32rpx;
+ color: #333333;
+ background: #ffffff;
+ border-bottom: 1rpx solid #f0f0f0;
+ position: relative;
+}
+
+.action-item:last-child {
+ border-bottom: none;
+}
+
+.action-item:active {
+ background: #f8f8f8;
+}
+
+.cancel-item {
+ margin-top: 20rpx;
+ border-radius: 24rpx;
+ border-bottom: none;
+ color: #666666;
+}
+
+/* 动画效果 */
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: 1;
+ }
+}
+
+@keyframes slideUp {
+ from {
+ transform: translateY(100%);
+ }
+ to {
+ transform: translateY(0);
+ }
+}
diff --git a/package-lock.json b/package-lock.json
index 065a37a..40def1d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "cloudbase-agent-ui",
- "version": "1.14.1",
+ "version": "1.14.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cloudbase-agent-ui",
- "version": "1.14.1",
+ "version": "1.14.2",
"license": "MIT",
"dependencies": {
"standard-version": "^9.5.0"
diff --git a/package.json b/package.json
index d7c3091..16bdbb3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cloudbase-agent-ui",
- "version": "1.14.1",
+ "version": "1.14.2",
"description": "微信小程序 Agent UI组件",
"main": "index.js",
"directories": {