This commit is contained in:
Hồ Công Sử 2026-11-16 14:53:18 +08:00 committed by GitHub
commit b4f5800816
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 235 additions and 154 deletions

View file

@ -425,7 +425,7 @@ body {
font-weight: 500;
}
/* 拨号按钮特殊样式 */
/* Kết nối按钮特殊样式 */
.dial-btn.dial-active {
background: rgba(237, 66, 69, 0.9);
}
@ -434,7 +434,7 @@ body {
background: rgba(237, 66, 69, 1);
}
/* 录音按钮特殊样式 */
/* Ghi âm按钮特殊样式 */
.control-btn.recording {
background: rgba(237, 66, 69, 0.9);
animation: pulse 1.5s infinite;
@ -444,7 +444,7 @@ body {
background: rgba(237, 66, 69, 1);
}
/* 摄像头按钮特殊样式 */
/* Camera按钮特殊样式 */
#cameraBtn.camera-active {
background: rgba(237, 66, 69, 0.9);
}
@ -453,7 +453,7 @@ body {
background: rgba(237, 66, 69, 1);
}
/* 录音按钮脉冲动画 */
/* Ghi âm按钮脉冲动画 */
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.7);
@ -1242,7 +1242,7 @@ body {
background: #4f545c;
}
/* ==================== 摄像头显示区域样式 ==================== */
/* ==================== Camera显示区域样式 ==================== */
.camera-container {
position: fixed;
top: 20px;

View file

@ -45,12 +45,12 @@
<!-- 主容器 -->
<div class="container">
<!-- 摄像头显示区域(可拖动) -->
<!-- Camera显示区域(可拖动) -->
<div class="camera-container" id="cameraContainer">
<video id="cameraVideo" autoplay playsinline muted></video>
<div class="camera-switch-mask" id="cameraSwitchMask">
<div class="camera-switch-container">
<!-- 摄像头切换按钮 -->
<!-- Camera切换按钮 -->
<div class="camera-switch" id="cameraSwitch">
<svg class="btn-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7319" width="32" height="32"><path d="M722.1 530.3c0-44.9-13.8-86.5-37.2-120.9-0.3-0.6-0.6-1.2-0.9-1.7-2.9-4.2-6.1-8.1-9.2-12-0.4-0.5-0.7-1-1.1-1.5-21.4-26.3-48.3-46.7-78.7-59.9-0.8-0.4-1.7-0.8-2.5-1.2-4.9-2-9.8-3.8-14.9-5.5-1.8-0.6-3.6-1.3-5.4-1.8-4.4-1.3-8.8-2.4-13.3-3.5-2.5-0.6-4.9-1.2-7.4-1.7-1.2-0.2-2.4-0.6-3.6-0.8-3.3-0.6-6.7-0.8-10-1.3-2.3-0.3-4.6-0.7-6.9-0.9-5.6-0.5-11.2-0.8-16.7-0.9-1 0-2-0.1-3-0.1-0.2 0-0.3 0.1-0.5 0.1-42.8 0-84.6 13.1-120.4 38.6-11.5 8.1-14.2 24.1-6.2 35.7 8 11.6 23.8 14.4 35.2 6.3 27.7-19.7 60-29.6 93.1-29.3 4.8 0 9.5 0.3 14.1 0.7 1.4 0.2 2.8 0.4 4.3 0.5 3.8 0.5 7.6 1 11.3 1.8 1.6 0.3 3.3 0.8 4.9 1.1 3.7 0.8 7.3 1.7 10.9 2.8 1.1 0.4 2.2 0.8 3.4 1.2 4.1 1.3 8.1 2.8 12 4.5 0.4 0.2 0.8 0.4 1.2 0.5 23.6 10.3 44.3 26.1 60.4 45.9 0.1 0.1 0.2 0.3 0.3 0.4 22.7 28 36.4 63.9 36.4 102.9h-42.2L697 632.9l67.5-102.6h-42.4z m-119 133c-27.9 19.8-60.5 29.7-93.9 29.3-4.4-0.1-8.8-0.3-13.1-0.7-1.8-0.2-3.5-0.5-5.3-0.7-3.4-0.5-6.8-0.9-10.1-1.6-2-0.4-4-0.9-6.1-1.4-3.3-0.8-6.5-1.5-9.7-2.5-1.5-0.5-3-1-4.6-1.5-3.7-1.2-7.3-2.5-10.8-4-0.8-0.3-1.6-0.7-2.4-1.1-4.1-1.9-8.2-3.8-12.2-6l-0.6-0.3c-13.4-7.5-25.7-16.8-36.4-27.7-0.2-0.2-0.3-0.4-0.5-0.6-3.3-3.4-6.5-6.9-9.5-10.7-0.6-0.8-1.3-1.6-1.9-2.5-21.9-27.8-35.1-63-35.1-101.2h42.2l-67.5-102.6-67.5 102.6h42.2c0 45 13.9 86.7 37.3 121.1 0.3 0.5 0.5 1 0.8 1.5 2.4 3.5 5.1 6.8 7.7 10.1 1 1.3 1.9 2.6 2.9 3.8 3.9 4.7 7.9 9.2 12.1 13.5 0.4 0.4 0.8 0.9 1.2 1.3 14.1 14.3 30.1 26.4 47.4 36 0.5 0.3 0.9 0.6 1.4 0.8 5 2.7 10.1 5.2 15.3 7.5l3.9 1.8c4.4 1.9 9 3.5 13.6 5.1 2.2 0.7 4.4 1.5 6.6 2.2 4 1.2 8.1 2.2 12.3 3.2 2.8 0.7 5.5 1.4 8.3 1.9 1.2 0.3 2.3 0.6 3.4 0.8 3.9 0.7 7.8 1.1 11.8 1.6l4.2 0.6c7 0.7 14.1 1.2 21.1 1.2 42.9 0 84.7-13.3 120.6-38.8 11.4-8.2 14.2-24.1 6.2-35.8-8-11.5-23.8-14.3-35.3-6.2z m271.3-421.6H763c-26.5 0-82.9-119.7-112.5-119.7H370.6c-29.6 0-85.9 119.7-112.4 119.7H147.5c-46.3 0-83.9 40.2-83.9 89.7v478.8c0 49.6 37.6 89.8 83.9 89.8h726.9c46.3 0 83.9-40.1 83.9-89.8V331.4c0-49.5-37.6-89.7-83.9-89.7z m28 538.6c0 33.1-25 59.8-55.9 59.8h-671c-30.9 0-55.9-26.8-55.9-59.8V361.4c0-33 25-59.8 55.9-59.8h111.2c25.8 0 82-119.7 111.6-119.7h223.2c29.5 0 85.6 119.7 111.5 119.7h113.5c30.9 0 55.9 26.8 55.9 59.8v418.9z" p-id="7320" fill="#ffffff"></path></svg>
</div>
@ -62,7 +62,7 @@
<div class="connection-status-top">
<div class="status-indicator">
<span class="status-dot status-disconnected"></span>
<span id="connectionStatus">离线</span>
<span id="connectionStatus">Ngoại tuyến</span>
</div>
</div>
@ -101,28 +101,28 @@
<span class="btn-text">设置</span>
</button>
<button class="control-btn" id="cameraBtn" title="请先连接服务器" disabled>
<button class="control-btn" id="cameraBtn" title="Vui lòng kết nối máy chủ trước" disabled>
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z" />
</svg>
<span class="btn-text">摄像头</span>
<span class="btn-text">Camera</span>
</button>
<button class="control-btn dial-btn" id="dialBtn" title="拨号">
<button class="control-btn dial-btn" id="dialBtn" title="Kết nối">
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z" />
</svg>
<span class="btn-text">拨号</span>
<span class="btn-text">Kết nối</span>
</button>
<button class="control-btn" id="recordBtn" title="开始录音" disabled>
<button class="control-btn" id="recordBtn" title="开始Ghi âm" disabled>
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M12,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z" />
</svg>
<span class="btn-text">录音</span>
<span class="btn-text">Ghi âm</span>
</button>
</div>
</div>
@ -185,7 +185,7 @@
<div class="input-group">
<label for="serverUrl">WebSocket服务器地址:</label>
<input type="text" id="serverUrl" value="" readonly disabled
placeholder="填写OTA地址后,点击拨号按钮自动连接" />
placeholder="填写OTA地址后,点击Kết nối按钮自动连接" />
</div>
<div class="input-group">
<label for="visionUrl">视觉分析地址:</label>
@ -219,7 +219,7 @@
</div>
</div>
<div class="modal-actions">
<button type="button" class="btn-primary" id="applyWakewordBtn">应用唤醒词</button>
<button type="button" class="btn-primary" id="applyWakewordBtn">Áp dụng từ khóa đánh thức</button>
</div>
</div>
</div>
@ -237,7 +237,7 @@
</div>
<div class="mcp-actions">
<button class="btn-primary" id="addMcpToolBtn">
➕ 添加新工具
➕ 添加Công cụ mới
</button>
</div>
</div>
@ -286,11 +286,11 @@
<div id="mcpErrorContainer"></div>
<form id="mcpToolForm">
<div class="input-group">
<label for="mcpToolName">工具名称 *</label>
<label for="mcpToolName">Tên công cụ *</label>
<input type="text" id="mcpToolName" placeholder="例如: self.get_device_status" required>
</div>
<div class="input-group">
<label for="mcpToolDescription">工具描述 *</label>
<label for="mcpToolDescription">Mô tả công cụ *</label>
<textarea id="mcpToolDescription" placeholder="详细描述工具的功能和使用场景..." required></textarea>
</div>
<div class="input-group">

View file

@ -48,13 +48,13 @@ class App {
startWakewordBridgeListener();
// 检查麦克风可用性
await this.checkMicrophoneAvailability();
// 检查摄像头可用性
// 检查Camera可用性
this.checkCameraAvailability();
// 初始化Live2D
await this.initLive2D();
// 初始化摄像头
// 初始化Camera
this.initCamera();
// 关闭加载loading
// Tắt加载loading
this.setModelLoadingStatus(false);
log('应用初始化完成', 'success');
}
@ -121,13 +121,13 @@ class App {
}
}
// 检查摄像头可用性
// 检查Camera可用性
checkCameraAvailability() {
window.cameraAvailable = true;
log('摄像头可用性检查完成: 默认已绑定验证码', 'success');
log('Camera可用性检查完成: 默认已绑定验证码', 'success');
}
// 初始化摄像头
// 初始化Camera
async initCamera() {
const cameraContainer = document.getElementById('cameraContainer');
const cameraVideo = document.getElementById('cameraVideo');
@ -136,7 +136,7 @@ class App {
const dialBtn = document.getElementById('dialBtn');
if (!cameraContainer || !cameraVideo) {
log('摄像头元素未找到,跳过初始化', 'warning');
log('Camera元素未找到,跳过初始化', 'warning');
return Promise.resolve(false);
}
@ -190,10 +190,10 @@ class App {
window.startCamera = async () => {
try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
log('浏览器不支持摄像头API', 'warning');
log('浏览器不支持CameraAPI', 'warning');
return false;
}
log('正在请求摄像头权限...', 'info');
log('正在请求Camera权限...', 'info');
this.cameraStream = await navigator.mediaDevices.getUserMedia({
video: { width: 180, height: 240, facingMode: this.currentFacingMode },
audio: false
@ -206,23 +206,23 @@ class App {
}
cameraContainer.classList.add('active');
// 切换时挂断情况
// 切换时Ngắt kết nối情况
const hasActive = dialBtn.classList.contains('dial-active');
if (!hasActive) {
cameraContainer.classList.remove('active');
cameraSwitch.classList.remove('active');
window.stopCamera();
}
log('摄像头已启动', 'success');
log('Camera已启动', 'success');
return true;
} catch (error) {
log(`启动摄像头失败: ${error.name} - ${error.message}`, 'error');
log(`启动Camera失败: ${error.name} - ${error.message}`, 'error');
if (error.name === 'NotAllowedError') {
log('摄像头权限被拒绝,请检查浏览器设置', 'warning');
log('Camera权限被拒绝,请检查浏览器设置', 'warning');
} else if (error.name === 'NotFoundError') {
log('未找到摄像头设备', 'warning');
log('未找到Camera设备', 'warning');
} else if (error.name === 'NotReadableError') {
log('摄像头已被其他程序占用', 'warning');
log('Camera已被其他程序占用', 'warning');
}
return false;
}
@ -233,7 +233,7 @@ class App {
this.cameraStream.getTracks().forEach(track => track.stop());
this.cameraStream = null;
cameraVideo.srcObject = null;
log('摄像头已关闭', 'info');
log('Camera đã tắt', 'info');
}
};
@ -269,10 +269,10 @@ class App {
const video = cameraVideo;
if (!video || video.readyState !== video.HAVE_ENOUGH_DATA) {
log('无法拍照:摄像头未就绪', 'warning');
log('无法拍照:Camera未就绪', 'warning');
resolve({
success: false,
error: '摄像头未就绪,请确保已连接且摄像头已启动'
error: 'Camera未就绪,请确保Đã kết nối且Camera已启动'
});
return;
}
@ -356,7 +356,7 @@ class App {
});
};
log('摄像头初始化完成', 'success');
log('Camera初始化完成', 'success');
resolve(true);
});
}

