diff --git a/main/manager-web/src/apis/module/agent.js b/main/manager-web/src/apis/module/agent.js index b90c932c..5cbd60cb 100644 --- a/main/manager-web/src/apis/module/agent.js +++ b/main/manager-web/src/apis/module/agent.js @@ -398,4 +398,35 @@ export default { }); }).send(); }, + // 获取智能体标签 + getAgentTags(agentId, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/agent/${agentId}/tags`) + .method('GET') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .networkFail(() => { + RequestService.reAjaxFun(() => { + this.getAgentTags(agentId, callback); + }); + }).send(); + }, + // 保存智能体标签 + saveAgentTags(agentId, tags, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/agent/${agentId}/tags`) + .method('PUT') + .data(tags) + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .networkFail(() => { + RequestService.reAjaxFun(() => { + this.saveAgentTags(agentId, tags, callback); + }); + }).send(); + }, } diff --git a/main/manager-web/src/components/DeviceItem.vue b/main/manager-web/src/components/DeviceItem.vue index c29d3243..28cbcb5b 100644 --- a/main/manager-web/src/components/DeviceItem.vue +++ b/main/manager-web/src/components/DeviceItem.vue @@ -39,6 +39,11 @@
{{ $t('home.lastConversation') }}:{{ formattedLastConnectedTime }}
+
+
+ {{ tag }} +
+
@@ -81,6 +86,10 @@ export default { } else { return this.device.lastConnectedAt; } + }, + tags() { + if (!this.device.tags) return []; + return this.device.tags.map((tag) => tag.tagName); } }, methods: { @@ -102,15 +111,34 @@ export default { } this.$emit('chat-history', { agentId: this.device.agentId, agentName: this.device.agentName }) } + }, + watch: { + tags: { + handler(newTags) { + if (newTags.length === 0) return; + this.$nextTick(() => { + const scrollWidth = this.$refs.scrollRef.clientWidth; + const tagsWidth = this.$refs.tagsRef.clientWidth; + if (tagsWidth < scrollWidth) { + this.$refs.tagsRef.style.width = '100%'; + this.$refs.tagsRef.style.justifyContent = 'flex-end'; + } else { + this.$refs.tagsRef.style.width = 'fit-content'; + this.$refs.tagsRef.style.justifyContent = 'flex-start'; + } + }) + }, + immediate: true + } } } -