From 94a43432fc0eaed3bb37f7cfccef13991512c526 Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Sat, 15 Nov 2025 09:51:58 +0800 Subject: [PATCH 01/40] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=9F=B3=E8=89=B2?= =?UTF-8?q?=E7=9A=84=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=9B=B4=E6=96=B9=E4=BE=BF=E7=9A=84=E8=AF=95=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaozhi/modules/model/dto/VoiceDTO.java | 26 + .../service/impl/TimbreServiceImpl.java | 11 +- main/manager-web/src/views/roleConfig.vue | 630 +++++++++++++----- 3 files changed, 491 insertions(+), 176 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java index 25358eb05..fe4586892 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java @@ -19,4 +19,30 @@ public class VoiceDTO implements Serializable { @Schema(description = "音色名称") private String name; + + @Schema(description = "音频播放地址") + private String voiceDemo; + + // 添加双参数构造函数,保持向后兼容 + public VoiceDTO(String id, String name) { + this.id = id; + this.name = name; + this.voiceDemo = null; + } + + // 为了兼容性,添加其他可能的音频字段别名 + @Schema(hidden = true) + public String getDemoUrl() { + return voiceDemo; + } + + @Schema(hidden = true) + public String getAudioUrl() { + return voiceDemo; + } + + @Schema(hidden = true) + public String getReferenceAudio() { + return voiceDemo; + } } \ No newline at end of file diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java index 8ebb21552..d0b8350cc 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java @@ -133,7 +133,11 @@ public class TimbreServiceImpl extends BaseServiceImpl timbreEntities = new ArrayList<>(); } List voiceDTOs = timbreEntities.stream() - .map(entity -> new VoiceDTO(entity.getId(), entity.getName())) + .map(entity -> { + VoiceDTO dto = new VoiceDTO(entity.getId(), entity.getName()); + dto.setVoiceDemo(entity.getVoiceDemo()); + return dto; + }) .collect(Collectors.toList()); // 获取当前登录用户ID @@ -205,6 +209,9 @@ public class TimbreServiceImpl extends BaseServiceImpl if (list.isEmpty()) { return null; } - return new VoiceDTO(list.get(0).getId(), list.get(0).getName()); + TimbreEntity entity = list.get(0); + VoiceDTO dto = new VoiceDTO(entity.getId(), entity.getName()); + dto.setVoiceDemo(entity.getVoiceDemo()); + return dto; } } \ No newline at end of file diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue index bc561f94b..e99270e43 100644 --- a/main/manager-web/src/views/roleConfig.vue +++ b/main/manager-web/src/views/roleConfig.vue @@ -3,7 +3,7 @@
-

{{ $t('roleConfig.title') }}

+

{{ $t("roleConfig.title") }}

@@ -12,21 +12,21 @@
- +
{{ form.agentName }}
- - {{ $t('roleConfig.restartNotice') }} + + {{ $t("roleConfig.restartNotice") }}
- {{ $t('roleConfig.saveConfig') }} + {{ $t("roleConfig.saveConfig") }} - {{ $t('roleConfig.reset') }} - + {{ + $t("roleConfig.reset") + }} +
@@ -36,97 +36,210 @@
- +
-
+
{{ template.agentName }}
- + - + - - + + - - + +
- - + +
- - + +
- +
- - + +
- +
功能名称: {{ func.name }}
-
+
{{ func.name.charAt(0) }}
- - {{ $t('roleConfig.editFunctions') }} + + {{ $t("roleConfig.editFunctions") }}
-
- - {{ $t('roleConfig.reportText') }} - {{ $t('roleConfig.reportTextVoice') }} +
+ + {{ + $t("roleConfig.reportText") + }} + {{ + $t("roleConfig.reportTextVoice") + }}
- - + + +
+ {{ item.label }} + +
+
@@ -137,19 +250,25 @@
- +
\ No newline at end of file + From d45bf5f60aee2396df9713b4b4d2bd2921017831 Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:45:22 +0800 Subject: [PATCH 02/40] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TimbreServiceImpl.java | 2 + .../mapper/voiceclone/VoiceCloneDao.xml | 2 +- main/manager-web/src/views/roleConfig.vue | 159 ++++++++++++------ 3 files changed, 115 insertions(+), 48 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java index d0b8350cc..feb6c4499 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/timbre/service/impl/TimbreServiceImpl.java @@ -150,6 +150,8 @@ public class TimbreServiceImpl extends BaseServiceImpl VoiceDTO voiceDTO = new VoiceDTO(); voiceDTO.setId(entity.getId()); voiceDTO.setName(MessageUtils.getMessage(ErrorCode.VOICE_CLONE_PREFIX) + entity.getName()); + // 保留从数据库查询到的voiceDemo字段 + voiceDTO.setVoiceDemo(entity.getVoiceDemo()); redisUtils.set(RedisKeys.getTimbreNameById(voiceDTO.getId()), voiceDTO.getName(), RedisUtils.NOT_EXPIRE); voiceDTOs.add(0, voiceDTO); diff --git a/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml b/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml index d76585920..0f0a458c0 100644 --- a/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml +++ b/main/manager-api/src/main/resources/mapper/voiceclone/VoiceCloneDao.xml @@ -3,7 +3,7 @@ diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue index e99270e43..2db769009 100644 --- a/main/manager-web/src/views/roleConfig.vue +++ b/main/manager-web/src/views/roleConfig.vue @@ -221,25 +221,37 @@ class="form-select" > -
- {{ item.label }} - -
-
+ v-for="(item, index) in voiceOptions" + :key="`voice-${index}`" + :label="item.label" + :value="item.value" + > +
+ {{ item.label }} + +
+
@@ -321,7 +333,9 @@ export default { allFunctions: [], originalFunctions: [], playingVoice: false, + isPaused: false, currentAudio: null, + currentPlayingVoiceId: null, }; }, methods: { @@ -555,9 +569,16 @@ export default { this.voiceOptions = data.data.map((voice) => ({ value: voice.id, label: voice.name, + // 复制音频相关字段,确保hasAudioPreview能检测到 + voiceDemo: voice.voiceDemo, + demoUrl: voice.demoUrl, + audioUrl: voice.audioUrl, + voice_demo: voice.voice_demo, + sample_voice: voice.sample_voice, + referenceAudio: voice.referenceAudio, })); // 保存完整的音色信息,添加调试信息 - console.log('获取到的音色数据:', data.data); + console.log("获取到的音色数据:", data.data); this.voiceDetails = data.data.reduce((acc, voice) => { acc[voice.id] = voice; return acc; @@ -676,17 +697,54 @@ export default { }, // 检查是否有音频预览 hasAudioPreview(item) { - // 检查item中是否包含音频相关字段 - const hasAudioFields = item.voiceDemo || item.demoUrl || item.audioUrl || - item.voice_demo || item.sample_voice || item.referenceAudio; - return hasAudioFields && typeof hasAudioFields === 'string' && hasAudioFields.trim() !== ''; + // 检查item中是否包含有效的音频URL字段,且URL必须以http开头 + const audioFields = [ + item.voiceDemo, + item.demoUrl, + item.audioUrl, + item.voice_demo, + item.sample_voice, + item.referenceAudio + ]; + + // 检查是否有任何音频字段是以http开头的有效URL + return audioFields.some(field => + field !== undefined && + field !== null && + typeof field === "string" && + field.trim() !== "" && + field.toLowerCase().startsWith("http") + ); }, - + + // 播放/暂停音频切换 + toggleAudioPlayback(voiceId) { + // 如果点击的是当前正在播放的音频,则切换暂停/播放状态 + if (this.playingVoice && this.currentPlayingVoiceId === voiceId) { + if (this.isPaused) { + // 从暂停状态恢复播放 + this.currentAudio.play().catch((error) => { + console.error("恢复播放失败:", error); + this.$message.warning("无法恢复播放音频"); + }); + this.isPaused = false; + } else { + // 暂停播放 + this.currentAudio.pause(); + this.isPaused = true; + } + return; + } + + // 否则开始播放新的音频 + this.playVoicePreview(voiceId); + }, + // 播放音色预览 playVoicePreview(voiceId = null) { // 如果传入了voiceId,则使用传入的,否则使用当前选中的 const targetVoiceId = voiceId || this.form.ttsVoiceId; - + if (!targetVoiceId) { this.$message.warning("请先选择一个音色"); return; @@ -698,34 +756,41 @@ export default { this.currentAudio = null; } + // 重置播放状态 + this.isPaused = false; + this.currentPlayingVoiceId = targetVoiceId; + try { // 从保存的音色详情中获取音频URL const voiceDetail = this.voiceDetails[targetVoiceId]; - + // 添加调试信息 - console.log('当前选择的音色ID:', targetVoiceId); - console.log('音色详情:', voiceDetail); - + console.log("当前选择的音色ID:", targetVoiceId); + console.log("音色详情:", voiceDetail); + // 尝试多种可能的音频属性名 let audioUrl = null; if (voiceDetail) { // 首先尝试直接从voiceDetail中获取各种可能的音频字段 - audioUrl = voiceDetail.voiceDemo || - voiceDetail.demoUrl || - voiceDetail.audioUrl || - voiceDetail.voice_demo || - voiceDetail.sample_voice; - + audioUrl = + voiceDetail.voiceDemo || + voiceDetail.demoUrl || + voiceDetail.audioUrl || + voiceDetail.voice_demo || + voiceDetail.sample_voice; + // 如果没有找到,尝试检查是否有URL格式的字段 if (!audioUrl) { for (const key in voiceDetail) { const value = voiceDetail[key]; - if (typeof value === 'string' && - (value.startsWith('http://') || - value.startsWith('https://') || - value.endsWith('.mp3') || - value.endsWith('.wav') || - value.endsWith('.ogg'))) { + if ( + typeof value === "string" && + (value.startsWith("http://") || + value.startsWith("https://") || + value.endsWith(".mp3") || + value.endsWith(".wav") || + value.endsWith(".ogg")) + ) { audioUrl = value; console.log(`发现可能的音频URL在字段 '${key}':`, audioUrl); break; @@ -733,7 +798,7 @@ export default { } } } - + if (!audioUrl) { // 如果没有音频URL,显示友好的提示 this.$message.warning("该音色暂无可预览的音频"); @@ -742,7 +807,7 @@ export default { // 设置播放状态 this.playingVoice = true; - + // 创建并播放音频 this.currentAudio = new Audio(audioUrl); @@ -760,7 +825,7 @@ export default { // 监听播放错误 this.currentAudio.onerror = () => { clearTimeout(timeoutId); - console.error('音频播放错误'); + console.error("音频播放错误"); this.$message.warning("音频播放失败"); this.playingVoice = false; }; @@ -778,7 +843,7 @@ export default { // 实际调用play方法开始播放 this.currentAudio.play().catch((error) => { clearTimeout(timeoutId); - console.error('播放失败:', error); + console.error("播放失败:", error); this.$message.warning("无法播放音频"); this.playingVoice = false; }); @@ -952,7 +1017,7 @@ export default { } .play-button { - color: #409EFF; + color: #409eff; transition: color 0.3s; } From d121b4d0e181b6991584e117e6c584e5e981a52b Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:48:52 +0800 Subject: [PATCH 03/40] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaozhi/modules/model/dto/VoiceDTO.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java index fe4586892..4db614ef4 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/model/dto/VoiceDTO.java @@ -19,30 +19,15 @@ public class VoiceDTO implements Serializable { @Schema(description = "音色名称") private String name; - + @Schema(description = "音频播放地址") private String voiceDemo; - + // 添加双参数构造函数,保持向后兼容 public VoiceDTO(String id, String name) { this.id = id; this.name = name; this.voiceDemo = null; } - - // 为了兼容性,添加其他可能的音频字段别名 - @Schema(hidden = true) - public String getDemoUrl() { - return voiceDemo; - } - - @Schema(hidden = true) - public String getAudioUrl() { - return voiceDemo; - } - - @Schema(hidden = true) - public String getReferenceAudio() { - return voiceDemo; - } + } \ No newline at end of file From bdd0ec41d58e9c79b5895dcba0beed1dc0639d98 Mon Sep 17 00:00:00 2001 From: rainv123 <2148537152@qq.com> Date: Sat, 15 Nov 2025 14:55:43 +0800 Subject: [PATCH 04/40] =?UTF-8?q?fix:manager-api=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaozhi/common/exception/ErrorCode.java | 15 ++++ .../AgentChatHistoryController.java | 4 +- .../service/impl/ConfigServiceImpl.java | 6 +- .../device/controller/DeviceController.java | 2 +- .../impl/KnowledgeBaseServiceImpl.java | 45 +++++------ .../impl/KnowledgeFilesServiceImpl.java | 80 ++++++++++--------- .../controller/VoiceCloneController.java | 10 +-- .../service/impl/VoiceCloneServiceImpl.java | 2 +- .../main/resources/i18n/messages.properties | 17 +++- .../resources/i18n/messages_en_US.properties | 9 +++ .../resources/i18n/messages_zh_CN.properties | 13 ++- .../resources/i18n/messages_zh_TW.properties | 11 ++- 12 files changed, 137 insertions(+), 77 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java b/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java index 659e135ac..1896ff115 100644 --- a/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java +++ b/main/manager-api/src/main/java/xiaozhi/common/exception/ErrorCode.java @@ -213,4 +213,19 @@ public interface ErrorCode { int RAG_API_ERROR_API_KEY_NULL = 10172; // RAG配置中api_key为空,请完善配置 int RAG_API_ERROR_API_KEY_INVALID = 10173; // RAG配置中api_key包含占位符,请替换为实际的API密钥 int RAG_API_ERROR_URL_INVALID = 10174; // RAG配置中base_url格式不正确,请检查协议是否正确 + int RAG_DATASET_ID_NOT_NULL = 10176; // RAG配置中dataset_id不能为空 + int RAG_MODEL_ID_NOT_NULL = 10177; // RAG配置中model_id不能为空 + int RAG_DATASET_ID_AND_MODEL_ID_NOT_NULL = 10178; // RAG配置中dataset_id和model_id不能为空 + int RAG_FILE_NAME_NOT_NULL = 10179; // 文件名称不能为空 + int RAG_FILE_CONTENT_EMPTY = 10180; // 文件内容不能为空 + + // 设备相关错误码(补充) + int MCA_NOT_NULL = 10175; // mac地址不能为空 + + // 音色克隆(补充) + int VOICE_CLONE_NAME_NOT_NULL = 10181; // 音色克隆名称不能为空 + int VOICE_CLONE_AUDIO_NOT_FOUND = 10182; // 音色克隆音频不存在 + + // 智能体模板相关错误码(补充) + int AGENT_TEMPLATE_NOT_FOUND = 10183; // 默认智能体未找到 } diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java index 53c85d72a..49096d43e 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentChatHistoryController.java @@ -139,14 +139,14 @@ public class AgentChatHistoryController { // 从Redis获取agentId和sessionId String agentSessionInfo = (String) redisUtils.get(RedisKeys.getChatHistoryKey(uuid)); if (StringUtils.isBlank(agentSessionInfo)) { - throw new RenException("下载链接已过期或无效"); + throw new RenException(ErrorCode.DOWNLOAD_LINK_EXPIRED); } try { // 解析agentId和sessionId String[] parts = agentSessionInfo.split(":"); if (parts.length != 2) { - throw new RenException("下载链接无效"); + throw new RenException(ErrorCode.DOWNLOAD_LINK_INVALID); } String agentId = parts[0]; String sessionId = parts[1]; diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java index 7883b8c1e..3ab3d9779 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java @@ -73,7 +73,7 @@ public class ConfigServiceImpl implements ConfigService { // 查询默认智能体 AgentTemplateEntity agent = agentTemplateService.getDefaultTemplate(); if (agent == null) { - throw new RenException("默认智能体未找到"); + throw new RenException(ErrorCode.AGENT_TEMPLATE_NOT_FOUND); } // 构建模块配置 @@ -111,13 +111,13 @@ public class ConfigServiceImpl implements ConfigService { if (StringUtils.isNotBlank(cachedCode)) { throw new RenException(ErrorCode.OTA_DEVICE_NEED_BIND, cachedCode); } - throw new RenException(ErrorCode.OTA_DEVICE_NOT_FOUND, "not found device"); + throw new RenException(ErrorCode.OTA_DEVICE_NOT_FOUND); } // 获取智能体信息 AgentEntity agent = agentService.getAgentById(device.getAgentId()); if (agent == null) { - throw new RenException("智能体未找到"); + throw new RenException(ErrorCode.AGENT_NOT_FOUND); } // 获取音色信息 String voice = null; diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java index a3f9d2366..ff6069bf0 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java @@ -69,7 +69,7 @@ public class DeviceController { public Result registerDevice(@RequestBody DeviceRegisterDTO deviceRegisterDTO) { String macAddress = deviceRegisterDTO.getMacAddress(); if (StringUtils.isBlank(macAddress)) { - return new Result().error(ErrorCode.NOT_NULL, "mac地址不能为空"); + return new Result().error(ErrorCode.MCA_NOT_NULL); } // 生成六位验证码 String code = String.valueOf(Math.random()).substring(2, 8); diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeBaseServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeBaseServiceImpl.java index c61df49ba..ddde71956 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeBaseServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeBaseServiceImpl.java @@ -356,7 +356,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl getRAGConfigByDatasetId(String datasetId) { if (StringUtils.isBlank(datasetId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "datasetId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_NOT_NULL); } // 根据datasetId查询知识库信息 @@ -370,7 +370,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl config) { if (config == null) { - throw new RenException(ErrorCode.RAG_CONFIG_NOT_FOUND, "RAG配置为空,请检查配置"); + throw new RenException(ErrorCode.RAG_CONFIG_NOT_FOUND); } // 从配置中提取必要的参数 @@ -510,8 +510,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl getValidatedRAGConfig(String ragModelId) { if (StringUtils.isBlank(ragModelId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "ragModelId不能为空"); + throw new RenException(ErrorCode.RAG_MODEL_ID_NOT_NULL); } Map ragConfig = getRAGConfig(ragModelId); diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeFilesServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeFilesServiceImpl.java index edf6238e5..069d51cdd 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeFilesServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/service/impl/KnowledgeFilesServiceImpl.java @@ -63,7 +63,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { // 构建请求URL - 根据RAGFlow API文档,获取文档列表的接口 String datasetId = knowledgeFilesDTO != null ? knowledgeFilesDTO.getDatasetId() : null; if (StringUtils.isBlank(datasetId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "datasetId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_NOT_NULL); } // 获取RAG配置 @@ -109,7 +109,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { if (!response.getStatusCode().is2xxSuccessful()) { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); - throw new RenException(ErrorCode.RAG_API_ERROR, "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode()); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode().toString()); } String responseBody = response.getBody(); @@ -133,7 +133,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("获取文档列表失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -229,7 +229,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("获取文档列表响应失败: {}", e.getMessage(), e); - throw new RenException(ErrorCode.RAG_API_ERROR, "获取文档列表响应失败: " + e.getMessage()); + throw new RenException(ErrorCode.RAG_API_ERROR, e.getMessage()); } } @@ -442,7 +442,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { @Override public KnowledgeFilesDTO getByDocumentId(String documentId, String datasetId) { if (StringUtils.isBlank(documentId) || StringUtils.isBlank(datasetId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "documentId和datasetId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_AND_MODEL_ID_NOT_NULL); } log.info("=== 开始根据documentId获取文档 ==="); @@ -475,8 +475,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); String responseBody = response.getBody(); throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + - ", 响应内容: " + (responseBody != null ? responseBody : "无响应内容")); + response.getStatusCode() + (responseBody != null ? responseBody : "null")); } String responseBody = response.getBody(); @@ -507,7 +506,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("根据documentId获取文档失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -521,7 +520,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { public PageData getPageListByStatus(String datasetId, Integer status, Integer page, Integer limit) { if (StringUtils.isBlank(datasetId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "datasetId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_NOT_NULL); } log.info("=== 开始根据状态查询文档列表 ==="); @@ -568,7 +567,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { if (!response.getStatusCode().is2xxSuccessful()) { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); - throw new RenException(ErrorCode.RAG_API_ERROR, "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode()); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode().toString()); } String responseBody = response.getBody(); @@ -600,12 +599,12 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { return pageData; } else { log.error("RAGFlow API调用失败,响应码: {}", code); - throw new RenException(ErrorCode.RAG_API_ERROR, "RAGFlow API调用失败,响应码: " + code); + throw new RenException(ErrorCode.RAG_API_ERROR, code.toString()); } } catch (Exception e) { log.error("根据状态查询文档列表失败: {}", e.getMessage(), e); - throw new RenException(ErrorCode.RAG_API_ERROR, "查询文档列表失败: " + e.getMessage()); + throw new RenException(ErrorCode.RAG_API_ERROR, e.getMessage()); } finally { log.info("=== 根据状态查询文档列表操作结束 ==="); } @@ -635,12 +634,12 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { // 检查文件基本信息 if (StringUtils.isBlank(fileName)) { log.error("文件名为空"); - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "文件名不能为空"); + throw new RenException(ErrorCode.RAG_FILE_NAME_NOT_NULL); } if (fileSize == 0) { log.error("文件大小为0"); - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "文件内容为空"); + throw new RenException(ErrorCode.RAG_FILE_CONTENT_EMPTY); } log.info("2. 开始流式上传到RAGFlow"); @@ -676,7 +675,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { @Override public void deleteByDocumentId(String documentId, String datasetId) { if (StringUtils.isBlank(documentId) || StringUtils.isBlank(datasetId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "documentId和datasetId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_AND_MODEL_ID_NOT_NULL); } log.info("=== 开始根据documentId删除文档 ==="); @@ -691,7 +690,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("删除文档失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -763,7 +762,22 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { // 验证base_url是否存在且非空 if (StringUtils.isBlank(baseUrl)) { - throw new RenException(ErrorCode.RAG_API_ERROR, "RAG配置缺少必要参数: base_url"); + throw new RenException(ErrorCode.RAG_API_ERROR_URL_NULL); + } + + // 验证api_key是否存在且非空 + if (StringUtils.isBlank(apiKey)) { + throw new RenException(ErrorCode.RAG_API_ERROR_API_KEY_NULL); + } + + // 检查api_key是否包含占位符 + if (apiKey.contains("你")) { + throw new RenException(ErrorCode.RAG_API_ERROR_API_KEY_INVALID); + } + + // 验证base_url格式 + if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) { + throw new RenException(ErrorCode.RAG_API_ERROR_URL_INVALID); } } @@ -876,9 +890,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } } else { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); - throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + - ", 响应内容: " + (responseBody != null ? responseBody : "无响应内容")); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode().toString()); } if (StringUtils.isBlank(documentId)) { @@ -890,7 +902,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("RAGFlow API调用失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -1027,13 +1039,12 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } else { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + - ", 响应内容: " + (responseBody != null ? responseBody : "无响应内容")); + response.getStatusCode() + (responseBody != null ? responseBody : "null")); } } catch (Exception e) { log.error("RAGFlow API调用失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -1082,7 +1093,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { @Override public boolean parseDocuments(String datasetId, List documentIds) { if (StringUtils.isBlank(datasetId) || documentIds == null || documentIds.isEmpty()) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "datasetId和documentIds不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_AND_MODEL_ID_NOT_NULL); } log.info("=== 开始解析文档(切块) ==="); @@ -1122,8 +1133,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { if (!response.getStatusCode().is2xxSuccessful()) { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); String errorDetail = responseBody != null ? responseBody : "无响应内容"; - throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + ", 响应内容: " + errorDetail); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode() + errorDetail); } // 解析响应 @@ -1143,7 +1153,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("解析文档失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -1157,7 +1167,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { public Map listChunks(String datasetId, String documentId, String keywords, Integer page, Integer pageSize, String chunkId) { if (StringUtils.isBlank(datasetId) || StringUtils.isBlank(documentId)) { - throw new RenException(ErrorCode.PARAMS_GET_ERROR, "datasetId和documentId不能为空"); + throw new RenException(ErrorCode.RAG_DATASET_ID_AND_MODEL_ID_NOT_NULL); } log.info("=== 开始列出切片 ==="); @@ -1220,8 +1230,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { if (!response.getStatusCode().is2xxSuccessful()) { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); String errorDetail = responseBody != null ? responseBody : "无响应内容"; - throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + ", 响应内容: " + errorDetail); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode() + errorDetail); } // 解析响应 @@ -1243,11 +1252,11 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (IOException e) { log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; throw new RenException(ErrorCode.RAG_API_ERROR, errorMessage); } catch (Exception e) { log.error("列出切片失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } @@ -1646,8 +1655,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { if (!response.getStatusCode().is2xxSuccessful()) { log.error("RAGFlow API调用失败,状态码: {}", response.getStatusCode()); String errorDetail = responseBody != null ? responseBody : "无响应内容"; - throw new RenException(ErrorCode.RAG_API_ERROR, - "RAGFlow API调用失败,HTTP状态码: " + response.getStatusCode() + ", 响应内容: " + errorDetail); + throw new RenException(ErrorCode.RAG_API_ERROR, response.getStatusCode() + errorDetail); } // 解析响应 @@ -1674,7 +1682,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService { } catch (Exception e) { log.error("召回测试失败: {}", e.getMessage(), e); - String errorMessage = e.getMessage() != null ? e.getMessage() : "未知错误"; + String errorMessage = e.getMessage() != null ? e.getMessage() : "null"; if (e instanceof RenException) { throw (RenException) e; } diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java index b7de9332c..a85dd34a0 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/controller/VoiceCloneController.java @@ -107,10 +107,10 @@ public class VoiceCloneController { String name = params.get("name"); if (id == null || id.isEmpty()) { - return new Result().error(ErrorCode.IDENTIFIER_NOT_NULL, "唯一标识不能为空"); + return new Result().error(ErrorCode.IDENTIFIER_NOT_NULL); } - if (name == null) { - return new Result().error(ErrorCode.NOT_NULL, "名称不能为空"); + if (name == null || name.isEmpty()) { + return new Result().error(ErrorCode.VOICE_CLONE_NAME_NOT_NULL); } // 检查权限 checkPermission(id); @@ -119,7 +119,7 @@ public class VoiceCloneController { redisUtils.delete(RedisKeys.getTimbreNameById(id)); return new Result(); } catch (Exception e) { - return new Result().error(ErrorCode.UPDATE_DATA_FAILED, "更新失败: " + e.getMessage()); + return new Result().error(ErrorCode.UPDATE_DATA_FAILED, e.getMessage()); } } @@ -131,7 +131,7 @@ public class VoiceCloneController { checkPermission(id); byte[] audioData = voiceCloneService.getVoiceData(id); if (audioData == null) { - return new Result().error(ErrorCode.RESOURCE_NOT_FOUND, "音频不存在"); + return new Result().error(ErrorCode.VOICE_CLONE_AUDIO_NOT_FOUND); } String uuid = UUID.randomUUID().toString(); redisUtils.set(RedisKeys.getVoiceCloneAudioIdKey(uuid), id); diff --git a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java index bc13d2aa1..cdfb5cf18 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/voiceclone/service/impl/VoiceCloneServiceImpl.java @@ -100,7 +100,7 @@ public class VoiceCloneServiceImpl extends BaseServiceImpl 0) { - throw new RenException(ErrorCode.VOICE_ID_ALREADY_EXISTS, "音色ID " + voiceId + " 已存在"); + throw new RenException(ErrorCode.VOICE_ID_ALREADY_EXISTS); } } diff --git a/main/manager-api/src/main/resources/i18n/messages.properties b/main/manager-api/src/main/resources/i18n/messages.properties index ebde5cdf1..6cdd8d1e8 100644 --- a/main/manager-api/src/main/resources/i18n/messages.properties +++ b/main/manager-api/src/main/resources/i18n/messages.properties @@ -164,7 +164,7 @@ 10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E 10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801{0} +10158=\u514b\u9686\u97f3\u8272: 10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 @@ -176,4 +176,17 @@ 10167=\u0052\u0041\u0047\u8c03\u7528\u5931\u8d25\uFF0C{0} 10168=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25 10169=\u60A8\u6CA1\u6709\u6743\u9650\u64CD\u4F5C\u8BE5\u8BB0\u5F55 -10170=\u77E5\u8BC6\u5E93\u540D\u79F0\u91CD\u590D \ No newline at end of file +10170=\u77E5\u8BC6\u5E93\u540D\u79F0\u91CD\u590D +10171=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A +10172=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A +10173=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 +10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 +10175=mac\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A +10176=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A +10177=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A +10178=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A +10179=\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a +10180=\u6587\u4ef6\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a +10181=\u97f3\u8272\u514b\u9686\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a +10182=\u97f3\u8272\u514b\u9686\u97f3\u9891\u4e0d\u5b58\u5728 +10183=\u9ed8\u8ba4\u667a\u80fd\u4f53\u672a\u627e\u5230 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_en_US.properties b/main/manager-api/src/main/resources/i18n/messages_en_US.properties index 5774b8f62..75510d37f 100644 --- a/main/manager-api/src/main/resources/i18n/messages_en_US.properties +++ b/main/manager-api/src/main/resources/i18n/messages_en_US.properties @@ -181,3 +181,12 @@ 10172=RAG configuration api_key cannot be empty 10173=RAG configuration api_key cannot contain placeholder, please replace with actual API key 10174=RAG configuration base_url format error, must start with http or https +10175=Mac address cannot be empty +10176=RAG configuration dataset_id cannot be empty +10177=RAG configuration model_id cannot be empty +10178=RAG configuration dataset_id and model_id cannot be empty +10179=File name cannot be empty +10180=File content cannot be empty +10181=Voice clone name cannot be empty +10182=Voice clone audio not found +10183=Default agent template not found \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties b/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties index 573d61428..6cdd8d1e8 100644 --- a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties +++ b/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties @@ -164,7 +164,7 @@ 10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E 10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u514B\u9686\u8272\u97F3: +10158=\u514b\u9686\u97f3\u8272: 10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 @@ -180,4 +180,13 @@ 10171=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A 10172=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A 10173=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 -10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 \ No newline at end of file +10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 +10175=mac\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A +10176=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A +10177=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A +10178=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A +10179=\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a +10180=\u6587\u4ef6\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a +10181=\u97f3\u8272\u514b\u9686\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a +10182=\u97f3\u8272\u514b\u9686\u97f3\u9891\u4e0d\u5b58\u5728 +10183=\u9ed8\u8ba4\u667a\u80fd\u4f53\u672a\u627e\u5230 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties b/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties index c57f9e2c6..6a7d7d72a 100644 --- a/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties +++ b/main/manager-api/src/main/resources/i18n/messages_zh_TW.properties @@ -164,7 +164,7 @@ 10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11appid\u6216access_token 10156=\u97FF\u61C9\u683C\u5F0F\u932F\u8AA4\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 10157=\u8ACB\u6C42\u5931\u6557 -10158=\u514B\u9686\u8A9E\u97F3: +10158=\u514b\u9686\u97f3\u8272: 10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u932F\u8AA4\uFF0C\u5FC5\u9808\u4EE5S_\u958B\u982D 10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 @@ -181,3 +181,12 @@ 10172=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A 10173=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 +10175=mac\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A +10176=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A +10177=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A +10178=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A +10179=\u6587\u4ef6\u540d\u7a31\u4e0d\u80fd\u70ba\u7a7a +10180=\u6587\u4ef6\u5185\u5bb9\u4e0d\u80fd\u70ba\u7a7a +10181=\u97f3\u8272\u514b\u9686\u540d\u7a31\u4e0d\u80fd\u70ba\u7a7a +10182=\u97f3\u8272\u514b\u9686\u97f3\u983b\u4e0d\u5b58\u5728 +10183=\u9ed8\u8ba4\u667a\u80fd\u4f53\u672a\u627e\u5230 \ No newline at end of file From 5050ea7ac15c6a06a21c56e92ede3a6bd983b42e Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Sat, 15 Nov 2025 16:06:58 +0800 Subject: [PATCH 05/40] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=85=8B=E9=9A=86=E9=9F=B3=E8=89=B2=E5=90=8E=E8=AF=95=E5=90=AC?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/views/roleConfig.vue | 205 +++++++++++++++++----- 1 file changed, 159 insertions(+), 46 deletions(-) diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue index 2db769009..f1024ed81 100644 --- a/main/manager-web/src/views/roleConfig.vue +++ b/main/manager-web/src/views/roleConfig.vue @@ -275,6 +275,8 @@ - - - - diff --git a/main/xiaozhi-server/test/default-mcp-tools.json b/main/xiaozhi-server/test/default-mcp-tools.json deleted file mode 100644 index 2d44f2dc7..000000000 --- a/main/xiaozhi-server/test/default-mcp-tools.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "name": "self.get_device_status", - "description": "Provides the real-time information of the device, including the current status of the audio speaker, screen, battery, network, etc.\nUse this tool for: \n1. Answering questions about current condition (e.g. what is the current volume of the audio speaker?)\n2. As the first step to control the device (e.g. turn up / down the volume of the audio speaker, etc.)", - "inputSchema": { - "type": "object", - "properties": {} - }, - "mockResponse": { - "audio_speaker": { - "volume": 50, - "muted": false - }, - "screen": { - "brightness": 80, - "theme": "light" - }, - "battery": { - "level": 85, - "charging": false - }, - "network": { - "connected": true, - "type": "wifi" - } - } - }, - { - "name": "self.audio_speaker.set_volume", - "description": "Set the volume of the audio speaker. If the current volume is unknown, you must call `self.get_device_status` tool first and then call this tool.", - "inputSchema": { - "type": "object", - "properties": { - "volume": { - "type": "integer", - "minimum": 0, - "maximum": 100 - } - }, - "required": [ - "volume" - ] - }, - "mockResponse": { - "success": true, - "volume": "${volume}", - "message": "音量已设置为 ${volume}" - } - }, - { - "name": "self.screen.set_brightness", - "description": "Set the brightness of the screen.", - "inputSchema": { - "type": "object", - "properties": { - "brightness": { - "type": "integer", - "minimum": 0, - "maximum": 100 - } - }, - "required": [ - "brightness" - ] - }, - "mockResponse": { - "success": true, - "brightness": "${brightness}", - "message": "亮度已设置为 ${brightness}" - } - } -] \ No newline at end of file diff --git a/main/xiaozhi-server/test/js/StreamingContext.js b/main/xiaozhi-server/test/js/StreamingContext.js index 761c06915..690312dd6 100644 --- a/main/xiaozhi-server/test/js/StreamingContext.js +++ b/main/xiaozhi-server/test/js/StreamingContext.js @@ -1,4 +1,4 @@ -import BlockingQueue from './utils/BlockingQueue.js'; +import BlockingQueue from './utils/blockingQueue.js'; import { log } from './utils/logger.js'; // 音频流播放上下文类 diff --git a/main/xiaozhi-server/test/js/document.js b/main/xiaozhi-server/test/js/document.js index 6fb5b222e..0aad77386 100644 --- a/main/xiaozhi-server/test/js/document.js +++ b/main/xiaozhi-server/test/js/document.js @@ -12,19 +12,19 @@ const logContainer = document.getElementById('logContainer'); let visualizerCanvas = document.getElementById('audioVisualizer'); // ota 是否连接成功,修改成对应的样式 -export function otaStatusStyle (flan) { - if(flan){ - document.getElementById('otaStatus').textContent = 'ota已连接'; +export function otaStatusStyle(flan) { + if (flan) { + document.getElementById('otaStatus').textContent = 'OTA已连接'; document.getElementById('otaStatus').style.color = 'green'; - }else{ - document.getElementById('otaStatus').textContent = 'ota未连接'; + } else { + document.getElementById('otaStatus').textContent = 'OTA未连接'; document.getElementById('otaStatus').style.color = 'red'; } } // ota 是否连接成功,修改成对应的样式 -export function getLogContainer (flan) { - return logContainer; +export function getLogContainer(flan) { + return logContainer; } // 更新Opus库状态显示 diff --git a/main/xiaozhi-server/test/js/mcpTools.js b/main/xiaozhi-server/test/js/mcpTools.js new file mode 100644 index 000000000..da11d8153 --- /dev/null +++ b/main/xiaozhi-server/test/js/mcpTools.js @@ -0,0 +1,477 @@ +import { log } from './utils/logger.js'; + +// ========================================== +// MCP 工具管理逻辑 +// ========================================== + +// 全局变量 +let mcpTools = []; +let mcpEditingIndex = null; +let mcpProperties = []; +let websocket = null; // 将从外部设置 + +/** + * 设置 WebSocket 实例 + * @param {WebSocket} ws - WebSocket 连接实例 + */ +export function setWebSocket(ws) { + websocket = ws; +} + +/** + * 初始化 MCP 工具 + */ +export async function initMcpTools() { + // 加载默认工具数据 + const defaultMcpTools = await fetch("js/default-mcp-tools.json").then(res => res.json()); + + const savedTools = localStorage.getItem('mcpTools'); + if (savedTools) { + try { + mcpTools = JSON.parse(savedTools); + } catch (e) { + log('加载MCP工具失败,使用默认工具', 'warning'); + mcpTools = [...defaultMcpTools]; + } + } else { + mcpTools = [...defaultMcpTools]; + } + + renderMcpTools(); + setupMcpEventListeners(); +} + +/** + * 渲染工具列表 + */ +function renderMcpTools() { + const container = document.getElementById('mcpToolsContainer'); + const countSpan = document.getElementById('mcpToolsCount'); + + countSpan.textContent = `${mcpTools.length} 个工具`; + + if (mcpTools.length === 0) { + container.innerHTML = '
暂无工具,点击下方按钮添加新工具
'; + return; + } + + container.innerHTML = mcpTools.map((tool, index) => { + const paramCount = tool.inputSchema.properties ? Object.keys(tool.inputSchema.properties).length : 0; + const requiredCount = tool.inputSchema.required ? tool.inputSchema.required.length : 0; + const hasMockResponse = tool.mockResponse && Object.keys(tool.mockResponse).length > 0; + + return ` +
+
+
${tool.name}
+
+ + +
+
+
${tool.description}
+
+
+ 参数数量: + ${paramCount} 个 ${requiredCount > 0 ? `(${requiredCount} 个必填)` : ''} +
+
+ 模拟返回: + ${hasMockResponse ? '✅ 已配置: ' + JSON.stringify(tool.mockResponse) : '⚪ 使用默认'} +
+
+
+ `; + }).join(''); +} + +/** + * 渲染参数列表 + */ +function renderMcpProperties() { + const container = document.getElementById('mcpPropertiesContainer'); + + if (mcpProperties.length === 0) { + container.innerHTML = '
暂无参数,点击下方按钮添加参数
'; + return; + } + + container.innerHTML = mcpProperties.map((prop, index) => ` +
+
+ ${prop.name} + +
+
+
+ + +
+
+ + +
+
+ ${(prop.type === 'integer' || prop.type === 'number') ? ` +
+
+ + +
+
+ + +
+
+ ` : ''} +
+ + +
+ +
+ `).join(''); +} + +/** + * 添加参数 + */ +function addMcpProperty() { + mcpProperties.push({ + name: `param_${mcpProperties.length + 1}`, + type: 'string', + required: false, + description: '' + }); + renderMcpProperties(); +} + +/** + * 更新参数 + */ +function updateMcpProperty(index, field, value) { + if (field === 'name') { + const isDuplicate = mcpProperties.some((p, i) => i !== index && p.name === value); + if (isDuplicate) { + alert('参数名称已存在,请使用不同的名称'); + renderMcpProperties(); + return; + } + } + + mcpProperties[index][field] = value; + + if (field === 'type' && value !== 'integer' && value !== 'number') { + delete mcpProperties[index].minimum; + delete mcpProperties[index].maximum; + renderMcpProperties(); + } +} + +/** + * 删除参数 + */ +function deleteMcpProperty(index) { + mcpProperties.splice(index, 1); + renderMcpProperties(); +} + +/** + * 设置事件监听 + */ +function setupMcpEventListeners() { + const toggleBtn = document.getElementById('toggleMcpTools'); + const panel = document.getElementById('mcpToolsPanel'); + const addBtn = document.getElementById('addMcpToolBtn'); + const modal = document.getElementById('mcpToolModal'); + const closeBtn = document.getElementById('closeMcpModalBtn'); + const cancelBtn = document.getElementById('cancelMcpBtn'); + const form = document.getElementById('mcpToolForm'); + const addPropertyBtn = document.getElementById('addMcpPropertyBtn'); + + toggleBtn.addEventListener('click', () => { + const isExpanded = panel.classList.contains('expanded'); + panel.classList.toggle('expanded'); + toggleBtn.textContent = isExpanded ? '展开' : '收起'; + }); + + addBtn.addEventListener('click', () => openMcpModal()); + closeBtn.addEventListener('click', closeMcpModal); + cancelBtn.addEventListener('click', closeMcpModal); + addPropertyBtn.addEventListener('click', addMcpProperty); + + modal.addEventListener('click', (e) => { + if (e.target === modal) closeMcpModal(); + }); + + form.addEventListener('submit', handleMcpSubmit); +} + +/** + * 打开模态框 + */ +function openMcpModal(index = null) { + const isConnected = websocket && websocket.readyState === WebSocket.OPEN; + if (isConnected) { + alert('WebSocket 已连接,无法编辑工具'); + return; + } + + mcpEditingIndex = index; + const errorContainer = document.getElementById('mcpErrorContainer'); + errorContainer.innerHTML = ''; + + if (index !== null) { + document.getElementById('mcpModalTitle').textContent = '编辑工具'; + const tool = mcpTools[index]; + document.getElementById('mcpToolName').value = tool.name; + document.getElementById('mcpToolDescription').value = tool.description; + document.getElementById('mcpMockResponse').value = tool.mockResponse ? JSON.stringify(tool.mockResponse, null, 2) : ''; + + mcpProperties = []; + const schema = tool.inputSchema; + if (schema.properties) { + Object.keys(schema.properties).forEach(key => { + const prop = schema.properties[key]; + mcpProperties.push({ + name: key, + type: prop.type || 'string', + minimum: prop.minimum, + maximum: prop.maximum, + description: prop.description || '', + required: schema.required && schema.required.includes(key) + }); + }); + } + } else { + document.getElementById('mcpModalTitle').textContent = '添加工具'; + document.getElementById('mcpToolForm').reset(); + mcpProperties = []; + } + + renderMcpProperties(); + document.getElementById('mcpToolModal').style.display = 'block'; +} + +/** + * 关闭模态框 + */ +function closeMcpModal() { + document.getElementById('mcpToolModal').style.display = 'none'; + mcpEditingIndex = null; + document.getElementById('mcpToolForm').reset(); + mcpProperties = []; + document.getElementById('mcpErrorContainer').innerHTML = ''; +} + +/** + * 处理表单提交 + */ +function handleMcpSubmit(e) { + e.preventDefault(); + const errorContainer = document.getElementById('mcpErrorContainer'); + errorContainer.innerHTML = ''; + + const name = document.getElementById('mcpToolName').value.trim(); + const description = document.getElementById('mcpToolDescription').value.trim(); + const mockResponseText = document.getElementById('mcpMockResponse').value.trim(); + + // 检查名称重复 + const isDuplicate = mcpTools.some((tool, index) => + tool.name === name && index !== mcpEditingIndex + ); + + if (isDuplicate) { + showMcpError('工具名称已存在,请使用不同的名称'); + return; + } + + // 解析模拟返回结果 + let mockResponse = null; + if (mockResponseText) { + try { + mockResponse = JSON.parse(mockResponseText); + } catch (e) { + showMcpError('模拟返回结果不是有效的 JSON 格式: ' + e.message); + return; + } + } + + // 构建 inputSchema + const inputSchema = { + type: "object", + properties: {}, + required: [] + }; + + mcpProperties.forEach(prop => { + const propSchema = { type: prop.type }; + + if (prop.description) { + propSchema.description = prop.description; + } + + if ((prop.type === 'integer' || prop.type === 'number')) { + if (prop.minimum !== undefined && prop.minimum !== '') { + propSchema.minimum = prop.minimum; + } + if (prop.maximum !== undefined && prop.maximum !== '') { + propSchema.maximum = prop.maximum; + } + } + + inputSchema.properties[prop.name] = propSchema; + + if (prop.required) { + inputSchema.required.push(prop.name); + } + }); + + if (inputSchema.required.length === 0) { + delete inputSchema.required; + } + + const tool = { name, description, inputSchema, mockResponse }; + + if (mcpEditingIndex !== null) { + mcpTools[mcpEditingIndex] = tool; + log(`已更新工具: ${name}`, 'success'); + } else { + mcpTools.push(tool); + log(`已添加工具: ${name}`, 'success'); + } + + saveMcpTools(); + renderMcpTools(); + closeMcpModal(); +} + +/** + * 显示错误 + */ +function showMcpError(message) { + const errorContainer = document.getElementById('mcpErrorContainer'); + errorContainer.innerHTML = `
${message}
`; +} + +/** + * 编辑工具 + */ +function editMcpTool(index) { + openMcpModal(index); +} + +/** + * 删除工具 + */ +function deleteMcpTool(index) { + const isConnected = websocket && websocket.readyState === WebSocket.OPEN; + if (isConnected) { + alert('WebSocket 已连接,无法编辑工具'); + return; + } + if (confirm(`确定要删除工具 "${mcpTools[index].name}" 吗?`)) { + const toolName = mcpTools[index].name; + mcpTools.splice(index, 1); + saveMcpTools(); + renderMcpTools(); + log(`已删除工具: ${toolName}`, 'info'); + } +} + +/** + * 保存工具 + */ +function saveMcpTools() { + localStorage.setItem('mcpTools', JSON.stringify(mcpTools)); +} + +/** + * 获取工具列表 + */ +export function getMcpTools() { + return mcpTools.map(tool => ({ + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema + })); +} + +/** + * 执行工具调用 + */ +export function executeMcpTool(toolName, toolArgs) { + const tool = mcpTools.find(t => t.name === toolName); + + if (!tool) { + log(`未找到工具: ${toolName}`, 'error'); + return { + success: false, + error: `未知工具: ${toolName}` + }; + } + + // 如果有模拟返回结果,使用它 + if (tool.mockResponse) { + // 替换模板变量 + let responseStr = JSON.stringify(tool.mockResponse); + + // 替换 ${paramName} 格式的变量 + if (toolArgs) { + Object.keys(toolArgs).forEach(key => { + const regex = new RegExp(`\\$\\{${key}\\}`, 'g'); + responseStr = responseStr.replace(regex, toolArgs[key]); + }); + } + + try { + const response = JSON.parse(responseStr); + log(`工具 ${toolName} 执行成功,返回模拟结果: ${responseStr}`, 'success'); + return response; + } catch (e) { + log(`解析模拟返回结果失败: ${e.message}`, 'error'); + return tool.mockResponse; + } + } + + // 没有模拟返回结果,返回默认成功消息 + log(`工具 ${toolName} 执行成功,返回默认结果`, 'success'); + return { + success: true, + message: `工具 ${toolName} 执行成功`, + tool: toolName, + arguments: toolArgs + }; +} + +// 暴露全局方法供 HTML 内联事件调用 +window.mcpModule = { + updateMcpProperty, + deleteMcpProperty, + editMcpTool, + deleteMcpTool +}; diff --git a/main/xiaozhi-server/test/libopus.js b/main/xiaozhi-server/test/js/utils/libopus.js similarity index 100% rename from main/xiaozhi-server/test/libopus.js rename to main/xiaozhi-server/test/js/utils/libopus.js diff --git a/main/xiaozhi-server/test/opus_test/app.js b/main/xiaozhi-server/test/opus_test/app.js deleted file mode 100644 index 9e56f997b..000000000 --- a/main/xiaozhi-server/test/opus_test/app.js +++ /dev/null @@ -1,670 +0,0 @@ -const SAMPLE_RATE = 16000; -const CHANNELS = 1; -const FRAME_SIZE = 960; // 对应于60ms帧大小 (16000Hz * 0.06s = 960 samples) -const OPUS_APPLICATION = 2049; // OPUS_APPLICATION_AUDIO -const BUFFER_SIZE = 4096; - -let audioContext = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: SAMPLE_RATE }); -let mediaStream, mediaSource, audioProcessor; -let recordedPcmData = []; // 存储原始PCM数据 -let recordedOpusData = []; // 存储Opus编码后的数据 -let opusEncoder, opusDecoder; -let isRecording = false; - -const startButton = document.getElementById("start"); -const stopButton = document.getElementById("stop"); -const playButton = document.getElementById("play"); -const statusLabel = document.getElementById("status"); - -startButton.addEventListener("click", startRecording); -stopButton.addEventListener("click", stopRecording); -playButton.addEventListener("click", playRecording); - -// 初始化Opus编码器与解码器 -async function initOpus() { - if (typeof window.ModuleInstance === 'undefined') { - if (typeof Module !== 'undefined') { - // 尝试使用全局Module - window.ModuleInstance = Module; - console.log('使用全局Module作为ModuleInstance'); - } else { - console.error("Opus库未加载,ModuleInstance和Module对象都不存在"); - return false; - } - } - - try { - const mod = window.ModuleInstance; - - // 创建编码器 - opusEncoder = { - channels: CHANNELS, - sampleRate: SAMPLE_RATE, - frameSize: FRAME_SIZE, - maxPacketSize: 4000, - module: mod, - - // 初始化编码器 - init: function() { - // 获取编码器大小 - const encoderSize = mod._opus_encoder_get_size(this.channels); - console.log(`Opus编码器大小: ${encoderSize}字节`); - - // 分配内存 - this.encoderPtr = mod._malloc(encoderSize); - if (!this.encoderPtr) { - throw new Error("无法分配编码器内存"); - } - - // 初始化编码器 - const err = mod._opus_encoder_init( - this.encoderPtr, - this.sampleRate, - this.channels, - OPUS_APPLICATION - ); - - if (err < 0) { - throw new Error(`Opus编码器初始化失败: ${err}`); - } - - return true; - }, - - // 编码方法 - encode: function(pcmData) { - const mod = this.module; - - // 为PCM数据分配内存 - const pcmPtr = mod._malloc(pcmData.length * 2); // Int16 = 2字节 - - // 将数据复制到WASM内存 - for (let i = 0; i < pcmData.length; i++) { - mod.HEAP16[(pcmPtr >> 1) + i] = pcmData[i]; - } - - // 为Opus编码数据分配内存 - const maxEncodedSize = this.maxPacketSize; - const encodedPtr = mod._malloc(maxEncodedSize); - - // 编码 - const encodedBytes = mod._opus_encode( - this.encoderPtr, - pcmPtr, - this.frameSize, - encodedPtr, - maxEncodedSize - ); - - if (encodedBytes < 0) { - mod._free(pcmPtr); - mod._free(encodedPtr); - throw new Error(`Opus编码失败: ${encodedBytes}`); - } - - // 复制编码后的数据 - const encodedData = new Uint8Array(encodedBytes); - for (let i = 0; i < encodedBytes; i++) { - encodedData[i] = mod.HEAPU8[encodedPtr + i]; - } - - // 释放内存 - mod._free(pcmPtr); - mod._free(encodedPtr); - - return encodedData; - }, - - // 销毁方法 - destroy: function() { - if (this.encoderPtr) { - this.module._free(this.encoderPtr); - this.encoderPtr = null; - } - } - }; - - // 创建解码器 - opusDecoder = { - channels: CHANNELS, - rate: SAMPLE_RATE, - frameSize: FRAME_SIZE, - module: mod, - - // 初始化解码器 - init: function() { - // 获取解码器大小 - const decoderSize = mod._opus_decoder_get_size(this.channels); - console.log(`Opus解码器大小: ${decoderSize}字节`); - - // 分配内存 - this.decoderPtr = mod._malloc(decoderSize); - if (!this.decoderPtr) { - throw new Error("无法分配解码器内存"); - } - - // 初始化解码器 - const err = mod._opus_decoder_init( - this.decoderPtr, - this.rate, - this.channels - ); - - if (err < 0) { - throw new Error(`Opus解码器初始化失败: ${err}`); - } - - return true; - }, - - // 解码方法 - decode: function(opusData) { - const mod = this.module; - - // 为Opus数据分配内存 - const opusPtr = mod._malloc(opusData.length); - mod.HEAPU8.set(opusData, opusPtr); - - // 为PCM输出分配内存 - const pcmPtr = mod._malloc(this.frameSize * 2); // Int16 = 2字节 - - // 解码 - const decodedSamples = mod._opus_decode( - this.decoderPtr, - opusPtr, - opusData.length, - pcmPtr, - this.frameSize, - 0 // 不使用FEC - ); - - if (decodedSamples < 0) { - mod._free(opusPtr); - mod._free(pcmPtr); - throw new Error(`Opus解码失败: ${decodedSamples}`); - } - - // 复制解码后的数据 - const decodedData = new Int16Array(decodedSamples); - for (let i = 0; i < decodedSamples; i++) { - decodedData[i] = mod.HEAP16[(pcmPtr >> 1) + i]; - } - - // 释放内存 - mod._free(opusPtr); - mod._free(pcmPtr); - - return decodedData; - }, - - // 销毁方法 - destroy: function() { - if (this.decoderPtr) { - this.module._free(this.decoderPtr); - this.decoderPtr = null; - } - } - }; - - // 初始化编码器和解码器 - if (opusEncoder.init() && opusDecoder.init()) { - console.log("Opus 编码器和解码器初始化成功。"); - return true; - } else { - console.error("Opus 初始化失败"); - return false; - } - } catch (error) { - console.error("Opus 初始化失败:", error); - return false; - } -} - -// 将Float32音频数据转换为Int16音频数据 -function convertFloat32ToInt16(float32Data) { - const int16Data = new Int16Array(float32Data.length); - for (let i = 0; i < float32Data.length; i++) { - // 将[-1,1]范围转换为[-32768,32767] - const s = Math.max(-1, Math.min(1, float32Data[i])); - int16Data[i] = s < 0 ? s * 0x8000 : s * 0x7FFF; - } - return int16Data; -} - -// 将Int16音频数据转换为Float32音频数据 -function convertInt16ToFloat32(int16Data) { - const float32Data = new Float32Array(int16Data.length); - for (let i = 0; i < int16Data.length; i++) { - // 将[-32768,32767]范围转换为[-1,1] - float32Data[i] = int16Data[i] / (int16Data[i] < 0 ? 0x8000 : 0x7FFF); - } - return float32Data; -} - -function startRecording() { - if (isRecording) return; - - // 确保有权限并且AudioContext是活跃的 - if (audioContext.state === 'suspended') { - audioContext.resume().then(() => { - console.log("AudioContext已恢复"); - continueStartRecording(); - }).catch(err => { - console.error("恢复AudioContext失败:", err); - statusLabel.textContent = "无法激活音频上下文,请再次点击"; - }); - } else { - continueStartRecording(); - } -} - -// 实际开始录音的逻辑 -function continueStartRecording() { - // 重置录音数据 - recordedPcmData = []; - recordedOpusData = []; - window.audioDataBuffer = new Int16Array(0); // 重置缓冲区 - - // 初始化Opus - initOpus().then(success => { - if (!success) { - statusLabel.textContent = "Opus初始化失败"; - return; - } - - console.log("开始录音,参数:", { - sampleRate: SAMPLE_RATE, - channels: CHANNELS, - frameSize: FRAME_SIZE, - bufferSize: BUFFER_SIZE - }); - - // 请求麦克风权限 - navigator.mediaDevices.getUserMedia({ - audio: { - sampleRate: SAMPLE_RATE, - channelCount: CHANNELS, - echoCancellation: true, - noiseSuppression: true, - autoGainControl: true - } - }) - .then(stream => { - console.log("获取到麦克风流,实际参数:", stream.getAudioTracks()[0].getSettings()); - - // 检查流是否有效 - if (!stream || !stream.getAudioTracks().length || !stream.getAudioTracks()[0].enabled) { - throw new Error("获取到的音频流无效"); - } - - mediaStream = stream; - mediaSource = audioContext.createMediaStreamSource(stream); - - // 创建ScriptProcessor(虽然已弃用,但兼容性好) - // 在降级到ScriptProcessor之前尝试使用AudioWorklet - createAudioProcessor().then(processor => { - if (processor) { - console.log("使用AudioWorklet处理音频"); - audioProcessor = processor; - // 连接音频处理链 - mediaSource.connect(audioProcessor); - audioProcessor.connect(audioContext.destination); - } else { - console.log("回退到ScriptProcessor"); - // 创建ScriptProcessor节点 - audioProcessor = audioContext.createScriptProcessor(BUFFER_SIZE, CHANNELS, CHANNELS); - - // 处理音频数据 - audioProcessor.onaudioprocess = processAudioData; - - // 连接音频处理链 - mediaSource.connect(audioProcessor); - audioProcessor.connect(audioContext.destination); - } - - // 更新UI - isRecording = true; - statusLabel.textContent = "录音中..."; - startButton.disabled = true; - stopButton.disabled = false; - playButton.disabled = true; - }).catch(error => { - console.error("创建音频处理器失败:", error); - statusLabel.textContent = "创建音频处理器失败"; - }); - }) - .catch(error => { - console.error("获取麦克风失败:", error); - statusLabel.textContent = "获取麦克风失败: " + error.message; - }); - }); -} - -// 创建AudioWorklet处理器 -async function createAudioProcessor() { - try { - // 尝试使用更现代的AudioWorklet API - if ('AudioWorklet' in window && 'AudioWorkletNode' in window) { - // 定义AudioWorklet处理器代码 - const workletCode = ` - class OpusRecorderProcessor extends AudioWorkletProcessor { - constructor() { - super(); - this.buffers = []; - this.frameSize = ${FRAME_SIZE}; - this.buffer = new Float32Array(this.frameSize); - this.bufferIndex = 0; - this.isRecording = false; - - this.port.onmessage = (event) => { - if (event.data.command === 'start') { - this.isRecording = true; - } else if (event.data.command === 'stop') { - this.isRecording = false; - // 发送最后的缓冲区 - if (this.bufferIndex > 0) { - const finalBuffer = this.buffer.slice(0, this.bufferIndex); - this.port.postMessage({ buffer: finalBuffer }); - } - } - }; - } - - process(inputs, outputs) { - if (!this.isRecording) return true; - - // 获取输入数据 - const input = inputs[0][0]; // mono channel - if (!input || input.length === 0) return true; - - // 将输入数据添加到缓冲区 - for (let i = 0; i < input.length; i++) { - this.buffer[this.bufferIndex++] = input[i]; - - // 当缓冲区填满时,发送给主线程 - if (this.bufferIndex >= this.frameSize) { - this.port.postMessage({ buffer: this.buffer.slice() }); - this.bufferIndex = 0; - } - } - - return true; - } - } - - registerProcessor('opus-recorder-processor', OpusRecorderProcessor); - `; - - // 创建Blob URL - const blob = new Blob([workletCode], { type: 'application/javascript' }); - const url = URL.createObjectURL(blob); - - // 加载AudioWorklet模块 - await audioContext.audioWorklet.addModule(url); - - // 创建AudioWorkletNode - const workletNode = new AudioWorkletNode(audioContext, 'opus-recorder-processor'); - - // 处理从AudioWorklet接收的消息 - workletNode.port.onmessage = (event) => { - if (event.data.buffer) { - // 使用与ScriptProcessor相同的处理逻辑 - processAudioData({ - inputBuffer: { - getChannelData: () => event.data.buffer - } - }); - } - }; - - // 启动录音 - workletNode.port.postMessage({ command: 'start' }); - - // 保存停止函数 - workletNode.stopRecording = () => { - workletNode.port.postMessage({ command: 'stop' }); - }; - - console.log("AudioWorklet 音频处理器创建成功"); - return workletNode; - } - } catch (error) { - console.error("创建AudioWorklet失败,将使用ScriptProcessor:", error); - } - - // 如果AudioWorklet不可用或失败,返回null以便回退到ScriptProcessor - return null; -} - -// 处理音频数据 -function processAudioData(e) { - // 获取输入缓冲区 - const inputBuffer = e.inputBuffer; - - // 获取第一个通道的Float32数据 - const inputData = inputBuffer.getChannelData(0); - - // 添加调试信息 - const nonZeroCount = Array.from(inputData).filter(x => Math.abs(x) > 0.001).length; - console.log(`接收到音频数据: ${inputData.length} 个样本, 非零样本数: ${nonZeroCount}`); - - // 如果全是0,可能是麦克风没有正确获取声音 - if (nonZeroCount < 5) { - console.warn("警告: 检测到大量静音样本,请检查麦克风是否正常工作"); - // 继续处理,以防有些样本确实是静音 - } - - // 存储PCM数据用于调试 - recordedPcmData.push(new Float32Array(inputData)); - - // 转换为Int16数据供Opus编码 - const int16Data = convertFloat32ToInt16(inputData); - - // 如果收集到的数据不是FRAME_SIZE的整数倍,需要进行处理 - // 创建静态缓冲区来存储不足一帧的数据 - if (!window.audioDataBuffer) { - window.audioDataBuffer = new Int16Array(0); - } - - // 合并之前缓存的数据和新数据 - const combinedData = new Int16Array(window.audioDataBuffer.length + int16Data.length); - combinedData.set(window.audioDataBuffer); - combinedData.set(int16Data, window.audioDataBuffer.length); - - // 处理完整帧 - const frameCount = Math.floor(combinedData.length / FRAME_SIZE); - console.log(`可编码的完整帧数: ${frameCount}, 缓冲区总大小: ${combinedData.length}`); - - for (let i = 0; i < frameCount; i++) { - const frameData = combinedData.subarray(i * FRAME_SIZE, (i + 1) * FRAME_SIZE); - - try { - console.log(`编码第 ${i+1}/${frameCount} 帧, 帧大小: ${frameData.length}`); - const encodedData = opusEncoder.encode(frameData); - if (encodedData) { - console.log(`编码成功: ${encodedData.length} 字节`); - recordedOpusData.push(encodedData); - } - } catch (error) { - console.error(`Opus编码帧 ${i+1} 失败:`, error); - } - } - - // 保存剩余不足一帧的数据 - const remainingSamples = combinedData.length % FRAME_SIZE; - if (remainingSamples > 0) { - window.audioDataBuffer = combinedData.subarray(frameCount * FRAME_SIZE); - console.log(`保留 ${remainingSamples} 个样本到下一次处理`); - } else { - window.audioDataBuffer = new Int16Array(0); - } -} - -function stopRecording() { - if (!isRecording) return; - - // 处理剩余的缓冲数据 - if (window.audioDataBuffer && window.audioDataBuffer.length > 0) { - console.log(`停止录音,处理剩余的 ${window.audioDataBuffer.length} 个样本`); - // 如果剩余数据不足一帧,可以通过补零的方式凑成一帧 - if (window.audioDataBuffer.length < FRAME_SIZE) { - const paddedFrame = new Int16Array(FRAME_SIZE); - paddedFrame.set(window.audioDataBuffer); - // 剩余部分填充为0 - for (let i = window.audioDataBuffer.length; i < FRAME_SIZE; i++) { - paddedFrame[i] = 0; - } - try { - console.log(`编码最后一帧(补零): ${paddedFrame.length} 样本`); - const encodedData = opusEncoder.encode(paddedFrame); - if (encodedData) { - recordedOpusData.push(encodedData); - } - } catch (error) { - console.error("最后一帧Opus编码失败:", error); - } - } else { - // 如果数据超过一帧,按正常流程处理 - processAudioData({ - inputBuffer: { - getChannelData: () => convertInt16ToFloat32(window.audioDataBuffer) - } - }); - } - window.audioDataBuffer = null; - } - - // 如果使用的是AudioWorklet,调用其特定的停止方法 - if (audioProcessor && typeof audioProcessor.stopRecording === 'function') { - audioProcessor.stopRecording(); - } - - // 停止麦克风 - if (mediaStream) { - mediaStream.getTracks().forEach(track => track.stop()); - } - - // 断开音频处理链 - if (audioProcessor) { - try { - audioProcessor.disconnect(); - if (mediaSource) mediaSource.disconnect(); - } catch (error) { - console.warn("断开音频处理链时出错:", error); - } - } - - // 更新UI - isRecording = false; - statusLabel.textContent = "已停止录音,收集了 " + recordedOpusData.length + " 帧Opus数据"; - startButton.disabled = false; - stopButton.disabled = true; - playButton.disabled = recordedOpusData.length === 0; - - console.log("录制完成:", - "PCM帧数:", recordedPcmData.length, - "Opus帧数:", recordedOpusData.length); -} - -function playRecording() { - if (!recordedOpusData.length) { - statusLabel.textContent = "没有可播放的录音"; - return; - } - - // 将所有Opus数据解码为PCM - let allDecodedData = []; - - for (const opusData of recordedOpusData) { - try { - // 解码为Int16数据 - const decodedData = opusDecoder.decode(opusData); - - if (decodedData && decodedData.length > 0) { - // 将Int16数据转换为Float32 - const float32Data = convertInt16ToFloat32(decodedData); - - // 添加到总解码数据中 - allDecodedData.push(...float32Data); - } - } catch (error) { - console.error("Opus解码失败:", error); - } - } - - // 如果没有解码出数据,返回 - if (allDecodedData.length === 0) { - statusLabel.textContent = "解码失败,无法播放"; - return; - } - - // 创建音频缓冲区 - const audioBuffer = audioContext.createBuffer(CHANNELS, allDecodedData.length, SAMPLE_RATE); - audioBuffer.copyToChannel(new Float32Array(allDecodedData), 0); - - // 创建音频源并播放 - const source = audioContext.createBufferSource(); - source.buffer = audioBuffer; - source.connect(audioContext.destination); - source.start(); - - // 更新UI - statusLabel.textContent = "正在播放..."; - playButton.disabled = true; - - // 播放结束后恢复UI - source.onended = () => { - statusLabel.textContent = "播放完毕"; - playButton.disabled = false; - }; -} - -// 模拟服务端返回的Opus数据进行解码播放 -function playOpusFromServer(opusData) { - // 这个函数展示如何处理服务端返回的opus数据 - // opusData应该是一个包含opus帧的数组 - - if (!opusDecoder) { - initOpus().then(success => { - if (success) { - decodeAndPlayOpusData(opusData); - } else { - statusLabel.textContent = "Opus解码器初始化失败"; - } - }); - } else { - decodeAndPlayOpusData(opusData); - } -} - -function decodeAndPlayOpusData(opusData) { - let allDecodedData = []; - - for (const frame of opusData) { - try { - const decodedData = opusDecoder.decode(frame); - if (decodedData && decodedData.length > 0) { - const float32Data = convertInt16ToFloat32(decodedData); - allDecodedData.push(...float32Data); - } - } catch (error) { - console.error("服务端Opus数据解码失败:", error); - } - } - - if (allDecodedData.length === 0) { - statusLabel.textContent = "服务端数据解码失败"; - return; - } - - const audioBuffer = audioContext.createBuffer(CHANNELS, allDecodedData.length, SAMPLE_RATE); - audioBuffer.copyToChannel(new Float32Array(allDecodedData), 0); - - const source = audioContext.createBufferSource(); - source.buffer = audioBuffer; - source.connect(audioContext.destination); - source.start(); - - statusLabel.textContent = "正在播放服务端数据..."; - source.onended = () => statusLabel.textContent = "服务端数据播放完毕"; -} diff --git a/main/xiaozhi-server/test/opus_test/test.html b/main/xiaozhi-server/test/opus_test/test.html deleted file mode 100644 index 77d5c73b9..000000000 --- a/main/xiaozhi-server/test/opus_test/test.html +++ /dev/null @@ -1,464 +0,0 @@ - - - - - Opus 编解码测试 - - - -
-

Opus 编解码录音播放测试

- -
正在加载Opus库...
- -
- - -

- - - -

录音状态: 待机,正在初始化...

- -
- -
-
- - - - - - - diff --git a/main/xiaozhi-server/test/test_page.css b/main/xiaozhi-server/test/test_page.css index bea049947..5a97063e1 100644 --- a/main/xiaozhi-server/test/test_page.css +++ b/main/xiaozhi-server/test/test_page.css @@ -1,52 +1,58 @@ body { font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; margin: 0; - padding: 20px; - background-color: #f5f5f5; + padding: 0px; + background-color: #f7f8fb; } .container { - max-width: 1000px; + max-width: 80%; margin: 0 auto; - background-color: white; border-radius: 10px; - box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); - padding: 10px 20px 10px 20px; -} - -h1 { - color: #333; - text-align: center; - margin-bottom: 30px; + padding: 0px; } .section { - margin-bottom: 5px; + margin-top: 10px; + margin-bottom: 10px; padding: 10px; - border-radius: 10px; - background-color: #f9f9f9; + border-radius: 15px; + background-color: #fff; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .section h2 { - margin-top: 0; + margin: 0; color: #444; - font-size: 18px; + font-size: 14px; + font-weight: 600; + letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; - padding: 10px 0; } -.section h2 .toggle-button { +.toggle-button, +.connect-button { margin-left: auto; padding: 4px 12px; - font-size: 12px; - border-radius: 4px; + font-size: 14px; + border-radius: 20px; cursor: pointer; height: 28px; line-height: 20px; } +.toggle-button { + border: 1px solid #007aff; + background-color: #fff; + color: #007aff; +} + +.connect-button { + box-shadow: 0px 0px 10px 2px rgba(0, 122, 255, 0.28); +} + .device-info { display: flex; align-items: center; @@ -70,37 +76,56 @@ h1 { } .config-panel { - display: none; + display: block; transition: all 0.3s ease; - margin-top: 5px; - padding: 5px 0; } -.config-panel.expanded { +/* 只为MCP工具面板设置默认隐藏 */ +#mcpToolsPanel { + display: none; +} + +#mcpToolsPanel.expanded { display: block; } .control-panel { display: flex; - flex-wrap: wrap; + flex-direction: column; gap: 10px; margin-top: 10px; } +.config-row { + display: flex; + gap: 10px; + width: 100%; +} + +.config-item { + flex: 1; + display: flex; + align-items: center; + gap: 10px; + min-width: 0; +} + +.config-item input { + flex: 1; + width: 0; + /* 确保input能自动填充剩余空间 */ +} + button { padding: 8px 15px; border: none; border-radius: 5px; - background-color: #4285f4; + background-color: #007aff; color: white; cursor: pointer; transition: background-color 0.2s; } -button:hover { - background-color: #3367d6; -} - button:disabled { background-color: #cccccc; cursor: not-allowed; @@ -124,53 +149,45 @@ button:disabled { flex-grow: 1; padding: 8px; border: 1px solid #ddd; - border-radius: 5px; + border-radius: 10px; } -#nfcCardId { - flex-grow: 1; - padding: 8px; - border: 1px solid #ddd; - border-radius: 5px; +#sendTextButton, +#recordButton { + border-radius: 20px; } .conversation { max-height: 300px; overflow-y: auto; border: 1px solid #ddd; - border-radius: 5px; + border-right: none; + border-radius: 5px 0px 0px 5px; padding: 10px; - background-color: white; flex: 1; - margin-right: 10px; } .message { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; + width: fit-content; max-width: 80%; } .user { - background-color: #e2f2ff; + background-color: #95ec69; margin-left: auto; margin-right: 10px; text-align: right; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .server { - background-color: #f0f0f0; + background-color: #fff; margin-right: auto; margin-left: 10px; -} - -.status { - color: #666; - font-style: italic; - font-size: 14px; - margin: 0; - padding: 0; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .audio-controls { @@ -218,13 +235,12 @@ button:disabled { #logContainer { margin-top: 0; padding: 10px; - background-color: #f0f0f0; - border-radius: 5px; + border-radius: 0px 5px 5px 0px; font-family: monospace; height: 300px; overflow-y: auto; flex: 1; - margin-left: 10px; + border: 1px solid #ddd; } .log-entry { @@ -322,11 +338,11 @@ button:disabled { } .tab:hover { - color: #4285f4; + color: #007aff; } .tab.active { - color: #4285f4; + color: #007aff; font-weight: bold; } @@ -337,7 +353,7 @@ button:disabled { left: 0; width: 100%; height: 2px; - background-color: #4285f4; + background-color: #007aff; } .tab-content { @@ -350,8 +366,8 @@ button:disabled { .flex-container { display: flex; - gap: 20px; margin-top: 10px; + background-color: #f9fafb; } .config-item { @@ -362,10 +378,11 @@ button:disabled { } .config-item label { - width: 100px; - text-align: right; - margin-right: 10px; + white-space: nowrap; + min-width: 70px; + text-align: left; color: #666; + font-size: 14px; } .config-item input { @@ -375,6 +392,24 @@ button:disabled { border-radius: 5px; } +.config-item input:disabled { + background-color: #f9f9f9; + border-color: #e0e0e0; + cursor: default; +} + +/* 两栏布局样式 */ +.two-column-layout { + display: flex; + gap: 15px; + align-items: stretch; +} + +.two-column-layout>.section { + flex: 1; + margin-bottom: 5px; +} + .control-panel { display: flex; flex-direction: column; @@ -384,17 +419,18 @@ button:disabled { .connection-controls { display: flex; + flex-direction: column; gap: 10px; - align-items: center; width: 100%; + margin-top: 10px; } .connection-controls input { - flex: 1; + width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 5px; - min-width: 200px; + box-sizing: border-box; } .connection-controls button { @@ -408,18 +444,233 @@ button:disabled { gap: 20px; margin-left: 20px; padding: 0 15px; - background-color: #f9f9f9; - border-radius: 4px; height: 28px; line-height: 28px; } .connection-status span { - color: #666; font-size: 13px; } .connection-status .status { + /* 默认未连接状态 */ + background-color: #fef2f2; + color: #b91c1c; + font-size: 12px; + padding: 0px 8px; + border-radius: 20px; + transition: all 0.3s ease; +} + +/* 已连接状态样式 */ +.connection-status .status.connected { + background-color: #ecfdf3; + color: #15803d; +} + +#fileProtocolWarning { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + z-index: 9999; + color: white; + padding: 20px; + box-sizing: border-box; +} + +#fileProtocolWarning h2 { + color: #ff4d4d; + margin-bottom: 20px; +} + +#fileProtocolWarning pre { + background-color: green; + font-size: 18px; + padding: 15px; + border-radius: 5px; + font-family: monospace; + overflow-x: auto; + margin: 15px 0; +} + +#fileProtocolWarning button { + background-color: #4CAF50; + color: white; + border: none; + padding: 10px 20px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + margin: 10px 2px; + cursor: pointer; + border-radius: 4px; +} + +#fileProtocolWarning button:hover { + background-color: #45a049; +} + +/* MCP 工具管理样式 */ +.mcp-tools-container { + display: grid; + gap: 12px; + margin-top: 10px; +} + +.mcp-tool-card { + background-color: white; + border: 1px solid #e0e0e0; + border-radius: 8px; + padding: 15px; + transition: all 0.2s; +} + +.mcp-tool-card:hover { + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +.mcp-tool-card.disabled { + opacity: 0.6; + pointer-events: none; +} + +.mcp-tool-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; +} + +.mcp-tool-name { + font-size: 15px; + font-weight: 600; color: #333; + flex: 1; +} + +.mcp-tool-actions { + display: flex; + gap: 6px; +} + +.mcp-tool-description { + color: #666; + font-size: 13px; + line-height: 1.5; + margin-bottom: 8px; +} + +.mcp-tool-info { + background-color: #f9f9f9; + border: 1px solid #e0e0e0; + border-radius: 4px; + padding: 8px; + font-size: 12px; +} + +.mcp-tool-info-row { + display: flex; + gap: 15px; + margin-bottom: 4px; +} + +.mcp-tool-info-label { + color: #999; + min-width: 60px; +} + +.mcp-tool-info-value { + color: #333; + font-family: 'Courier New', monospace; +} + +.mcp-property-item { + background-color: white; + border: 1px solid #e0e0e0; + border-radius: 5px; + padding: 12px; + margin-bottom: 10px; +} + +.mcp-property-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; +} + +.mcp-property-name { + font-weight: 600; + color: #333; +} + +.mcp-property-row { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 10px; + margin-bottom: 8px; +} + +.mcp-property-row-full { + margin-bottom: 8px; +} + +.mcp-small-label { + display: block; + margin-bottom: 4px; + font-size: 12px; + color: #666; +} + +.mcp-small-input { + width: 100%; + padding: 6px 8px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 13px; +} + +.mcp-checkbox-label { + display: flex; + align-items: center; + gap: 6px; + font-size: 13px; + color: #666; + cursor: pointer; +} + +.mcp-error { + background-color: #ffebee; + color: #c62828; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; + font-size: 14px; +} + +.mcp-badge { + display: inline-block; + padding: 2px 8px; + border-radius: 12px; + font-size: 11px; font-weight: 500; + margin-left: 8px; +} + +.mcp-badge-required { + background-color: #ffebee; + color: #c62828; +} + +.mcp-badge-optional { + background-color: #e3f2fd; + color: #1976d2; } \ No newline at end of file diff --git a/main/xiaozhi-server/test/test_page.html b/main/xiaozhi-server/test/test_page.html index 88f182c46..dff8b1397 100644 --- a/main/xiaozhi-server/test/test_page.html +++ b/main/xiaozhi-server/test/test_page.html @@ -6,214 +6,6 @@ 小智服务器测试页面 - + From 5dda2f731a07a28ffdf2352d8b21ac4220908fb3 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 16 Nov 2025 01:34:23 +0800 Subject: [PATCH 11/40] =?UTF-8?q?update:=E7=BB=9F=E4=B8=80js=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=A7=B0=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/js/{mcpTools.js => mcp-tools.js} | 0 .../test/js/{StreamingContext.js => streaming-context.js} | 2 +- .../test/js/utils/{BlockingQueue.js => blocking-queue.js} | 0 .../test/js/{xiaoZhiConnect.js => xiaozhi-connect.js} | 0 main/xiaozhi-server/test/test_page.html | 8 ++++---- 5 files changed, 5 insertions(+), 5 deletions(-) rename main/xiaozhi-server/test/js/{mcpTools.js => mcp-tools.js} (100%) rename main/xiaozhi-server/test/js/{StreamingContext.js => streaming-context.js} (99%) rename main/xiaozhi-server/test/js/utils/{BlockingQueue.js => blocking-queue.js} (100%) rename main/xiaozhi-server/test/js/{xiaoZhiConnect.js => xiaozhi-connect.js} (100%) diff --git a/main/xiaozhi-server/test/js/mcpTools.js b/main/xiaozhi-server/test/js/mcp-tools.js similarity index 100% rename from main/xiaozhi-server/test/js/mcpTools.js rename to main/xiaozhi-server/test/js/mcp-tools.js diff --git a/main/xiaozhi-server/test/js/StreamingContext.js b/main/xiaozhi-server/test/js/streaming-context.js similarity index 99% rename from main/xiaozhi-server/test/js/StreamingContext.js rename to main/xiaozhi-server/test/js/streaming-context.js index 690312dd6..198269e95 100644 --- a/main/xiaozhi-server/test/js/StreamingContext.js +++ b/main/xiaozhi-server/test/js/streaming-context.js @@ -1,4 +1,4 @@ -import BlockingQueue from './utils/blockingQueue.js'; +import BlockingQueue from './utils/blocking-queue.js'; import { log } from './utils/logger.js'; // 音频流播放上下文类 diff --git a/main/xiaozhi-server/test/js/utils/BlockingQueue.js b/main/xiaozhi-server/test/js/utils/blocking-queue.js similarity index 100% rename from main/xiaozhi-server/test/js/utils/BlockingQueue.js rename to main/xiaozhi-server/test/js/utils/blocking-queue.js diff --git a/main/xiaozhi-server/test/js/xiaoZhiConnect.js b/main/xiaozhi-server/test/js/xiaozhi-connect.js similarity index 100% rename from main/xiaozhi-server/test/js/xiaoZhiConnect.js rename to main/xiaozhi-server/test/js/xiaozhi-connect.js diff --git a/main/xiaozhi-server/test/test_page.html b/main/xiaozhi-server/test/test_page.html index dff8b1397..96f72e84d 100644 --- a/main/xiaozhi-server/test/test_page.html +++ b/main/xiaozhi-server/test/test_page.html @@ -219,12 +219,12 @@ - + + \ No newline at end of file From 3fe1acd15336857343f985c0b6f2db7e3cc1973f Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 16 Nov 2025 14:08:43 +0800 Subject: [PATCH 14/40] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BB=A3=E7=A0=81=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/css/test_page.css | 756 ++++++++++----------- 1 file changed, 374 insertions(+), 382 deletions(-) diff --git a/main/xiaozhi-server/test/css/test_page.css b/main/xiaozhi-server/test/css/test_page.css index 82ac36077..1642ae2d9 100644 --- a/main/xiaozhi-server/test/css/test_page.css +++ b/main/xiaozhi-server/test/css/test_page.css @@ -1,3 +1,4 @@ +/* ==================== 全局样式 ==================== */ * { box-sizing: border-box; } @@ -9,6 +10,7 @@ body { background-image: url('bg.png'); } +/* ==================== 容器布局 ==================== */ .container { max-width: 1400px; margin: 0 auto; @@ -16,29 +18,23 @@ body { padding: 0px; } -/* 大屏幕 (宽度 > 1200px) */ -@media (min-width: 1201px) { - .container { - max-width: 80%; - } +/* 两栏布局 */ +.two-column-layout { + display: flex; + gap: 20px; + align-items: stretch; + margin-top: 10px; + margin-bottom: 10px; } -/* 中等屏幕 (宽度 <= 1200px) */ -@media (max-width: 1200px) { - .container { - max-width: 95%; - padding: 10px; - } -} - -/* 响应式布局 - 移动设备 */ -@media (max-width: 768px) { - .container { - max-width: 100%; - padding: 5px; - } +.two-column-layout>.section { + flex: 1; + margin-top: 0; + margin-bottom: 0; + min-width: 0; } +/* ==================== 通用区块样式 ==================== */ .section { margin-top: 10px; margin-bottom: 10px; @@ -59,6 +55,23 @@ body { gap: 10px; } +/* ==================== 通用按钮样式 ==================== */ +button { + padding: 8px 15px; + border: none; + border-radius: 5px; + background-color: #007aff; + color: white; + cursor: pointer; + transition: background-color 0.2s; +} + +button:disabled { + background-color: #cccccc; + cursor: not-allowed; +} + +/* 切换按钮和连接按钮 */ .toggle-button, .connect-button { margin-left: auto; @@ -80,12 +93,13 @@ body { box-shadow: 0px 0px 10px 2px rgba(0, 122, 255, 0.28); } +/* ==================== 设备配置面板 ==================== */ .config-panel { display: block; transition: all 0.3s ease; } -/* 只为MCP工具面板设置默认隐藏 */ +/* MCP工具面板默认隐藏 */ #mcpToolsPanel { display: none; } @@ -101,39 +115,75 @@ body { margin-top: 10px; } +/* 配置行 */ .config-row { display: flex; gap: 10px; width: 100%; } +/* 配置项 */ .config-item { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; + margin-bottom: 8px; + width: 100%; +} + +.config-item label { + white-space: nowrap; + min-width: 70px; + text-align: left; + color: #666; + font-size: 12px; } .config-item input { flex: 1; width: 0; - /* 确保input能自动填充剩余空间 */ -} - -button { - padding: 8px 15px; - border: none; + flex-grow: 1; + padding: 6px; + font-size: 12px; + border: 1px solid #b1c9f8; border-radius: 5px; - background-color: #007aff; - color: white; - cursor: pointer; - transition: background-color 0.2s; } -button:disabled { - background-color: #cccccc; - cursor: not-allowed; +.config-item input:disabled { + background-color: #fff; + border-color: #fff; + cursor: default; +} + +/* ==================== 连接信息面板 ==================== */ +.connection-controls { + display: flex; + flex-direction: column; + gap: 10px; + width: 100%; + margin-top: 10px; +} + +.connection-controls input { + width: 100%; + padding: 8px; + border: 1px solid #ddd; + border-radius: 5px; + box-sizing: border-box; +} + +.connection-controls button { + white-space: nowrap; + padding: 8px 15px; +} + +#serverUrl, +#otaUrl { + flex-grow: 1; + padding: 8px; + border-radius: 5px; } #otaUrl { @@ -145,63 +195,67 @@ button:disabled { background-color: #fafafa; } -#serverUrl, -#otaUrl { - flex-grow: 1; - padding: 8px; - border-radius: 5px; -} - -.message-input { +/* 连接状态 */ +.connection-status { display: flex; - gap: 10px; - margin-bottom: 20px; + align-items: center; + gap: 20px; + margin-left: 0px; + padding: 0 15px; + height: 28px; + line-height: 28px; } -#messageInput { - flex-grow: 1; - padding: 8px 20px 8px 20px; - border: 1px solid #b1c9f8; - border-radius: 10px; +.connection-status span { + font-size: 13px; } -#messageInput:disabled { - border: 1px solid #fafafa; - background-color: #fafafa; -} - -#sendTextButton, -#recordButton { +.connection-status .status { + background-color: #fef2f2; + color: #b91c1c; + font-size: 12px; + padding: 0px 8px; border-radius: 20px; + transition: all 0.3s ease; } -.conversation { - max-height: 300px; - overflow-y: auto; - border: 1px solid #ddd; - border-right: none; - border-radius: 5px 0px 0px 5px; - padding: 10px; - flex: 1; +/* 已连接状态 */ +.connection-status .status.connected { + background-color: #ecfdf3; + color: #15803d; } -.message { - margin-bottom: 10px; - padding: 8px 12px; - border-radius: 8px; - width: fit-content; - max-width: 80%; +/* 会话状态 - 离线中 */ +.connection-status .status.offline { + background-color: #fef2f2; + color: #b91c1c; } -.user { - background-color: #fff; - margin-left: auto; - margin-right: 10px; - text-align: right; - box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); +/* 会话状态 - 聆听中 */ +.connection-status .status.listening { + background-color: #ecfdf3; + color: #15803d; } +/* 会话状态 - 说话中 */ +.connection-status .status.speaking { + background-color: #fff7ed; + color: #c2410c; + animation: pulse-speaking 1.5s infinite; +} +@keyframes pulse-speaking { + 0%, + 100% { + opacity: 1; + } + + 50% { + opacity: 0.7; + } +} + +/* LLM状态emoji样式 */ span.connection-status.llm-emoji { display: block !important; text-align: center !important; @@ -214,131 +268,14 @@ span.connection-status.llm-emoji { padding: 8px 20px !important; } -.server { - background-color: #95ec69; - margin-right: auto; - margin-left: 10px; - box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); -} - -.audio-controls { - display: flex; - justify-content: center; - gap: 10px; - margin-top: 20px; -} - -.audio-visualizer { - height: 60px; - width: 100%; - margin-top: 10px; - border: 1px solid #ddd; - border-radius: 5px; - background-color: #fafafa; -} - -.record-button { - background-color: #db4437; -} - -.record-button:hover { - background-color: #c53929; -} - -.record-button.recording { - animation: pulse 1.5s infinite; -} - -@keyframes pulse { - 0% { - background-color: #db4437; - } - - 50% { - background-color: #ff6659; - } - - 100% { - background-color: #db4437; - } -} - -#logContainer { - margin-top: 0; - padding: 10px; - border-radius: 0px 5px 5px 0px; - font-family: monospace; - height: 300px; - overflow-y: auto; - flex: 1; - border: 1px solid #ddd; -} - -.log-entry { - margin: 5px 0; - font-size: 12px; -} - -.log-info { - color: #333; -} - -.log-error { - color: #db4437; -} - -.log-success { - color: #0f9d58; -} - -.script-status { +.emoji-large { + font-size: 2em !important; + vertical-align: middle; display: inline-block; - width: 10px; - height: 10px; - border-radius: 50%; - margin-right: 5px; + line-height: 1; } -.script-loaded { - background-color: #0f9d58; -} - -.script-loading { - background-color: #f4b400; -} - -.script-error { - background-color: #db4437; -} - -.script-list { - margin: 10px 0; - padding: 10px; - background-color: #f9f9f9; - border-radius: 5px; - font-family: monospace; - font-size: 11px; -} - -#scriptStatus.success { - background-color: #e6f4ea; - color: #0f9d58; - border-left: 4px solid #0f9d58; -} - -#scriptStatus.error { - background-color: #fce8e6; - color: #db4437; - border-left: 4px solid #db4437; -} - -#scriptStatus.warning { - background-color: #fef7e0; - color: #f4b400; - border-left: 4px solid #f4b400; -} - -/* 标签页样式 */ +/* ==================== 标签页样式 ==================== */ .tabs { display: flex; margin-bottom: 20px; @@ -384,208 +321,145 @@ span.connection-status.llm-emoji { display: block; } +/* ==================== 文本消息输入 ==================== */ +.message-input { + display: flex; + gap: 10px; + margin-bottom: 20px; +} + +#messageInput { + flex-grow: 1; + padding: 8px 20px 8px 20px; + border: 1px solid #b1c9f8; + border-radius: 10px; +} + +#messageInput:disabled { + border: 1px solid #fafafa; + background-color: #fafafa; +} + +#sendTextButton, +#recordButton { + border-radius: 20px; +} + +/* ==================== 语音消息控制 ==================== */ +.audio-controls { + display: flex; + justify-content: center; + gap: 10px; + margin-top: 20px; +} + +.audio-visualizer { + height: 60px; + width: 100%; + margin-top: 10px; + border: 1px solid #ddd; + border-radius: 5px; + background-color: #fafafa; +} + +.record-button { + background-color: #db4437; +} + +.record-button:hover { + background-color: #c53929; +} + +.record-button.recording { + animation: pulse 1.5s infinite; +} + +@keyframes pulse { + 0% { + background-color: #db4437; + } + + 50% { + background-color: #ff6659; + } + + 100% { + background-color: #db4437; + } +} + +/* ==================== 会话记录和日志 ==================== */ .flex-container { display: flex; margin-top: 10px; background-color: #f9fafb; } -.config-item { - display: flex; - align-items: center; - margin-bottom: 8px; - width: 100%; -} - -.config-item label { - white-space: nowrap; - min-width: 70px; - text-align: left; - color: #666; - font-size: 12px; -} - -.config-item input { - flex-grow: 1; - padding: 6px; - font-size: 12px; - border: 1px solid #b1c9f8; - border-radius: 5px; -} - -.config-item input:disabled { - background-color: #fff; - border-color: #fff; - cursor: default; -} - -/* 两栏布局样式 */ -.two-column-layout { - display: flex; - gap: 20px; - /* 两栏之间的间距 */ - align-items: stretch; - margin-top: 10px; - margin-bottom: 10px; -} - -.two-column-layout>.section { - flex: 1; - margin-top: 0; - /* 在两栏布局时不需要额外的上下margin */ - margin-bottom: 0; - min-width: 0; - /* 防止flex子元素溢出 */ -} - -.control-panel { - display: flex; - flex-direction: column; - gap: 10px; - margin-top: 10px; -} - -.connection-controls { - display: flex; - flex-direction: column; - gap: 10px; - width: 100%; - margin-top: 10px; -} - -.connection-controls input { - width: 100%; - padding: 8px; +/* 会话记录容器 */ +.conversation { + max-height: 300px; + overflow-y: auto; border: 1px solid #ddd; - border-radius: 5px; - box-sizing: border-box; + border-right: none; + border-radius: 5px 0px 0px 5px; + padding: 10px; + flex: 1; } -.connection-controls button { - white-space: nowrap; - padding: 8px 15px; +/* 消息气泡 */ +.message { + margin-bottom: 10px; + padding: 8px 12px; + border-radius: 8px; + width: fit-content; + max-width: 80%; } -.connection-status { - display: flex; - align-items: center; - gap: 20px; - margin-left: 0px; - padding: 0 15px; - height: 28px; - line-height: 28px; +.user { + background-color: #fff; + margin-left: auto; + margin-right: 10px; + text-align: right; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } -.connection-status span { - font-size: 13px; +.server { + background-color: #95ec69; + margin-right: auto; + margin-left: 10px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } -.connection-status .status { - /* 默认未连接状态 */ - background-color: #fef2f2; - color: #b91c1c; - font-size: 12px; - padding: 0px 8px; - border-radius: 20px; - transition: all 0.3s ease; -} - -/* 已连接状态样式 */ -.connection-status .status.connected { - background-color: #ecfdf3; - color: #15803d; -} - -/* 会话状态样式 - 离线中 */ -.connection-status .status.offline { - background-color: #fef2f2; - color: #b91c1c; -} - -/* 会话状态样式 - 聆听中 */ -.connection-status .status.listening { - background-color: #ecfdf3; - color: #15803d; -} - -/* 会话状态样式 - 说话中 */ -.connection-status .status.speaking { - background-color: #fff7ed; - color: #c2410c; - animation: pulse-speaking 1.5s infinite; -} - -@keyframes pulse-speaking { - - 0%, - 100% { - opacity: 1; - } - - 50% { - opacity: 0.7; - } -} - -/* 表情符号放大样式 */ -.emoji-large { - font-size: 2em !important; - vertical-align: middle; - display: inline-block; - line-height: 1; -} - -#fileProtocolWarning { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.8); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - z-index: 9999; - color: white; - padding: 20px; - box-sizing: border-box; -} - -#fileProtocolWarning h2 { - color: #ff4d4d; - margin-bottom: 20px; -} - -#fileProtocolWarning pre { - background-color: green; - font-size: 18px; - padding: 15px; - border-radius: 5px; +/* 日志容器 */ +#logContainer { + margin-top: 0; + padding: 10px; + border-radius: 0px 5px 5px 0px; font-family: monospace; - overflow-x: auto; - margin: 15px 0; + height: 300px; + overflow-y: auto; + flex: 1; + border: 1px solid #ddd; } -#fileProtocolWarning button { - background-color: #4CAF50; - color: white; - border: none; - padding: 10px 20px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - margin: 10px 2px; - cursor: pointer; - border-radius: 4px; +.log-entry { + margin: 5px 0; + font-size: 12px; } -#fileProtocolWarning button:hover { - background-color: #45a049; +.log-info { + color: #333; } -/* MCP 工具管理样式 */ +.log-error { + color: #db4437; +} + +.log-success { + color: #0f9d58; +} + +/* ==================== MCP 工具管理 ==================== */ .mcp-tools-container { display: grid; gap: 12px; @@ -659,6 +533,7 @@ span.connection-status.llm-emoji { font-family: 'Courier New', monospace; } +/* MCP 属性项 */ .mcp-property-item { background-color: white; border: 1px solid #e0e0e0; @@ -742,7 +617,121 @@ span.connection-status.llm-emoji { color: #1976d2; } -/* ==================== 响应式媒体查询 ==================== */ +/* ==================== 脚本加载状态 ==================== */ +.script-status { + display: inline-block; + width: 10px; + height: 10px; + border-radius: 50%; + margin-right: 5px; +} + +.script-loaded { + background-color: #0f9d58; +} + +.script-loading { + background-color: #f4b400; +} + +.script-error { + background-color: #db4437; +} + +.script-list { + margin: 10px 0; + padding: 10px; + background-color: #f9f9f9; + border-radius: 5px; + font-family: monospace; + font-size: 11px; +} + +#scriptStatus.success { + background-color: #e6f4ea; + color: #0f9d58; + border-left: 4px solid #0f9d58; +} + +#scriptStatus.error { + background-color: #fce8e6; + color: #db4437; + border-left: 4px solid #db4437; +} + +#scriptStatus.warning { + background-color: #fef7e0; + color: #f4b400; + border-left: 4px solid #f4b400; +} + +/* ==================== File协议警告 ==================== */ +#fileProtocolWarning { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + z-index: 9999; + color: white; + padding: 20px; + box-sizing: border-box; +} + +#fileProtocolWarning h2 { + color: #ff4d4d; + margin-bottom: 20px; +} + +#fileProtocolWarning pre { + background-color: green; + font-size: 18px; + padding: 15px; + border-radius: 5px; + font-family: monospace; + overflow-x: auto; + margin: 15px 0; +} + +#fileProtocolWarning button { + background-color: #4CAF50; + color: white; + border: none; + padding: 10px 20px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + margin: 10px 2px; + cursor: pointer; + border-radius: 4px; +} + +#fileProtocolWarning button:hover { + background-color: #45a049; +} + +/* ==================== 响应式布局 ==================== */ + +/* 大屏幕 (宽度 > 1200px) */ +@media (min-width: 1201px) { + .container { + max-width: 80%; + } +} + +/* 中等屏幕 (宽度 <= 1200px) */ +@media (max-width: 1200px) { + .container { + max-width: 95%; + padding: 10px; + } +} /* 平板设备 (宽度 <= 1060px) */ @media (max-width: 1060px) { @@ -751,13 +740,11 @@ span.connection-status.llm-emoji { .two-column-layout { flex-direction: column; gap: 0; - /* 移除gap,使用section自己的margin控制间距 */ } .two-column-layout>.section { width: 100%; margin-top: 10px; - /* 恢复正常的margin */ margin-bottom: 10px; } @@ -797,6 +784,11 @@ span.connection-status.llm-emoji { padding: 0; } + .container { + max-width: 100%; + padding: 5px; + } + /* 调整区块内边距 */ .section { padding: 8px; @@ -826,12 +818,12 @@ span.connection-status.llm-emoji { line-height: 18px; } - /* 输入框和按钮 */ button { padding: 6px 12px; font-size: 13px; } + /* 输入框 */ #serverUrl, #otaUrl, #messageInput { @@ -1001,4 +993,4 @@ span.connection-status.llm-emoji { .mcp-tool-description { font-size: 11px; } -} \ No newline at end of file +} From e37618423d501c5f70b3cdf07f887c6e89953ed7 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 16 Nov 2025 14:39:53 +0800 Subject: [PATCH 15/40] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=A1=B5=E9=9D=A2=E9=9F=B3=E6=B3=A2=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/css/test_page.css | 4 +++- main/xiaozhi-server/test/js/ui/controller.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/test/css/test_page.css b/main/xiaozhi-server/test/css/test_page.css index 1642ae2d9..c05641918 100644 --- a/main/xiaozhi-server/test/css/test_page.css +++ b/main/xiaozhi-server/test/css/test_page.css @@ -245,6 +245,7 @@ button:disabled { } @keyframes pulse-speaking { + 0%, 100% { opacity: 1; @@ -357,6 +358,7 @@ span.connection-status.llm-emoji { height: 60px; width: 100%; margin-top: 10px; + margin-bottom: 15px; border: 1px solid #ddd; border-radius: 5px; background-color: #fafafa; @@ -993,4 +995,4 @@ span.connection-status.llm-emoji { .mcp-tool-description { font-size: 11px; } -} +} \ No newline at end of file diff --git a/main/xiaozhi-server/test/js/ui/controller.js b/main/xiaozhi-server/test/js/ui/controller.js index dd58555b6..8fc9dd317 100644 --- a/main/xiaozhi-server/test/js/ui/controller.js +++ b/main/xiaozhi-server/test/js/ui/controller.js @@ -126,7 +126,12 @@ export class UIController { for (let i = 0; i < dataArray.length; i++) { barHeight = dataArray[i] / 2; - this.visualizerContext.fillStyle = `rgb(${barHeight + 100}, 50, 50)`; + // 创建渐变色:从紫色到蓝色到青色 + const hue = 200 + (barHeight / this.visualizerCanvas.height) * 60; // 200-260度,从青色到紫色 + const saturation = 80 + (barHeight / this.visualizerCanvas.height) * 20; // 饱和度 80-100% + const lightness = 45 + (barHeight / this.visualizerCanvas.height) * 15; // 亮度 45-60% + + this.visualizerContext.fillStyle = `hsl(${hue}, ${saturation}%, ${lightness}%)`; this.visualizerContext.fillRect(x, this.visualizerCanvas.height - barHeight, barWidth, barHeight); x += barWidth + 1; From c6527d7df93b6e67f0655af6871826dbe52511fa Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 16 Nov 2025 17:18:49 +0800 Subject: [PATCH 16/40] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/i18n/messages.properties | 30 ++++++------- .../resources/i18n/messages_zh_CN.properties | 30 ++++++------- .../i18n/validation_de_DE.properties | 2 +- .../i18n/validation_zh_CN.properties | 14 +++--- main/manager-mobile/src/i18n/de.ts | 2 +- main/manager-mobile/src/i18n/vi.ts | 2 +- main/manager-mobile/src/i18n/zh_TW.ts | 8 +--- main/manager-web/src/i18n/de.js | 23 +++++----- main/manager-web/src/i18n/en.js | 9 ++-- main/manager-web/src/i18n/vi.js | 43 +++++++++---------- main/manager-web/src/i18n/zh_CN.js | 7 ++- main/manager-web/src/i18n/zh_TW.js | 3 +- 12 files changed, 82 insertions(+), 91 deletions(-) diff --git a/main/manager-api/src/main/resources/i18n/messages.properties b/main/manager-api/src/main/resources/i18n/messages.properties index 6cdd8d1e8..81164dc26 100644 --- a/main/manager-api/src/main/resources/i18n/messages.properties +++ b/main/manager-api/src/main/resources/i18n/messages.properties @@ -160,11 +160,11 @@ 10151=\u8BF7\u5148\u4E0A\u4F20\u97F3\u9891\u6587\u4EF6 10152=\u6A21\u578B\u914D\u7F6E\u672A\u627E\u5230 10153=\u6A21\u578B\u7C7B\u578B\u672A\u627E\u5230 -10154=\u8BAD\u7EC3\u5931\u8D25 +10154=\u8BAD\u7EC3\u5931\u8D25: {0} 10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E 10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u514b\u9686\u97f3\u8272: +10158=\u514B\u9686\u97F3\u8272: 10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 @@ -173,20 +173,20 @@ 10164=RAG\u914D\u7F6E\u672A\u627E\u5230 10165=RAG\u914D\u7F6E\u7C7B\u578B\u9519\u8BEF 10166=\u9ED8\u8BA4RAG\u914D\u7F6E\u672A\u627E\u5230 -10167=\u0052\u0041\u0047\u8c03\u7528\u5931\u8d25\uFF0C{0} +10167=RAG\u8C03\u7528\u5931\u8D25\uFF0C{0} 10168=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25 10169=\u60A8\u6CA1\u6709\u6743\u9650\u64CD\u4F5C\u8BE5\u8BB0\u5F55 10170=\u77E5\u8BC6\u5E93\u540D\u79F0\u91CD\u590D -10171=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A -10172=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A -10173=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 -10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 +10171=RAG\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A +10172=RAG\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A +10173=RAG\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 +10174=RAG\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 10175=mac\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10176=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A -10177=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A -10178=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A -10179=\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a -10180=\u6587\u4ef6\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a -10181=\u97f3\u8272\u514b\u9686\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a -10182=\u97f3\u8272\u514b\u9686\u97f3\u9891\u4e0d\u5b58\u5728 -10183=\u9ed8\u8ba4\u667a\u80fd\u4f53\u672a\u627e\u5230 \ No newline at end of file +10176=RAG\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A +10177=RAG\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A +10178=RAG\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A +10179=\u6587\u4EF6\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A +10180=\u6587\u4EF6\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A +10181=\u97F3\u8272\u514B\u9686\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A +10182=\u97F3\u8272\u514B\u9686\u97F3\u9891\u4E0D\u5B58\u5728 +10183=\u9ED8\u8BA4\u667A\u80FD\u4F53\u672A\u627E\u5230 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties b/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties index 6cdd8d1e8..81164dc26 100644 --- a/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties +++ b/main/manager-api/src/main/resources/i18n/messages_zh_CN.properties @@ -160,11 +160,11 @@ 10151=\u8BF7\u5148\u4E0A\u4F20\u97F3\u9891\u6587\u4EF6 10152=\u6A21\u578B\u914D\u7F6E\u672A\u627E\u5230 10153=\u6A21\u578B\u7C7B\u578B\u672A\u627E\u5230 -10154=\u8BAD\u7EC3\u5931\u8D25 +10154=\u8BAD\u7EC3\u5931\u8D25: {0} 10155=\u706B\u5C71\u5F15\u64CE\u7F3A\u5C11\u914D\u7F6E 10156=\u54CD\u5E94\u683C\u5F0F\u9519\u8BEF\uFF0C\u7F3A\u5C11BaseResp\u5B57\u6BB5 10157=\u8BF7\u6C42\u5931\u8D25 -10158=\u514b\u9686\u97f3\u8272: +10158=\u514B\u9686\u97F3\u8272: 10159=\u97F3\u8272ID\u5DF2\u5B58\u5728 10160=\u706B\u5C71\u5F15\u64CE\u97F3\u8272ID\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5S_\u5F00\u5934 10161=Mac\u5730\u5740\u5DF2\u5B58\u5728 @@ -173,20 +173,20 @@ 10164=RAG\u914D\u7F6E\u672A\u627E\u5230 10165=RAG\u914D\u7F6E\u7C7B\u578B\u9519\u8BEF 10166=\u9ED8\u8BA4RAG\u914D\u7F6E\u672A\u627E\u5230 -10167=\u0052\u0041\u0047\u8c03\u7528\u5931\u8d25\uFF0C{0} +10167=RAG\u8C03\u7528\u5931\u8D25\uFF0C{0} 10168=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25 10169=\u60A8\u6CA1\u6709\u6743\u9650\u64CD\u4F5C\u8BE5\u8BB0\u5F55 10170=\u77E5\u8BC6\u5E93\u540D\u79F0\u91CD\u590D -10171=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A -10172=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A -10173=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 -10174=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 +10171=RAG\u914D\u7F6E\u4F53\u7684base_url\u4E0D\u80FD\u4E3A\u7A7A +10172=RAG\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A +10173=RAG\u914D\u7F6E\u4F53\u7684api_key\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u66F4\u6362\u4E3A\u5728\u53D6\u7684API\u53C2\u6570 +10174=RAG\u914D\u7F6E\u4F53\u7684base_url\u683C\u5F0F\u9519\u8BEF\uFF0C\u5FC5\u987B\u4EE5http\u6216https\u5F00\u5934 10175=mac\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A -10176=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A -10177=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A -10178=\u0052\u0041\u0047\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A -10179=\u6587\u4ef6\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a -10180=\u6587\u4ef6\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a -10181=\u97f3\u8272\u514b\u9686\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a -10182=\u97f3\u8272\u514b\u9686\u97f3\u9891\u4e0d\u5b58\u5728 -10183=\u9ed8\u8ba4\u667a\u80fd\u4f53\u672a\u627e\u5230 \ No newline at end of file +10176=RAG\u914D\u7F6E\u4F53\u7684dataset_id\u4E0D\u80FD\u4E3A\u7A7A +10177=RAG\u914D\u7F6E\u4F53\u7684model_id\u4E0D\u80FD\u4E3A\u7A7A +10178=RAG\u914D\u7F6E\u4F53\u7684dataset_id\u548Cmodel_id\u4E0D\u80FD\u4E3A\u7A7A +10179=\u6587\u4EF6\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A +10180=\u6587\u4EF6\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A +10181=\u97F3\u8272\u514B\u9686\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A +10182=\u97F3\u8272\u514B\u9686\u97F3\u9891\u4E0D\u5B58\u5728 +10183=\u9ED8\u8BA4\u667A\u80FD\u4F53\u672A\u627E\u5230 \ No newline at end of file diff --git a/main/manager-api/src/main/resources/i18n/validation_de_DE.properties b/main/manager-api/src/main/resources/i18n/validation_de_DE.properties index 219230191..d3b4ce51a 100644 --- a/main/manager-api/src/main/resources/i18n/validation_de_DE.properties +++ b/main/manager-api/src/main/resources/i18n/validation_de_DE.properties @@ -31,4 +31,4 @@ timbre.ttsModelId.require=Die TTS-Modell-ID des Klangs darf nicht leer sein timbre.ttsVoice.require=Die TTS-Stimme des Klangs darf nicht leer sein ota.device.not.found=Gerät nicht gefunden -ota.device.need.bind={0} muss gebunden werden +ota.device.need.bind={0} diff --git a/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties b/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties index eaa50eb77..786004299 100644 --- a/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties +++ b/main/manager-api/src/main/resources/i18n/validation_zh_CN.properties @@ -3,8 +3,8 @@ id.require=ID\u4E0D\u80FD\u4E3A\u7A7A id.null=ID\u5FC5\u987B\u4E3A\u7A7A sort.number=\u6392\u5E8F\u503C\u4E0D\u80FD\u5C0F\u4E8E0 -page.number=\u9801\u6578\u4E0D\u80FD\u5C0F\u4E8E0 -limit.number=\u5217\u6578\u4E0D\u80FD\u5C0F\u4E8E0 +page.number=\u9875\u6570\u4E0D\u80FD\u5C0F\u4E8E0 +limit.number=\u5217\u6570\u4E0D\u80FD\u5C0F\u4E8E0 sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A @@ -25,10 +25,10 @@ sysuser.status.range=\u72B6\u6001\u53D6\u503C\u8303\u56F40~1 sysuser.captcha.require=\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A sysuser.uuid.require=\u552F\u4E00\u6807\u8BC6\u4E0D\u80FD\u4E3A\u7A7A -timbre.languages.require=\u97F3\u8272\u7684\u8A9E\u8A00\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.name.require=\u97F3\u8272\u7684\u540D\u7A31\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.ttsModelId.require=\u97F3\u8272\u7684tts\u4E3B\u9375\u4E0D\u53EF\u4EE5\u70BA\u7A7A -timbre.ttsVoice.require=\u97F3\u8272\u7684\u7DE8\u78BC\u4E0D\u53EF\u4EE5\u70BA\u7A7A +timbre.languages.require=\u97F3\u8272\u7684\u8BED\u8A00\u4E0D\u80FD\u4E3A\u7A7A +timbre.name.require=\u97F3\u8272\u7684\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A +timbre.ttsModelId.require=\u97F3\u8272\u7684tts\u4E3B\u952E\u4E0D\u80FD\u4E3A\u7A7A +timbre.ttsVoice.require=\u97F3\u8272\u7684\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A -ota.device.not.found=\u8A2D\u5099\u672A\u627E\u5230 +ota.device.not.found=\u8BBE\u5907\u672A\u627E\u5230 ota.device.need.bind={0} \ No newline at end of file diff --git a/main/manager-mobile/src/i18n/de.ts b/main/manager-mobile/src/i18n/de.ts index 83ad8e317..42076940b 100644 --- a/main/manager-mobile/src/i18n/de.ts +++ b/main/manager-mobile/src/i18n/de.ts @@ -130,7 +130,7 @@ export default { 'chatHistory.loading': 'Lädt...', 'chatHistory.noMoreData': 'Keine weiteren Daten', 'chatHistory.noChatRecords': 'Keine Chat-Aufzeichnungen', - 'chatRecordsDescription': 'Konversationsaufzeichnungen mit Agenten werden hier angezeigt', + 'chatHistory.chatRecordsDescription': 'Konversationsaufzeichnungen mit Agenten werden hier angezeigt', // Chat-Verlauf Detailseite 'chatHistory.pageTitle': 'Chat-Details', 'chatHistory.assistantName': 'Intelligenter Assistent', diff --git a/main/manager-mobile/src/i18n/vi.ts b/main/manager-mobile/src/i18n/vi.ts index ec3747694..5a68513d2 100644 --- a/main/manager-mobile/src/i18n/vi.ts +++ b/main/manager-mobile/src/i18n/vi.ts @@ -130,7 +130,7 @@ export default { 'chatHistory.loading': 'Đang tải...', 'chatHistory.noMoreData': 'Không còn dữ liệu', 'chatHistory.noChatRecords': 'Không có bản ghi trò chuyện', - 'chatRecordsDescription': 'Bản ghi trò chuyện với đại lý sẽ hiển thị ở đây', + 'chatHistory.chatRecordsDescription': 'Bản ghi trò chuyện với đại lý sẽ hiển thị ở đây', // Trang chi tiết lịch sử trò chuyện 'chatHistory.pageTitle': 'Chi tiết trò chuyện', 'chatHistory.assistantName': 'Trợ lý thông minh', diff --git a/main/manager-mobile/src/i18n/zh_TW.ts b/main/manager-mobile/src/i18n/zh_TW.ts index 4873f5362..53fb324d1 100644 --- a/main/manager-mobile/src/i18n/zh_TW.ts +++ b/main/manager-mobile/src/i18n/zh_TW.ts @@ -46,13 +46,9 @@ export default { 'retrievePassword.mobileCaptchaPlaceholder': '請輸入手機驗證碼', 'retrievePassword.newPasswordPlaceholder': '請輸入新密碼', 'retrievePassword.confirmNewPasswordPlaceholder': '請確認新密碼', - 'retrievePassword.confirmPasswordPlaceholder': '請確認新密碼', - 'retrievePassword.captchaSendSuccess': '驗證碼發送成功', - 'retrievePassword.passwordUpdateSuccess': '密碼更新成功', - 'retrievePassword.getCaptcha': '獲取驗證碼', 'retrievePassword.getMobileCaptcha': '獲取驗證碼', - 'retrievePassword.resend': '重新發送', - 'retrievePassword.resetPasswordButton': '重置密碼', + 'retrievePassword.captchaSendSuccess': '驗證碼發送成功', + 'retrievePassword.passwordUpdateSuccess': '密碼重置成功', 'retrievePassword.resetButton': '重置密碼', 'retrievePassword.goToLogin': '返回登錄', diff --git a/main/manager-web/src/i18n/de.js b/main/manager-web/src/i18n/de.js index 4f0f419a1..f9dc8eff9 100644 --- a/main/manager-web/src/i18n/de.js +++ b/main/manager-web/src/i18n/de.js @@ -644,11 +644,11 @@ export default { // Home page text 'home.addAgent': 'Agent hinzufügen', - 'home.greeting': 'Hallo Jarvis', + 'home.greeting': 'Hallo XiaoZhi', 'home.wish': 'Lassen Sie uns einen wunderbaren Tag haben!', 'home.languageModel': 'LLM', 'home.voiceModel': 'TTS', - 'home.configureRole': 'Rollen konfig.', + 'home.configureRole': 'Rolle konf.', 'home.voiceprintRecognition': 'Stimmabdruck', 'home.deviceManagement': 'Geräte', 'home.chatHistory': 'Chat-Verlauf', @@ -732,14 +732,14 @@ export default { 'roleConfig.roleIntroduction': 'Einführung', 'roleConfig.languageCode': 'Sprachcode', 'roleConfig.interactionLanguage': 'Interaktionssprache', - 'roleConfig.vad': ' Sprach-Erkenn. ', - 'roleConfig.asr': 'Sprach-Erkenn.', - 'roleConfig.llm': 'Sprach-Mod.', - 'roleConfig.vllm': 'Vision-Modell', - 'roleConfig.tts': 'Text-zu-Sprache', + 'roleConfig.vad': 'VAD', + 'roleConfig.asr': 'ASR', + 'roleConfig.llm': 'LLM', + 'roleConfig.vllm': 'VLLM', + 'roleConfig.tts': 'TTS', 'roleConfig.memoryHis': 'Speicher', - 'roleConfig.memory': 'Speicher-Mod.', - 'roleConfig.intent': 'Absichts-Erkenn.', + 'roleConfig.memory': 'Speicher', + 'roleConfig.intent': 'Intent', 'roleConfig.voiceType': 'Stimmtyp', 'roleConfig.pleaseEnterContent': 'Bitte Inhalt eingeben', 'roleConfig.pleaseEnterLangCode': 'Bitte Sprachcode eingeben, z.B.: en_US', @@ -1013,7 +1013,6 @@ export default { 'agentTemplateManagement.deleteFailed': 'Vorlagenlöschung fehlgeschlagen', 'agentTemplateManagement.batchDeleteFailed': 'Vorlagen-Massenlöschung fehlgeschlagen', 'agentTemplateManagement.deleteBackendError': 'Löschen fehlgeschlagen, bitte prüfen Sie, ob der Backend-Service normal ist', - 'agentTemplateManagement.deleteCancelled': 'Löschen abgebrochen', // templateQuickConfig 'templateQuickConfig.title': 'Modul-Schnellkonfiguration', @@ -1023,8 +1022,8 @@ export default { 'templateQuickConfig.agentSettings.systemPromptPlaceholder': 'Bitte Einführung eingeben', 'templateQuickConfig.saveConfig': 'Konfiguration speichern', 'templateQuickConfig.resetConfig': 'Konfiguration zurücksetzen', - 'templateQuickConfig.configSaved': 'Konfiguration erfolgreich gespeichert', - 'templateQuickConfig.configReset': 'Konfiguration wurde zurückgesetzt', + 'templateQuickConfig.saveSuccess': 'Speichern erfolgreich', + 'templateQuickConfig.resetSuccess': 'Zurücksetzen erfolgreich', 'templateQuickConfig.confirmReset': 'Sind Sie sicher, dass Sie die Konfiguration zurücksetzen möchten?', 'templateQuickConfig.saveFailed': 'Konfigurationsspeicherung fehlgeschlagen', 'templateQuickConfig.confirm': 'Bestätigen', diff --git a/main/manager-web/src/i18n/en.js b/main/manager-web/src/i18n/en.js index 56394ec42..e9b9f74dd 100644 --- a/main/manager-web/src/i18n/en.js +++ b/main/manager-web/src/i18n/en.js @@ -644,7 +644,7 @@ export default { // Home page text 'home.addAgent': 'Add Agent', - 'home.greeting': 'Hi Jarvis', + 'home.greeting': 'Hi XiaoZhi', 'home.wish': "Let's have a wonderful day!", 'home.languageModel': 'LLM', 'home.voiceModel': 'TTS', @@ -994,7 +994,6 @@ export default { 'agentTemplateManagement.templateName': 'Template Name', 'agentTemplateManagement.action': 'Action', 'agentTemplateManagement.createTemplate': 'Create Template', - 'templateQuickConfig.newTemplate': 'New Template', 'agentTemplateManagement.editTemplate': 'Edit Template', 'agentTemplateManagement.deleteTemplate': 'Delete Template', 'agentTemplateManagement.deleteSuccess': 'Template deleted successfully', @@ -1013,7 +1012,6 @@ export default { 'agentTemplateManagement.deleteFailed': 'Template deletion failed', 'agentTemplateManagement.batchDeleteFailed': 'Template batch deletion failed', 'agentTemplateManagement.deleteBackendError': 'Deletion failed, please check if the backend service is normal', - 'agentTemplateManagement.deleteCancelled': 'Deletion cancelled', // templateQuickConfig 'templateQuickConfig.title': 'Module Quick Configuration', @@ -1023,13 +1021,14 @@ export default { 'templateQuickConfig.agentSettings.systemPromptPlaceholder': 'Please enter ntroduction', 'templateQuickConfig.saveConfig': 'Save Configuration', 'templateQuickConfig.resetConfig': 'Reset Configuration', - 'templateQuickConfig.configSaved': 'Configuration saved successfully', - 'templateQuickConfig.configReset': 'Configuration has been reset', + 'templateQuickConfig.saveSuccess': 'Configuration saved successfully', + 'templateQuickConfig.resetSuccess': 'Configuration reset successfully', 'templateQuickConfig.confirmReset': 'Are you sure you want to reset the configuration?', 'templateQuickConfig.saveFailed': 'Configuration save failed', 'templateQuickConfig.confirm': 'Confirm', 'templateQuickConfig.cancel': 'Cancel', 'templateQuickConfig.templateNotFound': 'Template not found', + 'templateQuickConfig.newTemplate': 'New Template', 'warning': 'Warning', 'info': 'Info', 'common.networkError': 'Network request failed', diff --git a/main/manager-web/src/i18n/vi.js b/main/manager-web/src/i18n/vi.js index 19c5967c0..dec2fd059 100644 --- a/main/manager-web/src/i18n/vi.js +++ b/main/manager-web/src/i18n/vi.js @@ -7,14 +7,14 @@ export default { 'login.loginSuccess': 'Đăng nhập thành công!', // HeaderBar component text - 'header.smartManagement': 'Đại lý', + 'header.smartManagement': 'Tác nhân AI', 'header.modelConfig': 'Mô hình', 'header.knowledgeBase': 'Kiến thức', - 'header.voiceCloneManagement': 'Cloning', + 'header.voiceCloneManagement': 'Nhân bản giọng', 'header.voiceResourceManagement': 'Tài nguyên giọng nói', 'header.userManagement': 'Người dùng', 'header.otaManagement': 'Quản lý OTA', - 'header.paramDictionary': 'Thêm', + 'header.paramDictionary': 'Khác', 'header.paramManagement': 'Quản lý tham số', 'header.dictManagement': 'Quản lý từ điển', 'header.agentTemplate': 'Mẫu vai trò mặc định', @@ -643,8 +643,8 @@ export default { 'language.vi': 'Tiếng Việt', // Home page text - 'home.addAgent': 'Thêm đại lý', - 'home.greeting': 'Xin chào Jarvis', + 'home.addAgent': 'Thêm tác nhân', + 'home.greeting': 'Xin chào XiaoZhi', 'home.wish': 'Chúc bạn một ngày tuyệt vời!', 'home.languageModel': 'LLM', 'home.voiceModel': 'TTS', @@ -657,7 +657,7 @@ export default { 'home.justNow': 'Vừa xong', 'home.minutesAgo': '{minutes} phút trước', 'home.hoursAgo': '{hours} giờ {minutes} phút trước', - 'home.confirmDeleteAgent': 'Bạn có chắc chắn muốn xóa đại lý này?', + 'home.confirmDeleteAgent': 'Bạn có chắc chắn muốn xóa tác nhân này?', 'home.deleteSuccess': 'Xóa thành công', 'home.deleteFailed': 'Xóa thất bại', 'home.enableMemory': 'Vui lòng bật bộ nhớ trong trang \"Cấu hình vai trò\" trước', @@ -714,12 +714,12 @@ export default { 'serverSideManager.updateConfigSuccess': 'Cập nhật cấu hình thành công', // Add agent dialog text - 'addAgentDialog.title': 'Thêm đại lý', - 'addAgentDialog.agentName': 'Tên đại lý', - 'addAgentDialog.placeholder': 'Vui lòng nhập tên đại lý..', + 'addAgentDialog.title': 'Thêm tác nhân', + 'addAgentDialog.agentName': 'Tên tác nhân', + 'addAgentDialog.placeholder': 'Vui lòng nhập tên tác nhân..', 'addAgentDialog.confirm': 'Xác nhận', 'addAgentDialog.cancel': 'Hủy bỏ', - 'addAgentDialog.nameRequired': 'Vui lòng nhập tên đại lý', + 'addAgentDialog.nameRequired': 'Vui lòng nhập tên tác nhân', 'addAgentDialog.addSuccess': 'Thêm thành công', // Role configuration page text @@ -770,7 +770,7 @@ export default { 'functionDialog.noNeedToConfig': ' không yêu cầu cấu hình tham số', 'functionDialog.pleaseSelectFunctionForParam': 'Vui lòng chọn một chức năng đã cấu hình để thiết lập tham số', 'functionDialog.mcpAccessPoint': 'Điểm truy cập MCP', - 'functionDialog.mcpAddressDesc': 'Dưới đây là các địa chỉ điểm truy cập MCP cho đại lý.', + 'functionDialog.mcpAddressDesc': 'Dưới đây là các địa chỉ điểm truy cập MCP cho tác nhân.', 'functionDialog.howToDeployMcp': 'Cách triển khai điểm truy cập MCP', 'functionDialog.howToIntegrateMcp': 'Cách tích hợp chức năng MCP', 'functionDialog.copy': 'Sao chép', @@ -1013,7 +1013,6 @@ export default { 'agentTemplateManagement.deleteFailed': 'Xóa mẫu thất bại', 'agentTemplateManagement.batchDeleteFailed': 'Xóa hàng loạt mẫu thất bại', 'agentTemplateManagement.deleteBackendError': 'Xóa thất bại, vui lòng kiểm tra xem dịch vụ backend có bình thường không', - 'agentTemplateManagement.deleteCancelled': 'Đã hủy xóa', // templateQuickConfig 'templateQuickConfig.title': 'Cấu hình nhanh mô-đun', @@ -1023,8 +1022,8 @@ export default { 'templateQuickConfig.agentSettings.systemPromptPlaceholder': 'Vui lòng nhập giới thiệu', 'templateQuickConfig.saveConfig': 'Lưu cấu hình', 'templateQuickConfig.resetConfig': 'Đặt lại cấu hình', - 'templateQuickConfig.configSaved': 'Đã lưu cấu hình thành công', - 'templateQuickConfig.configReset': 'Cấu hình đã được đặt lại', + 'templateQuickConfig.saveSuccess': 'Lưu thành công', + 'templateQuickConfig.resetSuccess': 'Đặt lại thành công', 'templateQuickConfig.confirmReset': 'Bạn có chắc chắn muốn đặt lại cấu hình?', 'templateQuickConfig.saveFailed': 'Lưu cấu hình thất bại', 'templateQuickConfig.confirm': 'Xác nhận', @@ -1044,13 +1043,13 @@ export default { 'sm2.publicKeyRetryFailed': 'Thử lấy lại khóa công khai thất bại', // Voice Clone and Resource Management - 'voiceClone.title': 'Cloning giọng', + 'voiceClone.title': 'Nhân bản giọng nói', 'voiceResource.title': 'Tài nguyên giọng nói', 'voiceClone.platformName': 'Tên nền tảng', 'voiceClone.voiceId': 'ID giọng nói', 'voiceClone.userId': 'Chủ sở hữu tài khoản', 'voiceClone.name': 'Tên giọng nói', - 'voiceClone.clone': 'Cloning giọng', + 'voiceClone.clone': 'Nhân bản', 'voiceClone.action': 'Hành động', 'voiceClone.modelId': 'ID mô hình', 'voiceClone.trainStatus': 'Trạng thái đào tạo', @@ -1075,8 +1074,8 @@ export default { 'voiceClone.operationClosed': 'Đã đóng popup', 'voiceClone.cloneSuccess': 'Nhân bản thành công', 'voiceClone.cloneFailed': 'Nhân bản thất bại', - 'voiceClone.confirmClone': 'Bạn có chắc chắn muốn nhân bản giọng nói này?', - 'voiceClone.onlySuccessCanClone': 'Chỉ những giọng nói đã được đào tạo thành công mới có thể được nhân bản', + 'voiceClone.confirmClone': 'Bạn có chắc chắn muốn nhân bản giọng này?', + 'voiceClone.onlySuccessCanClone': 'Chỉ có thể nhân bản giọng đã huấn luyện thành công', 'common.insufficient': 'Không đủ', 'voiceClone.platformNameRequired': 'Vui lòng chọn tên nền tảng', 'voiceClone.voiceIdRequired': 'Vui lòng chọn ID giọng nói', @@ -1086,9 +1085,9 @@ export default { 'voiceClone.userIdPlaceholder': 'Vui lòng nhập từ khóa để chọn chủ sở hữu tài khoản', 'voiceClone.waitingUpload': 'Đang chờ tải lên', 'voiceClone.waitingTraining': 'Đang chờ nhân bản', - 'voiceClone.training': 'Đang đào tạo', - 'voiceClone.trainSuccess': 'Đào tạo thành công', - 'voiceClone.trainFailed': 'Đào tạo thất bại', + 'voiceClone.training': 'Đang huấn luyện', + 'voiceClone.trainSuccess': 'Huấn luyện thành công', + 'voiceClone.trainFailed': 'Huấn luyện thất bại', 'voiceClone.itemsPerPage': '{items} mục mỗi trang', 'voiceClone.firstPage': 'Trang đầu', 'voiceClone.prevPage': 'Trang trước', @@ -1096,7 +1095,7 @@ export default { 'voiceClone.totalRecords': 'Tổng cộng {total} bản ghi', 'voiceClone.noVoiceCloneAssigned': 'Tài khoản của bạn không được chỉ định tài nguyên giọng nói', 'voiceClone.contactAdmin': 'Vui lòng liên hệ quản trị viên để được chỉ định tài nguyên giọng nói', - 'voiceClone.dialogTitle': 'Cloning giọng', + 'voiceClone.dialogTitle': 'Nhân bản giọng nói', 'voiceClone.stepUpload': 'Chuẩn bị âm thanh', 'voiceClone.stepEdit': 'Chỉnh sửa âm thanh', 'voiceClone.dragOrClick': 'Kéo tệp âm thanh vào đây hoặc nhấp để tải lên', diff --git a/main/manager-web/src/i18n/zh_CN.js b/main/manager-web/src/i18n/zh_CN.js index 63434c426..221136a29 100644 --- a/main/manager-web/src/i18n/zh_CN.js +++ b/main/manager-web/src/i18n/zh_CN.js @@ -993,8 +993,6 @@ export default { 'agentTemplateManagement.title': '默认角色管理', 'agentTemplateManagement.templateName': '模板名称', 'agentTemplateManagement.action': '操作', - 'templateQuickConfig.saveSuccess': '配置保存成功', - 'templateQuickConfig.saveFailed': '配置保存失败', 'agentTemplateManagement.createTemplate': '创建模板', 'agentTemplateManagement.editTemplate': '编辑模板', 'agentTemplateManagement.deleteTemplate': '删除模板', @@ -1023,13 +1021,14 @@ export default { 'templateQuickConfig.agentSettings.systemPromptPlaceholder': '请输入角色介绍', 'templateQuickConfig.saveConfig': '保存配置', 'templateQuickConfig.resetConfig': '重置配置', + 'templateQuickConfig.saveSuccess': '保存成功', + 'templateQuickConfig.resetSuccess': '重置成功', 'templateQuickConfig.confirmReset': '确定要重置配置吗?', + 'templateQuickConfig.saveFailed': '配置保存失败', 'templateQuickConfig.confirm': '确定', 'templateQuickConfig.cancel': '取消', 'templateQuickConfig.templateNotFound': '未找到指定模板', 'templateQuickConfig.newTemplate': '新模板', - 'templateQuickConfig.saveSuccess': '保存成功', - 'templateQuickConfig.resetSuccess': '重置成功', 'warning': '警告', 'info': '提示', 'common.networkError': '网络请求失败', diff --git a/main/manager-web/src/i18n/zh_TW.js b/main/manager-web/src/i18n/zh_TW.js index 02134a877..70c475272 100644 --- a/main/manager-web/src/i18n/zh_TW.js +++ b/main/manager-web/src/i18n/zh_TW.js @@ -994,6 +994,7 @@ export default { 'agentTemplateManagement.templateName': '模板名稱', 'agentTemplateManagement.action': '操作', 'templateQuickConfig.saveSuccess': '配置保存成功', + 'templateQuickConfig.resetSuccess': '配置重置成功', 'templateQuickConfig.saveFailed': '配置保存失敗', 'agentTemplateManagement.createTemplate': '建立模板', 'agentTemplateManagement.editTemplate': '編輯模板', @@ -1023,8 +1024,6 @@ export default { 'templateQuickConfig.agentSettings.systemPromptPlaceholder': '請輸入角色介紹', 'templateQuickConfig.saveConfig': '保存配置', 'templateQuickConfig.resetConfig': '重置配置', - 'templateQuickConfig.configSaved': '配置保存成功', - 'templateQuickConfig.configReset': '配置已重置', 'templateQuickConfig.confirmReset': '確定要重置配置嗎?', 'templateQuickConfig.confirm': '確定', 'templateQuickConfig.cancel': '取消', From 6c325f68aca0645b332999baeef803bea028ee7b Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 16 Nov 2025 17:40:39 +0800 Subject: [PATCH 17/40] =?UTF-8?q?fix:=E7=BD=91=E9=A1=B5=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=92=8Cmanager-web=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/js/config/manager.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/main/xiaozhi-server/test/js/config/manager.js b/main/xiaozhi-server/test/js/config/manager.js index 95eac7b92..71c1120b3 100644 --- a/main/xiaozhi-server/test/js/config/manager.js +++ b/main/xiaozhi-server/test/js/config/manager.js @@ -1,5 +1,4 @@ // 配置管理模块 -import { log } from '../utils/logger.js'; // 生成随机MAC地址 function generateRandomMac() { @@ -23,30 +22,30 @@ export function loadConfig() { const otaUrlInput = document.getElementById('otaUrl'); // 从localStorage加载MAC地址,如果没有则生成新的 - let savedMac = localStorage.getItem('deviceMac'); + let savedMac = localStorage.getItem('xz_tester_deviceMac'); if (!savedMac) { savedMac = generateRandomMac(); - localStorage.setItem('deviceMac', savedMac); + localStorage.setItem('xz_tester_deviceMac', savedMac); } deviceMacInput.value = savedMac; // 从localStorage加载其他配置 - const savedDeviceName = localStorage.getItem('deviceName'); + const savedDeviceName = localStorage.getItem('xz_tester_deviceName'); if (savedDeviceName) { deviceNameInput.value = savedDeviceName; } - const savedClientId = localStorage.getItem('clientId'); + const savedClientId = localStorage.getItem('xz_tester_clientId'); if (savedClientId) { clientIdInput.value = savedClientId; } - const savedToken = localStorage.getItem('token'); + const savedToken = localStorage.getItem('xz_tester_token'); if (savedToken) { tokenInput.value = savedToken; } - const savedOtaUrl = localStorage.getItem('otaUrl'); + const savedOtaUrl = localStorage.getItem('xz_tester_otaUrl'); if (savedOtaUrl) { otaUrlInput.value = savedOtaUrl; } @@ -59,10 +58,10 @@ export function saveConfig() { const clientIdInput = document.getElementById('clientId'); const tokenInput = document.getElementById('token'); - localStorage.setItem('deviceMac', deviceMacInput.value); - localStorage.setItem('deviceName', deviceNameInput.value); - localStorage.setItem('clientId', clientIdInput.value); - localStorage.setItem('token', tokenInput.value); + localStorage.setItem('xz_tester_deviceMac', deviceMacInput.value); + localStorage.setItem('xz_tester_deviceName', deviceNameInput.value); + localStorage.setItem('xz_tester_clientId', clientIdInput.value); + localStorage.setItem('xz_tester_token', tokenInput.value); } // 获取配置值 @@ -81,6 +80,6 @@ export function getConfig() { export function saveConnectionUrls() { const otaUrl = document.getElementById('otaUrl').value.trim(); const wsUrl = document.getElementById('serverUrl').value.trim(); - localStorage.setItem('otaUrl', otaUrl); - localStorage.setItem('wsUrl', wsUrl); + localStorage.setItem('xz_tester_otaUrl', otaUrl); + localStorage.setItem('xz_tester_wsUrl', wsUrl); } From fa194af9bbca49678960d1a6a2a448089f81e2cd Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Mon, 17 Nov 2025 10:15:53 +0800 Subject: [PATCH 18/40] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/views/roleConfig.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue index d3369c4fb..0693b5835 100644 --- a/main/manager-web/src/views/roleConfig.vue +++ b/main/manager-web/src/views/roleConfig.vue @@ -705,10 +705,10 @@ export default { // 检查是否有音频预览 hasAudioPreview(item) { // 检查item中是否包含有效的音频URL字段或克隆音频字段 - // 克隆音频通过hasCloneAudio标志或特定格式的ID来判断 + // 克隆音频通过hasCloneAudio标志或ID格式判断(非TTS开头的ID) const isCloneAudio = item.hasCloneAudio || - (item.id && item.id.startsWith("e") && item.id.length === 14); + (item.value && !item.value.startsWith("TTS")); const audioFields = [ item.voiceDemo, @@ -789,13 +789,10 @@ export default { let isCloneAudio = false; if (voiceDetail) { - // 首先检查是否是克隆音频(通过train_status字段、hasCloneAudio标志或ID格式判断) + // 首先检查是否是克隆音频(通过ID格式判断,非TTS开头的ID) isCloneAudio = - (voiceDetail.train_status !== undefined && voiceDetail.train_status >= 0) || voiceDetail.hasCloneAudio || - (voiceDetail.id && - voiceDetail.id.startsWith("e") && - voiceDetail.id.length === 14); + (voiceDetail.id && !voiceDetail.id.startsWith("TTS")); console.log("克隆音频判断结果:", isCloneAudio, "训练状态:", voiceDetail.train_status); // 获取音频URL @@ -816,8 +813,11 @@ export default { .method("POST") .success((res) => { if (res.code === 0 && res.data) { + // 处理返回的数据格式,在res.data基础上再套一层.data + const audioId = res.data.data; + console.log("获取到的音频ID:", audioId); // 使用返回的UUID构建播放URL - const playUrl = `${getServiceUrl()}/voiceClone/play/${res.data}`; + const playUrl = `${getServiceUrl()}/voiceClone/play/${audioId}`; console.log("构建克隆音频播放URL:", playUrl); resolve(playUrl); } else { From 9a3e1fa9c88bf3304ca5eba7748d2b5aeba8a1a1 Mon Sep 17 00:00:00 2001 From: LiJinHui <166460433+stu-rgsze@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:39:11 +0800 Subject: [PATCH 19/40] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/views/roleConfig.vue | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/manager-web/src/views/roleConfig.vue b/main/manager-web/src/views/roleConfig.vue index 0693b5835..7782e66db 100644 --- a/main/manager-web/src/views/roleConfig.vue +++ b/main/manager-web/src/views/roleConfig.vue @@ -707,8 +707,7 @@ export default { // 检查item中是否包含有效的音频URL字段或克隆音频字段 // 克隆音频通过hasCloneAudio标志或ID格式判断(非TTS开头的ID) const isCloneAudio = - item.hasCloneAudio || - (item.value && !item.value.startsWith("TTS")); + item.hasCloneAudio || (item.value && !item.value.startsWith("TTS")); const audioFields = [ item.voiceDemo, @@ -793,7 +792,12 @@ export default { isCloneAudio = voiceDetail.hasCloneAudio || (voiceDetail.id && !voiceDetail.id.startsWith("TTS")); - console.log("克隆音频判断结果:", isCloneAudio, "训练状态:", voiceDetail.train_status); + console.log( + "克隆音频判断结果:", + isCloneAudio, + "训练状态:", + voiceDetail.train_status + ); // 获取音频URL if (isCloneAudio && voiceDetail.id) { @@ -812,7 +816,7 @@ export default { .url(`${getServiceUrl()}/voiceClone/audio/${voiceDetail.id}`) .method("POST") .success((res) => { - if (res.code === 0 && res.data) { + if (res.data.code === 0 && res.data.data) { // 处理返回的数据格式,在res.data基础上再套一层.data const audioId = res.data.data; console.log("获取到的音频ID:", audioId); @@ -825,7 +829,7 @@ export default { resolve(null); } }) - .error((err) => { + .networkFail((err) => { console.error("请求音频ID接口失败:", err); resolve(null); }) From 146a039c19bf917be1c820e9c793e1759b393c39 Mon Sep 17 00:00:00 2001 From: rainv123 <2148537152@qq.com> Date: Mon, 17 Nov 2025 11:53:30 +0800 Subject: [PATCH 20/40] =?UTF-8?q?fix:=E7=BF=BB=E8=AF=91=E5=8F=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/i18n/de.js | 14 +++++++------- main/manager-web/src/i18n/vi.js | 2 +- .../manager-web/src/views/VoiceCloneManagement.vue | 2 +- main/manager-web/src/views/auth.scss | 6 ++++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/main/manager-web/src/i18n/de.js b/main/manager-web/src/i18n/de.js index f9dc8eff9..f5281e15b 100644 --- a/main/manager-web/src/i18n/de.js +++ b/main/manager-web/src/i18n/de.js @@ -169,7 +169,7 @@ export default { // Dictionary type dialog related 'dictTypeDialog.addDictType': 'Wörterbuchtyp hinzufügen', - 'dictTypeDialog.dictName': 'Wörterbuchtyp-Name', + 'dictTypeDialog.dictName': 'WWörterbuchtyp-Name', 'dictTypeDialog.dictNamePlaceholder': 'Bitte Wörterbuchtyp-Namen eingeben', 'dictTypeDialog.dictType': 'Wörterbuchtyp-Code', 'dictTypeDialog.dictTypePlaceholder': 'Bitte Wörterbuchtyp-Code eingeben', @@ -523,7 +523,7 @@ export default { 'dictManagement.pageTitle': 'Wörterbuchverwaltung', 'dictManagement.searchPlaceholder': 'Bitte Wörterbuchwert-Label zur Suche eingeben', 'dictManagement.search': 'Suchen', - 'dictManagement.dictTypeName': 'Wörterbuchtyp-Name', + 'dictManagement.dictTypeName': 'WDT-Name', 'dictManagement.operation': 'Operation', 'dictManagement.edit': 'Bearbeiten', 'dictManagement.dictLabel': 'Wörterbuch-Label', @@ -532,10 +532,10 @@ export default { 'dictManagement.delete': 'Löschen', 'dictManagement.selectAll': 'Alle auswählen', 'dictManagement.deselectAll': 'Alle abwählen', - 'dictManagement.addDictType': 'Wörterbuchtyp hinzufügen', - 'dictManagement.batchDeleteDictType': 'Wörterbuchtypen massenhaft löschen', - 'dictManagement.addDictData': 'Wörterbuchdaten hinzufügen', - 'dictManagement.batchDeleteDictData': 'Wörterbuchdaten massenhaft löschen', + 'dictManagement.addDictType': 'WDT hinzufügen', + 'dictManagement.batchDeleteDictType': 'WDT massenhaft löschen', + 'dictManagement.addDictData': 'WDT hinzufügen', + 'dictManagement.batchDeleteDictData': 'WDT massenhaft löschen', 'dictManagement.itemsPerPage': '{items} Einträge/Seite', 'dictManagement.firstPage': 'Erste Seite', 'dictManagement.prevPage': 'Vorherige Seite', @@ -810,7 +810,7 @@ export default { 'modelConfig.duplicate': 'Duplizieren', 'modelConfig.delete': 'Löschen', 'modelConfig.deselectAll': 'Alle abwählen', - 'modelConfig.select': 'Auswählen', + 'modelConfig.select': 'ausw.', 'modelConfig.selectAll': 'Alle auswählen', 'modelConfig.add': 'Neu hinzufügen', 'modelConfig.selectModelsFirst': 'Bitte wählen Sie zuerst Modelle zum Löschen aus', diff --git a/main/manager-web/src/i18n/vi.js b/main/manager-web/src/i18n/vi.js index dec2fd059..8c5409230 100644 --- a/main/manager-web/src/i18n/vi.js +++ b/main/manager-web/src/i18n/vi.js @@ -10,7 +10,7 @@ export default { 'header.smartManagement': 'Tác nhân AI', 'header.modelConfig': 'Mô hình', 'header.knowledgeBase': 'Kiến thức', - 'header.voiceCloneManagement': 'Nhân bản giọng', + 'header.voiceCloneManagement': 'NB giọng', 'header.voiceResourceManagement': 'Tài nguyên giọng nói', 'header.userManagement': 'Người dùng', 'header.otaManagement': 'Quản lý OTA', diff --git a/main/manager-web/src/views/VoiceCloneManagement.vue b/main/manager-web/src/views/VoiceCloneManagement.vue index 71282ad7e..58f808f45 100644 --- a/main/manager-web/src/views/VoiceCloneManagement.vue +++ b/main/manager-web/src/views/VoiceCloneManagement.vue @@ -42,7 +42,7 @@ - +