View file

@ -204,7 +204,7 @@ export class AudioRecorder {
if (this.isRecording) return false;
try {
if (!this.initEncoder()) {
log('无法开始录音: Opus编码器初始化失败', 'error');
log('无法开始Ghi âm: Opus编码器初始化失败', 'error');
return false;
}
log('请至少录制1-2秒音频以确保收集足够的数据', 'info');
@ -234,7 +234,7 @@ export class AudioRecorder {
}
// Send listening start message
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
log(`已发送录音开始消息`, 'info');
log(`已发送Ghi âm开始消息`, 'info');
} else {
log('WebSocket未连接,无法发送开始消息', 'error');
return false;
@ -256,10 +256,10 @@ export class AudioRecorder {
this.onRecordingStart(recordingSeconds);
}
}, 100);
log('已开始PCM直接录音', 'success');
log('已开始PCM直接Ghi âm', 'success');
return true;
} catch (error) {
log(`直接录音启动错误: ${error.message}`, 'error');
log(`直接Ghi âm启动错误: ${error.message}`, 'error');
this.isRecording = false;
return false;
}
@ -308,15 +308,15 @@ export class AudioRecorder {
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
const emptyOpusFrame = new Uint8Array(0);
this.websocket.send(emptyOpusFrame);
log('已发送录音停止信号', 'info');
log('已发送Ghi âm停止信号', 'info');
}
if (this.onRecordingStop) {
this.onRecordingStop();
}
log('已停止PCM直接录音', 'success');
log('已停止PCM直接Ghi âm', 'success');
return true;
} catch (error) {
log(`直接录音停止错误: ${error.message}`, 'error');
log(`直接Ghi âm停止错误: ${error.message}`, 'error');
return false;
}
}
@ -355,7 +355,7 @@ export async function checkMicrophoneAvailability() {
log('麦克风可用性检查成功', 'success');
return true;
} catch (error) {
log(`麦克风不可用: ${error.message}`, 'warning');
log(`Micro không khả dụng: ${error.message}`, 'warning');
return false;
}
}

