From acd386bb09cdaf746c9eaffad20423a523fac586 Mon Sep 17 00:00:00 2001
From: CGD <3030332422@qq.com>
Date: Wed, 19 Mar 2025 18:13:03 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=99=BA=E8=83=BD=E4=BD=93?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main/manager-web/src/apis/module/user.js | 62 ++++++++++++++-----
.../src/components/AddWisdomBodyDialog.vue | 16 ++++-
.../manager-web/src/components/DeviceItem.vue | 12 ++--
main/manager-web/src/components/HeaderBar.vue | 48 ++++++++++++--
main/manager-web/src/views/home.vue | 41 ++++++++----
5 files changed, 139 insertions(+), 40 deletions(-)
diff --git a/main/manager-web/src/apis/module/user.js b/main/manager-web/src/apis/module/user.js
index 444d5d76..333439f9 100755
--- a/main/manager-web/src/apis/module/user.js
+++ b/main/manager-web/src/apis/module/user.js
@@ -18,20 +18,6 @@ export default {
})
}).send()
},
- // 获取用户信息
- getUserInfo(callback) {
- RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/info`)
- .method('GET')
- .success((res) => {
- RequestService.clearRequestTime()
- callback(res)
- })
- .fail(() => {
- RequestService.reAjaxFun(() => {
- this.getUserInfo()
- })
- }).send()
- },
// 获取设备信息
getHomeList(callback) {
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/device/bind`)
@@ -174,4 +160,52 @@ export default {
}).send();
},
+ // 获取智能体列表
+ getAgentList(callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/api/v1/user/agent`)
+ .method('GET')
+ .success((res) => {
+ RequestService.clearRequestTime();
+ callback(res);
+ })
+ .fail(() => {
+ RequestService.reAjaxFun(() => {
+ this.getAgentList(callback);
+ });
+ }).send();
+ },
+
+ getUserInfo(callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/api/v1/user/info`)
+ .method('GET')
+ .success((res) => {
+ RequestService.clearRequestTime()
+ callback(res)
+ })
+ .fail((err) => {
+ console.error('接口请求失败:', err)
+ RequestService.reAjaxFun(() => {
+ this.getUserInfo(callback)
+ })
+ }).send()
+ },
+ // 添加智能体
+ addAgent(agentName, callback) {
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/api/v1/user/agent`)
+ .method('POST')
+ .data({ name: agentName })
+ .success((res) => {
+ RequestService.clearRequestTime();
+ callback(res);
+ })
+ .fail(() => {
+ RequestService.reAjaxFun(() => {
+ this.addAgent(agentName, callback);
+ });
+ }).send();
+ },
+
}
diff --git a/main/manager-web/src/components/AddWisdomBodyDialog.vue b/main/manager-web/src/components/AddWisdomBodyDialog.vue
index fef13d50..cca026ef 100644
--- a/main/manager-web/src/components/AddWisdomBodyDialog.vue
+++ b/main/manager-web/src/components/AddWisdomBodyDialog.vue
@@ -29,6 +29,9 @@
diff --git a/main/manager-web/src/views/home.vue b/main/manager-web/src/views/home.vue
index 4b9c6eb5..0c914e77 100644
--- a/main/manager-web/src/views/home.vue
+++ b/main/manager-web/src/views/home.vue
@@ -1,7 +1,7 @@
-
@@ -47,22 +47,22 @@
import DeviceItem from '@/components/DeviceItem.vue'
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue'
import HeaderBar from '@/components/HeaderBar.vue'
+
export default {
name: 'HomePage',
components: { DeviceItem, AddWisdomBodyDialog, HeaderBar },
data() {
return {
addDeviceDialogVisible: false,
- // 此处模拟设备列表(10条数据)
- devices: Array.from({ length: 10 }, (_, i) => ({
- id: i,
- mac: 'CC:ba:97:11:a6:ac',
- model: 'esp32-s3-touch-amoled-1.8',
- voiceModel: 'esp32-s3-touch-amoled-1.8',
- lastConversation: '6天前',
- }))
+ devices: [],
+ originalDevices: [],
}
},
+
+ mounted() {
+ this.fetchAgentList();
+ },
+
methods: {
showAddDialog() {
this.addDeviceDialogVisible = true
@@ -71,13 +71,28 @@ export default {
// 点击配置角色后跳转到角色配置页
this.$router.push('/role-config')
},
- handleWisdomBodyAdded(name) {
- console.log('新增智慧体名称:', name)
- this.addDeviceDialogVisible = false
+ handleWisdomBodyAdded(res) {
+ console.log('新增智能体响应:', res);
+ this.fetchAgentList();
+ this.addDeviceDialogVisible = false;
},
handleDeviceManage() {
this.$router.push('/device-management');
},
+ // 获取智能体列表
+ fetchAgentList() {
+ import('@/apis/module/user').then(({ default: userApi }) => {
+ userApi.getAgentList(({data}) => {
+ this.originalDevices = data.data;
+ this.devices = data.data;
+ });
+ });
+ },
+ // 搜索更新智能体列表
+ handleSearchResult(filteredList) {
+ this.devices = filteredList; // 更新设备列表
+ }
+
}
}