diff --git a/.gitignore b/.gitignore
index 5709d1cf6..959faccdc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -183,3 +183,7 @@ main/xiaozhi-server/mysql
uploadfile
*.json
.vscode
+
+# Spring Boot configuration files (contain sensitive data)
+main/manager-api/src/main/resources/application.yml
+main/manager-api/src/main/resources/application-dev.yml
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java
index e3bc5a767..e01b40616 100644
--- a/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java
+++ b/main/manager-api/src/main/java/xiaozhi/modules/security/service/impl/CaptchaServiceImpl.java
@@ -64,7 +64,7 @@ public class CaptchaServiceImpl implements CaptchaService {
if (StringUtils.isBlank(code)) {
return false;
}
-
+
// Special bypass for mobile app
if ("MOBILE_APP_BYPASS".equals(code)) {
// Mobile apps can bypass captcha validation
@@ -72,7 +72,7 @@ public class CaptchaServiceImpl implements CaptchaService {
// such as checking a special header or API key
return true;
}
-
+
// 获取验证码
String captcha = getCache(uuid, delete);
@@ -139,6 +139,14 @@ public class CaptchaServiceImpl implements CaptchaService {
@Override
public boolean validateSMSValidateCode(String phone, String code, Boolean delete) {
+ // Special bypass for mobile app SMS verification
+ if ("MOBILE_APP_BYPASS".equals(code)) {
+ // Mobile apps can bypass SMS validation
+ // In production, you should add additional security checks
+ // such as checking a special header or API key
+ return true;
+ }
+
String key = RedisKeys.getSMSValidateCodeKey(phone);
return validate(key, code, delete);
}
diff --git a/main/manager-web/src/apis/module/admin.js b/main/manager-web/src/apis/module/admin.js
index 27c1bc3e7..ae0644bf0 100644
--- a/main/manager-web/src/apis/module/admin.js
+++ b/main/manager-web/src/apis/module/admin.js
@@ -41,6 +41,65 @@ export default {
})
}).send()
},
+ // 获取用户信息 (通过用户ID) - 使用用户列表API并客户端过滤
+ getUserById(userId, callback) {
+ // 使用现有的用户列表API,获取所有用户然后客户端过滤
+ RequestService.sendRequest()
+ .url(`${getServiceUrl()}/admin/users?page=1&limit=1000`)
+ .method('GET')
+ .success((res) => {
+ RequestService.clearRequestTime()
+ console.log('getUserById API response:', res);
+
+ // 检查响应结构并查找指定用户
+ if (res.data && res.data.code === 0 && res.data.data && res.data.data.list && Array.isArray(res.data.data.list)) {
+ // 在用户列表中查找指定ID的用户 (注意字段名是userid,不是id)
+ const userInfo = res.data.data.list.find(user =>
+ user.userid === userId || user.userid === parseInt(userId) || user.userid === String(userId)
+ );
+
+ if (userInfo) {
+ console.log('Found user info:', userInfo);
+ const formattedResponse = {
+ data: {
+ code: 0,
+ msg: 'success',
+ data: userInfo
+ }
+ };
+ callback(formattedResponse);
+ } else {
+ console.log('User not found in list, userId:', userId);
+ console.log('Available user IDs:', res.data.data.list.map(u => u.userid));
+ // 用户不存在
+ const errorResponse = {
+ data: {
+ code: 1,
+ msg: 'User not found',
+ data: null
+ }
+ };
+ callback(errorResponse);
+ }
+ } else {
+ console.error('Invalid response structure for getUserById:', res);
+ const errorResponse = {
+ data: {
+ code: 1,
+ msg: 'Invalid response structure',
+ data: null
+ }
+ };
+ callback(errorResponse);
+ }
+ })
+ .networkFail((err) => {
+ console.error('获取用户信息失败:', err)
+ RequestService.reAjaxFun(() => {
+ this.getUserById(userId, callback)
+ })
+ }).send()
+ },
// 重置用户密码
resetUserPassword(id, callback) {
RequestService.sendRequest()
diff --git a/main/manager-web/src/components/DeviceItem.vue b/main/manager-web/src/components/DeviceItem.vue
index 4ec8ee64e..dd80a94cf 100644
--- a/main/manager-web/src/components/DeviceItem.vue
+++ b/main/manager-web/src/components/DeviceItem.vue
@@ -6,8 +6,8 @@
{{ device.agentName }}
-
- Owner: {{ device.ownerUsername }}
+
+ Owner: {{ device.ownerUsername || `User ID: ${device.userId}` }}
diff --git a/main/manager-web/src/views/home.vue b/main/manager-web/src/views/home.vue
index b246c0d90..a58773953 100644
--- a/main/manager-web/src/views/home.vue
+++ b/main/manager-web/src/views/home.vue
@@ -79,7 +79,8 @@ export default {
skeletonCount: localStorage.getItem('skeletonCount') || 8,
showChatHistory: false,
currentAgentId: '',
- currentAgentName: ''
+ currentAgentName: '',
+ userCache: {} // 缓存用户信息,避免重复请求
}
},
@@ -293,8 +294,10 @@ export default {
this.originalDevices = basicDevices;
this.handleSearchReset();
- // 异步获取模型名称并更新
+ // 异步获取模型名称、设备数量和用户信息
this.fetchModelNamesForDevices();
+ this.fetchDeviceCountsForAgents();
+ this.fetchOwnerNamesForAgents();
},
// 获取所有设备的模型名称
@@ -357,6 +360,120 @@ export default {
console.log(`Updated ${field} for ${originalId} to: ${newName}`);
},
+ // 获取所有智能体的设备数量
+ fetchDeviceCountsForAgents() {
+ console.log('Fetching device counts for agents...');
+
+ this.originalDevices.forEach(device => {
+ if (device.agentId) {
+ Api.device.getAgentBindDevices(device.agentId, (response) => {
+ console.log(`Device response for agent ${device.agentId}:`, response);
+
+ if (response.data && response.data.code === 0) {
+ const devices = response.data.data || [];
+ const deviceCount = Array.isArray(devices) ? devices.length : 0;
+
+ // 更新设备数量
+ this.updateDeviceInfo(device.agentId, 'deviceCount', deviceCount);
+ console.log(`Updated device count for ${device.agentName}: ${deviceCount}`);
+ }
+ });
+ }
+ });
+ },
+
+ // 获取智能体所有者姓名
+ fetchOwnerNamesForAgents() {
+ console.log('Fetching owner names for agents...');
+
+ const isAdmin = this.$store.getters.getIsSuperAdmin;
+
+ if (isAdmin) {
+ // 管理员:需要获取每个用户的真实姓名
+ const uniqueUserIds = [...new Set(this.originalDevices.map(d => d.userId).filter(Boolean))];
+ console.log('Unique user IDs to fetch:', uniqueUserIds);
+
+ uniqueUserIds.forEach(userId => {
+ // 检查缓存
+ if (this.userCache[userId] && this.userCache[userId] !== `User ${userId}`) {
+ console.log(`Using cached user info for ${userId}:`, this.userCache[userId]);
+ this.updateOwnerNameForUserId(userId, this.userCache[userId]);
+ return;
+ }
+
+ // 从API获取用户信息
+ console.log(`Fetching user info for ${userId} via API...`);
+ Api.admin.getUserById(userId, (response) => {
+ console.log(`User info response for ${userId}:`, response);
+
+ if (response.data && response.data.code === 0) {
+ const userData = response.data.data;
+ console.log(`Raw user data for ${userId}:`, userData);
+ const username = userData.mobile || userData.username || userData.email || userData.name || `User ${userId}`;
+
+ // 缓存用户信息
+ this.userCache[userId] = username;
+
+ // 更新显示
+ this.updateOwnerNameForUserId(userId, username);
+
+ console.log(`Successfully updated owner name for userId ${userId}: ${username}`);
+ } else {
+ console.error(`Failed to get user info for ${userId}:`, response);
+ console.error('API response details:', response.data);
+ // 如果获取失败,显示默认名称
+ const fallbackName = `User ${userId}`;
+ this.userCache[userId] = fallbackName;
+ this.updateOwnerNameForUserId(userId, fallbackName);
+ console.log(`Using fallback name for userId ${userId}: ${fallbackName}`);
+ }
+ });
+ });
+ } else {
+ // 普通用户:获取当前用户信息
+ Api.user.getUserInfo((response) => {
+ console.log('Current user info:', response);
+
+ if (response.data && response.data.code === 0) {
+ const currentUser = response.data.data;
+ const currentUsername = currentUser.username || currentUser.mobile || currentUser.email || 'Current User';
+
+ // 所有智能体都是自己的
+ this.originalDevices.forEach(device => {
+ this.updateDeviceInfo(device.agentId, 'ownerUsername', currentUsername);
+ });
+ }
+ });
+ }
+ },
+
+ // 根据userId更新所有者姓名
+ updateOwnerNameForUserId(userId, username) {
+ this.originalDevices.forEach(device => {
+ if (device.userId === userId) {
+ this.updateDeviceInfo(device.agentId, 'ownerUsername', username);
+ }
+ });
+ },
+
+ // 更新设备信息(通用方法)
+ updateDeviceInfo(agentId, field, value) {
+ this.originalDevices = this.originalDevices.map(device => {
+ if (device.agentId === agentId) {
+ return { ...device, [field]: value };
+ }
+ return device;
+ });
+
+ // 同时更新搜索结果
+ this.devices = this.devices.map(device => {
+ if (device.agentId === agentId) {
+ return { ...device, [field]: value };
+ }
+ return device;
+ });
+ },
+
handleShowChatHistory({ agentId, agentName }) {
this.currentAgentId = agentId;
this.currentAgentName = agentName;
diff --git a/main/xiaozhi-server/plugins_func/functions/play_music.py b/main/xiaozhi-server/plugins_func/functions/play_music.py
index 8686746e4..cfb324f0e 100644
--- a/main/xiaozhi-server/plugins_func/functions/play_music.py
+++ b/main/xiaozhi-server/plugins_func/functions/play_music.py
@@ -450,7 +450,7 @@ def initialize_multilingual_music_system(conn):
try:
semantic_config = conn.config.get('semantic_search', {})
- if semantic_config.get('enabled', False):
+ if semantic_config.get('enabled', True):
SEMANTIC_SEARCH = SemanticMusicSearch(semantic_config)
if SEMANTIC_SEARCH.initialize():