View file

@ -30,7 +30,7 @@ export async function initMcpTools() {
const parsedTools = JSON.parse(savedTools);
// 合并默认工具和用户保存的工具,保留用户自定义的工具
const defaultToolNames = new Set(defaultMcpTools.map(t => t.name));
// 添加默认工具中不存在的新工具
// 添加默认工具中不存在的Công cụ mới
parsedTools.forEach(tool => {
if (!defaultToolNames.has(tool.name)) {
defaultMcpTools.push(tool);
@ -61,7 +61,7 @@ function renderMcpTools() {
countSpan.textContent = `${mcpTools.length} 个工具`;
}
if (mcpTools.length === 0) {
container.innerHTML = '<div style="text-align: center; padding: 30px; color: #999;">暂无工具,点击下方按钮添加新工具</div>';
container.innerHTML = '<div style="text-align: center; padding: 30px; color: #999;">暂无工具,点击下方按钮添加Công cụ mới</div>';
return;
}
container.innerHTML = mcpTools.map((tool, index) => {
@ -77,7 +77,7 @@ function renderMcpTools() {
✏️ 编辑
</button>
<button class="mcp-delete-btn" onclick="window.mcpModule.deleteMcpTool(${index})">
🗑️ 删除
🗑️ Xóa
</button>
</div>
</div>
@ -131,7 +131,7 @@ function renderMcpProperties() {
<span class="mcp-property-value">${prop.description || '-'}</span>
</div>
<div class="mcp-property-row-action">
<button class="mcp-property-delete-btn" onclick="event.stopPropagation(); window.mcpModule.deleteMcpProperty(${index})">删除</button>
<button class="mcp-property-delete-btn" onclick="event.stopPropagation(); window.mcpModule.deleteMcpProperty(${index})">Xóa</button>
</div>
</div>
`).join('');
@ -199,7 +199,7 @@ function openPropertyModal(index = null) {
}
/**
* 关闭参数编辑模态框
* Tắt参数编辑模态框
*/
function closePropertyModal() {
document.getElementById('mcpPropertyModal').style.display = 'none';
@ -266,7 +266,7 @@ function handlePropertySubmit(e) {
}
/**
* 删除参数
* Xóa参数
*/
function deleteMcpProperty(index) {
mcpProperties.splice(index, 1);
@ -317,7 +317,7 @@ function setupMcpEventListeners() {
function openMcpModal(index = null) {
const isConnected = websocket && websocket.readyState === WebSocket.OPEN;
if (isConnected) {
alert('WebSocket 已连接,无法编辑工具');
alert('WebSocket Đã kết nối,无法编辑工具');
return;
}
mcpEditingIndex = index;
@ -354,7 +354,7 @@ function openMcpModal(index = null) {
}
/**
* 关闭模态框
* Tắt模态框
*/
function closeMcpModal() {
document.getElementById('mcpToolModal').style.display = 'none';
@ -377,7 +377,7 @@ function handleMcpSubmit(e) {
// 检查名称重复
const isDuplicate = mcpTools.some((tool, index) => tool.name === name && index !== mcpEditingIndex);
if (isDuplicate) {
showMcpError('工具名称已存在,请使用不同的名称');
showMcpError('Tên công cụ已存在,请使用不同的名称');
return;
}
// 解析模拟返回结果
@ -416,7 +416,7 @@ function handleMcpSubmit(e) {
const tool = { name, description, inputSchema, mockResponse };
if (mcpEditingIndex !== null) {
mcpTools[mcpEditingIndex] = tool;
log(`已更新工具: ${name}`, 'success');
log(`已更Công cụ mới: ${name}`, 'success');
} else {
mcpTools.push(tool);
log(`已添加工具: ${name}`, 'success');
@ -442,20 +442,20 @@ function editMcpTool(index) {
}
/**
* 删除工具
* Xóa工具
*/
function deleteMcpTool(index) {
const isConnected = websocket && websocket.readyState === WebSocket.OPEN;
if (isConnected) {
alert('WebSocket 已连接,无法编辑工具');
alert('WebSocket Đã kết nối,无法编辑工具');
return;
}
if (confirm(`确定要删除工具 "${mcpTools[index].name}" 吗?`)) {
if (confirm(`确定要Xóa工具 "${mcpTools[index].name}" 吗?`)) {
const toolName = mcpTools[index].name;
mcpTools.splice(index, 1);
saveMcpTools();
renderMcpTools();
log(`已删除工具: ${toolName}`, 'info');
log(`已Xóa工具: ${toolName}`, 'info');
}
}
@ -492,7 +492,7 @@ export async function executeMcpTool(toolName, toolArgs) {
return result;
} else {
log('拍照功能不可用', 'warning');
return { success: false, error: '摄像头未启动或不支持拍照功能' };
return { success: false, error: 'Camera未启动或不支持拍照功能' };
}
}

View file

@ -28,7 +28,7 @@ function tryConnect() {
wakewordSocket = new WebSocket(bridgeUrl);
wakewordSocket.onopen = () => {
reconnectAttempts = 0;
log(`本地唤醒事件桥已连接: ${bridgeUrl}`, 'success');
log(`本地唤醒事件桥Đã kết nối: ${bridgeUrl}`, 'success');
// 连接成功后自动保存地址,刷新后仍能记住
localStorage.setItem('xz_tester_wakewordWsUrl', bridgeUrl);
const urlInput = document.getElementById('wakewordWsUrl');
@ -36,7 +36,7 @@ function tryConnect() {
};
wakewordSocket.onerror = () => {
log(`本地唤醒事件桥连接失败: ${bridgeUrl}`, 'error');
log(`本地唤醒事件桥Kết nối thất bại: ${bridgeUrl}`, 'error');
};
wakewordSocket.onmessage = async (event) => {

View file

@ -98,7 +98,7 @@ export class WebSocketHandler {
if (message.type === 'hello') {
log(`服务器回应:${JSON.stringify(message, null, 2)}`, 'success');
window.cameraAvailable = true;
log('连接成功,摄像头已可用', 'success');
log('连接成功,Camera已可用', 'success');
uiController.updateDialButton(true);
this._sendWakeupMessages(message.session_id);
@ -112,19 +112,19 @@ export class WebSocketHandler {
log(`识别结果: ${message.text}`, 'info');
// 检查是否需要绑定设备
if (message.text && (message.text.includes('绑定') || message.text.includes('bind'))) {
log('收到设备绑定提示,更新摄像头状态', 'warning');
log('收到设备绑定提示,更新Camera状态', 'warning');
window.cameraAvailable = false;
// 关闭摄像头
// TắtCamera
if (typeof window.stopCamera === 'function') {
window.stopCamera();
}
// 更新摄像头按钮状态
// 更新Camera按钮状态
const cameraBtn = document.getElementById('cameraBtn');
if (cameraBtn) {
cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头';
cameraBtn.querySelector('.btn-text').textContent = 'Camera';
cameraBtn.disabled = true;
cameraBtn.title = '请先绑定验证码';
cameraBtn.title = 'Vui lòng liên kết mã xác minh trước';
}
}
// 使用新的聊天消息回调显示STT消息
@ -256,7 +256,7 @@ export class WebSocketHandler {
if (live2dManager) {
// 初始化音频分析器(使用音频播放器的上下文)
if (live2dManager.initializeAudioAnalyzer()) {
log('Live2D音频分析器初始化完成,已连接到音频播放器', 'success');
log('Live2D音频分析器初始化完成,Đã kết nối到音频播放器', 'success');
} else {
log('Live2D音频分析器初始化失败,将使用模拟动画', 'warning');
}
@ -413,7 +413,7 @@ export class WebSocketHandler {
// 设置 MCP 模块的 WebSocket 实例
setMcpWebSocket(this.websocket);
// 设置录音器的WebSocket
// 设置Ghi âm器的WebSocket
const audioRecorder = getAudioRecorder();
audioRecorder.setWebSocket(this.websocket);
@ -433,7 +433,7 @@ export class WebSocketHandler {
setupEventHandlers() {
this.websocket.onopen = async () => {
const url = document.getElementById('serverUrl').value;
log(`已连接到服务器: ${url}`, 'success');
log(`Đã kết nối到服务器: ${url}`, 'success');
if (this.onConnectionStateChange) {
this.onConnectionStateChange(true);
@ -461,12 +461,12 @@ export class WebSocketHandler {
const audioRecorder = getAudioRecorder();
audioRecorder.stop();
// 关闭摄像头
// TắtCamera
if (typeof window.stopCamera === 'function') {
window.stopCamera();
}
// 隐藏摄像头显示区域
// 隐藏Camera显示区域
const cameraContainer = document.getElementById('cameraContainer');
if (cameraContainer) {
cameraContainer.classList.remove('active');
@ -505,12 +505,12 @@ export class WebSocketHandler {
const audioRecorder = getAudioRecorder();
audioRecorder.stop();
// 关闭摄像头
// TắtCamera
if (typeof window.stopCamera === 'function') {
window.stopCamera();
}
// 隐藏摄像头显示区域
// 隐藏Camera显示区域
const cameraContainer = document.getElementById('cameraContainer');
if (cameraContainer) {
cameraContainer.classList.remove('active');
@ -574,7 +574,7 @@ export class WebSocketHandler {
return this.websocket;
}
// 检查是否已连接
// 检查是否Đã kết nối
isConnected() {
return this.websocket && this.websocket.readyState === WebSocket.OPEN;
}

View file

@ -135,7 +135,7 @@ class UIController {
wsHandler.disconnect();
this.updateDialButton(false);
if (cameraSwitch) cameraSwitch.classList.remove('active');
this.addChatMessage('Disconnected, see you next time~😊', false);
this.addChatMessage('Đã ngắt kết nối, hẹn gặp lại nhé 😊', false);
} else {
// Check if OTA URL is filled
const otaUrlInput = document.getElementById('otaUrl');
@ -143,7 +143,7 @@ class UIController {
// If OTA URL is not filled, show settings modal and switch to device tab
this.showModal('settingsModal');
this.switchTab('device');
this.addChatMessage('Please fill in OTA server URL', false);
this.addChatMessage('Vui lòng nhập địa chỉ máy chủ OTA', false);
return;
}
@ -165,36 +165,36 @@ class UIController {
cameraTimer = setTimeout(() => {
const cameraContainer = document.getElementById('cameraContainer');
if (!cameraContainer) {
log('摄像头容器不存在', 'warning');
log('Không tìm thấy vùng hiển thị camera', 'warning');
return;
}
const isActive = cameraContainer.classList.contains('active');
if (isActive) {
// 关闭摄像头
// TắtCamera
if (typeof window.stopCamera === 'function') {
if (cameraSwitch) cameraSwitch.classList.remove('active');
window.stopCamera();
}
cameraContainer.classList.remove('active');
cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头';
log('摄像头已关闭', 'info');
cameraBtn.querySelector('.btn-text').textContent = 'Camera';
log('Camera đã tắt', 'info');
} else {
// 打开摄像头
// 打开Camera
if (typeof window.startCamera === 'function') {
window.startCamera().then(success => {
if (success) {
cameraBtn.classList.add('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '关闭';
cameraBtn.querySelector('.btn-text').textContent = 'Tắt';
} else {
this.addChatMessage('⚠️ 摄像头启动失败,请检查浏览器权限', false);
this.addChatMessage('⚠️ Camera启动失败,请检查浏览器权限', false);
}
}).catch(error => {
log(`启动摄像头异常: ${error.message}`, 'error');
log(`启动Camera异常: ${error.message}`, 'error');
});
} else {
log('startCamera函数未定义', 'warning');
log('Hàm startCamera chưa được định nghĩa', 'warning');
}
}
}, 300);
@ -216,11 +216,11 @@ class UIController {
audioRecorder.stop();
// Restore record button to normal state
recordBtn.classList.remove('recording');
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
} else {
// Update button state to recording
recordBtn.classList.add('recording');
recordBtn.querySelector('.btn-text').textContent = '录音中';
recordBtn.querySelector('.btn-text').textContent = 'Đang ghi âm';
// Start recording, update button state after delay
setTimeout(() => {
@ -274,15 +274,15 @@ class UIController {
applyWakewordBtn.addEventListener('click', this.handleApplyWakeword);
}
// 点击模态框背景关闭(仅对特定模态框禁用此功能)
// 点击模态框背景Tắt(仅对特定模态框禁用此功能)
const modals = document.querySelectorAll('.modal');
modals.forEach(modal => {
modal.addEventListener('click', (e) => {
if (e.target === modal) {
// settingsModal、mcpToolModal、mcpPropertyModal 只能通过点击X关闭
// settingsModal、mcpToolModal、mcpPropertyModal 只能通过点击XTắt
const nonClosableModals = ['settingsModal', 'mcpToolModal', 'mcpPropertyModal'];
if (nonClosableModals.includes(modal.id)) {
return; // 禁止点击背景关闭
return; // 禁止点击背景Tắt
}
this.hideModal(modal.id);
}
@ -308,12 +308,12 @@ class UIController {
if (connectionStatus) {
if (isConnected) {
connectionStatus.textContent = '已连接';
connectionStatus.textContent = 'Đã kết nối';
if (statusDot) {
statusDot.className = 'status-dot status-connected';
}
} else {
connectionStatus.textContent = '离线';
connectionStatus.textContent = 'Ngoại tuyến';
if (statusDot) {
statusDot.className = 'status-dot status-disconnected';
}
@ -330,14 +330,14 @@ class UIController {
if (dialBtn) {
if (isConnected) {
dialBtn.classList.add('dial-active');
dialBtn.querySelector('.btn-text').textContent = '挂断';
dialBtn.querySelector('.btn-text').textContent = 'Ngắt kết nối';
// Update dial button icon to hang up icon
dialBtn.querySelector('svg').innerHTML = `
<path d="M12,9C10.4,9 9,10.4 9,12C9,13.6 10.4,15 12,15C13.6,15 15,13.6 15,12C15,10.4 13.6,9 12,9M12,17C9.2,17 7,14.8 7,12C7,9.2 9.2,7 12,7C14.8,7 17,9.2 17,12C17,14.8 14.8,17 12,17M12,4.5C7,4.5 2.7,7.6 1,12C2.7,16.4 7,19.5 12,19.5C17,19.5 21.3,16.4 23,12C21.3,7.6 17,4.5 12,4.5Z"/>
`;
} else {
dialBtn.classList.remove('dial-active');
dialBtn.querySelector('.btn-text').textContent = '拨号';
dialBtn.querySelector('.btn-text').textContent = 'Kết nối';
// Restore dial button icon
dialBtn.querySelector('svg').innerHTML = `
<path d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z"/>
@ -352,10 +352,10 @@ class UIController {
cameraContainer.classList.remove('active');
}
cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头';
cameraBtn.querySelector('.btn-text').textContent = 'Camera';
cameraBtn.disabled = true;
cameraBtn.title = '请先连接服务器';
// 关闭摄像头
cameraBtn.title = 'Vui lòng kết nối máy chủ trước';
// TắtCamera
if (typeof window.stopCamera === 'function') {
window.stopCamera();
}
@ -365,10 +365,10 @@ class UIController {
if (cameraBtn && isConnected) {
if (window.cameraAvailable) {
cameraBtn.disabled = false;
cameraBtn.title = '打开/关闭摄像头';
cameraBtn.title = '打开/TắtCamera';
} else {
cameraBtn.disabled = true;
cameraBtn.title = '请先绑定验证码';
cameraBtn.title = 'Vui lòng liên kết mã xác minh trước';
}
}
@ -377,19 +377,19 @@ class UIController {
const microphoneAvailable = window.microphoneAvailable !== false;
if (isConnected && microphoneAvailable) {
recordBtn.disabled = false;
recordBtn.title = '开始录音';
recordBtn.title = '开始Ghi âm';
// Restore record button to normal state
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording');
} else {
recordBtn.disabled = true;
if (!microphoneAvailable) {
recordBtn.title = window.isHttpNonLocalhost ? '当前由于是http访问,无法录音,只能用文字交互' : '麦克风不可用';
recordBtn.title = window.isHttpNonLocalhost ? '当前由于是http访问,无法Ghi âm,只能用文字交互' : 'Micro không khả dụng';
} else {
recordBtn.title = '请先连接服务器';
recordBtn.title = 'Vui lòng kết nối máy chủ trước';
}
// Restore record button to normal state
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording');
}
}
@ -400,10 +400,10 @@ class UIController {
const recordBtn = document.getElementById('recordBtn');
if (recordBtn) {
if (isRecording) {
recordBtn.querySelector('.btn-text').textContent = `录音中`;
recordBtn.querySelector('.btn-text').textContent = `Đang ghi âm`;
recordBtn.classList.add('recording');
} else {
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording');
}
// Only enable button when microphone is available
@ -423,15 +423,15 @@ class UIController {
// Disable record button
recordBtn.disabled = true;
// Update button text and title
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.title = isHttpNonLocalhost ? '当前由于是http访问,无法录音,只能用文字交互' : '麦克风不可用';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.title = isHttpNonLocalhost ? '当前由于是http访问,无法Ghi âm,只能用文字交互' : 'Micro không khả dụng';
} else {
// If connected, enable record button
const wsHandler = getWebSocketHandler();
if (wsHandler && wsHandler.isConnected()) {
recordBtn.disabled = false;
recordBtn.title = '开始录音';
recordBtn.title = '开始Ghi âm';
}
}
}
@ -464,7 +464,7 @@ class UIController {
switchLive2DModel() {
const modelSelect = document.getElementById('live2dModelSelect');
if (!modelSelect) {
console.error('模型选择下拉框不存在');
console.error('Không tìm thấy danh sách chọn mô hình');
return;
}
@ -475,17 +475,17 @@ class UIController {
app.live2dManager.switchModel(selectedModel)
.then(success => {
if (success) {
this.addChatMessage(`已切换到模型: ${selectedModel}`, false);
this.addChatMessage(`Đã chuyển sang mô hình: ${selectedModel}`, false);
} else {
this.addChatMessage('模型切换失败', false);
this.addChatMessage('Chuyển mô hình thất bại', false);
}
})
.catch(error => {
console.error('模型切换错误:', error);
this.addChatMessage('模型切换出错', false);
console.error('Lỗi khi chuyển mô hình:', error);
this.addChatMessage('Có lỗi khi chuyển mô hình', false);
});
} else {
this.addChatMessage('Live2D管理器未初始化', false);
this.addChatMessage('Trình quản lý Live2D chưa được khởi tạo', false);
}
}
@ -561,14 +561,14 @@ class UIController {
};
if (payload.enabled && payload.wakeWords.length === 0) {
this.addChatMessage('启用唤醒词时,至少需要填写一个唤醒词。', false);
this.addChatMessage('Khi bật từ khóa đánh thức, cần nhập ít nhất một từ khóa.', false);
return;
}
const applyWakewordBtn = document.getElementById('applyWakewordBtn');
if (applyWakewordBtn) {
applyWakewordBtn.disabled = true;
applyWakewordBtn.textContent = '应用中...';
applyWakewordBtn.textContent = 'Đang áp dụng...';
}
try {
@ -584,11 +584,11 @@ class UIController {
if (urlChanged) {
// 地址变了,先确认
const shouldRestart = window.confirm('地址已变更,是否继续?(将断开旧连接并重新连接)');
const shouldRestart = window.confirm('Địa chỉ đã thay đổi, bạn có muốn tiếp tục không? Kết nối cũ sẽ bị ngắt và kết nối lại.');
if (!shouldRestart) {
// 恢复 localStorage 里的旧地址
localStorage.setItem('xz_tester_wakewordWsUrl', currentWsUrl);
this.addChatMessage('已取消地址变更。', false);
this.addChatMessage('Đã hủy thay đổi địa chỉ.', false);
return;
}
@ -601,7 +601,7 @@ class UIController {
// 等 bridge_connected
await new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(new Error('连接新服务器超时'));
reject(new Error('Kết nối tới máy chủ mới bị quá thời gian'));
}, 5000);
onNextBridgeConnected(() => {
@ -614,40 +614,40 @@ class UIController {
await requestWakewordBridge('set_wakeword_config', payload);
this.applyWakewordConfig(payload);
await requestWakewordBridge('restart_wakeword_service');
this.addChatMessage('唤醒词配置已保存,唤醒词服务正在重启。', false);
this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.', false);
} else {
// 地址没变:直接在当前连接操作
const response = await requestWakewordBridge('set_wakeword_config', payload);
this.applyWakewordConfig(response.payload || payload);
const shouldRestart = window.confirm('唤醒词已保存。是否现在重启唤醒词服务以立即生效?');
const shouldRestart = window.confirm('Đã lưu từ khóa đánh thức. Bạn có muốn khởi động lại dịch vụ ngay để áp dụng không?');
if (!shouldRestart) {
this.addChatMessage('唤醒词配置已保存,可稍后手动重启服务后生效。', false);
this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức. Có thể khởi động lại dịch vụ sau để áp dụng.', false);
return;
}
await requestWakewordBridge('restart_wakeword_service');
this.addChatMessage('唤醒词配置已保存,唤醒词服务正在重启。', false);
this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.', false);
}
} catch (error) {
this.addChatMessage(`应用唤醒词失败: ${error.message}`, false);
this.addChatMessage(`Áp dụng từ khóa đánh thức thất bại: ${error.message}`, false);
} finally {
if (applyWakewordBtn) {
applyWakewordBtn.disabled = false;
applyWakewordBtn.textContent = '应用唤醒词';
applyWakewordBtn.textContent = 'Áp dụng từ khóa đánh thức';
}
}
}
// Start AI chat session after connection
startAIChatSession() {
this.addChatMessage('连接成功,开始聊天吧~😊', false);
this.addChatMessage('Kết nối thành công, bắt đầu trò chuyện nhé! 😊', false);
// Check microphone availability and show error messages if needed
if (!window.microphoneAvailable) {
if (window.isHttpNonLocalhost) {
this.addChatMessage('⚠️ 当前由于是http访问,无法录音,只能用文字交互', false);
this.addChatMessage('⚠️ 当前由于是http访问,无法Ghi âm,只能用文字交互', false);
} else {
this.addChatMessage('⚠️ 麦克风不可用,请检查权限设置,只能用文字交互', false);
this.addChatMessage('⚠️ Micro không khả dụng,请检查权限设置,只能用文字交互', false);
}
}
// Start recording only if microphone is available
@ -664,13 +664,13 @@ class UIController {
const cameraBtn = document.getElementById('cameraBtn');
if (cameraBtn) {
cameraBtn.classList.add('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '关闭';
cameraBtn.querySelector('.btn-text').textContent = 'Tắt';
}
} else {
this.addChatMessage('⚠️ 摄像头启动失败,可能被浏览器拒绝', false);
this.addChatMessage('⚠️ Camera启动失败,可能被浏览器拒绝', false);
}
}).catch(error => {
log(`启动摄像头异常: ${error.message}`, 'error');
log(`启动Camera异常: ${error.message}`, 'error');
});
}
}
@ -679,7 +679,7 @@ class UIController {
async handleConnect() {
const wsHandler = getWebSocketHandler();
if (this.isConnecting || (wsHandler && wsHandler.isConnected())) {
log('连接已存在或正在进行,忽略本次拨号请求', 'info');
log('连接已存在或正在进行,忽略本次Kết nối请求', 'info');
return;
}
@ -698,7 +698,7 @@ class UIController {
console.log('otaUrl element:', otaUrlInput);
if (!otaUrlInput || !otaUrlInput.value) {
this.addChatMessage('请输入OTA服务器地址', false);
this.addChatMessage('Vui lòng nhập địa chỉ máy chủ OTA', false);
return;
}
@ -709,12 +709,12 @@ class UIController {
const dialBtn = document.getElementById('dialBtn');
if (dialBtn) {
dialBtn.classList.add('dial-active');
dialBtn.querySelector('.btn-text').textContent = '连接中...';
dialBtn.querySelector('.btn-text').textContent = 'Đang kết nối...';
dialBtn.disabled = true;
}
// Show connecting message
this.addChatMessage('正在连接服务器...', false);
this.addChatMessage('Đang kết nối tới máy chủ...', false);
const chatIpt = document.getElementById('chatIpt');
if (chatIpt) {
@ -739,10 +739,10 @@ class UIController {
if (recordBtn) {
if (isRecording) {
recordBtn.classList.add('recording');
recordBtn.querySelector('.btn-text').textContent = '录音中';
recordBtn.querySelector('.btn-text').textContent = 'Đang ghi âm';
} else {
recordBtn.classList.remove('recording');
recordBtn.querySelector('.btn-text').textContent = '录音';
recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
}
}
};
@ -757,7 +757,7 @@ class UIController {
if (!micAvailable) {
const isHttp = window.isHttpNonLocalhost;
if (isHttp) {
this.addChatMessage('⚠️ 当前由于是http访问,无法录音,只能用文字交互', false);
this.addChatMessage('⚠️ 当前由于是http访问,无法Ghi âm,只能用文字交互', false);
}
// Update global state
window.microphoneAvailable = false;
@ -769,13 +769,13 @@ class UIController {
if (!this.dialBtnDisabled) {
dialBtn.disabled = false;
}
dialBtn.querySelector('.btn-text').textContent = '挂断';
dialBtn.querySelector('.btn-text').textContent = 'Ngắt kết nối';
dialBtn.classList.add('dial-active');
}
this.hideModal('settingsModal');
} else {
throw new Error('OTA连接失败');
throw new Error('OTAKết nối thất bại');
}
} catch (error) {
console.error('Connection error details:', {
@ -786,8 +786,8 @@ class UIController {
// Show error message
const errorMessage = error.message.includes('Cannot set properties of null')
? '连接失败:请检查设备连接'
: `连接失败: ${error.message}`;
? 'Kết nối thất bại: vui lòng kiểm tra thiết bị'
: `Kết nối thất bại: ${error.message}`;
this.addChatMessage(errorMessage, false);
@ -797,7 +797,7 @@ class UIController {
if (!this.dialBtnDisabled) {
dialBtn.disabled = false;
}
dialBtn.querySelector('.btn-text').textContent = '拨号';
dialBtn.querySelector('.btn-text').textContent = 'Kết nối';
dialBtn.classList.remove('dial-active');
console.log('Dial button state restored successfully');
}
@ -811,22 +811,22 @@ class UIController {
const now = Date.now();
if (wsHandler && wsHandler.isConnected()) {
log('页面已连接,忽略自动拨号', 'info');
log('页面Đã kết nối,忽略自动Kết nối', 'info');
return false;
}
if (this.isConnecting || this.dialBtnDisabled) {
log('页面正在连接中,忽略重复唤醒', 'info');
log('Trang đang kết nối, bỏ qua đánh thức lặp lại', 'info');
return false;
}
if (now - this.lastWakewordDialTime < 3000) {
log('唤醒触发过于频繁,忽略本次自动拨号', 'warning');
log('唤醒触发过于频繁,忽略本次自动Kết nối', 'warning');
return false;
}
this.lastWakewordDialTime = now;
this.addChatMessage(`检测到唤醒词“${wakeWord}”,准备连接服务器...`, false);
this.addChatMessage(`Đã phát hiện từ khóa đánh thức“${wakeWord}”,Đang chuẩn bị kết nối máy chủ...`, false);
await this.handleConnect();
return true;
}
@ -841,9 +841,9 @@ class UIController {
toolDiv.className = 'properties-container';
toolDiv.innerHTML = `
<div class="property-item">
<input type="text" placeholder="工具名称" value="新工具">
<input type="text" placeholder="工具描述" value="工具描述">
<button class="remove-property" onclick="uiController.removeMCPTool('${toolId}')">删除</button>
<input type="text" placeholder="Tên công cụ" value="Công cụ mới">
<input type="text" placeholder="Mô tả công cụ" value="Mô tả công cụ">
<button class="remove-property" onclick="uiController.removeMCPTool('${toolId}')">Xóa</button>
</div>
`;

View file

@ -0,0 +1,81 @@
from pathlib import Path
root = Path(__file__).parent
replacements = {
"正在连接服务器...": "Đang kết nối tới máy chủ...",
"连接成功,开始聊天吧~😊": "Kết nối thành công, bắt đầu trò chuyện nhé! 😊",
"Disconnected, see you next time~😊": "Đã ngắt kết nối, hẹn gặp lại nhé 😊",
"Please fill in OTA server URL": "Vui lòng nhập địa chỉ máy chủ OTA",
"摄像头容器不存在": "Không tìm thấy vùng hiển thị camera",
"摄像头已关闭": "Camera đã tắt",
"摄像头": "Camera",
"关闭": "Tắt",
"摄像头启动失败,请检查浏览器权限": "Không thể khởi động camera, vui lòng kiểm tra quyền trình duyệt",
"摄像头启动失败,可能被浏览器拒绝": "Không thể khởi động camera, có thể trình duyệt đã từ chối quyền",
"启动摄像头异常": "Lỗi khi khởi động camera",
"startCamera函数未定义": "Hàm startCamera chưa được định nghĩa",
"录音中": "Đang ghi âm",
"录音": "Ghi âm",
"已连接": "Đã kết nối",
"离线": "Ngoại tuyến",
"挂断": "Ngắt kết nối",
"拨号": "Kết nối",
"请先连接服务器": "Vui lòng kết nối máy chủ trước",
"打开/关闭摄像头": "Bật/tắt camera",
"请先绑定验证码": "Vui lòng liên kết mã xác minh trước",
"开始录音": "Bắt đầu ghi âm",
"当前由于是http访问,无法录音,只能用文字交互": "Hiện đang truy cập bằng HTTP nên không thể ghi âm, chỉ có thể nhập văn bản",
"麦克风不可用": "Micro không khả dụng",
"模型选择下拉框不存在": "Không tìm thấy danh sách chọn mô hình",
"已切换到模型": "Đã chuyển sang mô hình",
"模型切换失败": "Chuyển mô hình thất bại",
"模型切换错误": "Lỗi khi chuyển mô hình",
"模型切换出错": "Có lỗi khi chuyển mô hình",
"Live2D管理器未初始化": "Trình quản lý Live2D chưa được khởi tạo",
"启用唤醒词时,至少需要填写一个唤醒词。": "Khi bật từ khóa đánh thức, cần nhập ít nhất một từ khóa.",
"应用中...": "Đang áp dụng...",
"地址已变更,是否继续?(将断开旧连接并重新连接)": "Địa chỉ đã thay đổi, bạn có muốn tiếp tục không? Kết nối cũ sẽ bị ngắt và kết nối lại.",
"已取消地址变更。": "Đã hủy thay đổi địa chỉ.",
"连接新服务器超时": "Kết nối tới máy chủ mới bị quá thời gian",
"唤醒词配置已保存,唤醒词服务正在重启。": "Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.",
"唤醒词已保存。是否现在重启唤醒词服务以立即生效?": "Đã lưu từ khóa đánh thức. Bạn có muốn khởi động lại dịch vụ ngay để áp dụng không?",
"唤醒词配置已保存,可稍后手动重启服务后生效。": "Đã lưu cấu hình từ khóa đánh thức. Có thể khởi động lại dịch vụ sau để áp dụng.",
"应用唤醒词失败": "Áp dụng từ khóa đánh thức thất bại",
"应用唤醒词": "Áp dụng từ khóa đánh thức",
"请输入OTA服务器地址": "Vui lòng nhập địa chỉ máy chủ OTA",
"连接中...": "Đang kết nối...",
"连接失败:请检查设备连接": "Kết nối thất bại: vui lòng kiểm tra thiết bị",
"连接失败": "Kết nối thất bại",
"OTA连接失败": "Kết nối OTA thất bại",
"连接已存在或正在进行,忽略本次拨号请求": "Kết nối đã tồn tại hoặc đang thực hiện, bỏ qua yêu cầu này",
"页面已连接,忽略自动拨号": "Trang đã kết nối, bỏ qua tự động kết nối",
"页面正在连接中,忽略重复唤醒": "Trang đang kết nối, bỏ qua đánh thức lặp lại",
"唤醒触发过于频繁,忽略本次自动拨号": "Kích hoạt đánh thức quá thường xuyên, bỏ qua lần này",
"检测到唤醒词": "Đã phát hiện từ khóa đánh thức",
"准备连接服务器": "Đang chuẩn bị kết nối máy chủ",
"工具名称": "Tên công cụ",
"新工具": "Công cụ mới",
"工具描述": "Mô tả công cụ",
"删除": "Xóa",
"⚠️ 麦克风不可用,请检查权限设置,只能用文字交互": "⚠️ Không thể sử dụng micro, vui lòng kiểm tra quyền truy cập. Chỉ có thể nhập văn bản.",
"⚠️ 当前由于是http访问,无法录音,只能用文字交互": "⚠️ Đang truy cập bằng HTTP nên không thể ghi âm, chỉ có thể nhập văn bản.",
}
exts = {".js", ".html", ".css"}
changed = []
for path in root.rglob("*"):
if path.is_file() and path.suffix.lower() in exts:
text = path.read_text(encoding="utf-8", errors="ignore")
old = text
for a, b in replacements.items():
text = text.replace(a, b)
if text != old:
path.write_text(text, encoding="utf-8")
changed.append(str(path.relative_to(root)))
print("Đã Việt hóa các file:")
for f in changed:
print(" -", f)
print("Xong.")