diff --git a/src/view/components/speechControl.vue b/src/view/components/speechControl.vue index eda99c9..01f5b92 100644 --- a/src/view/components/speechControl.vue +++ b/src/view/components/speechControl.vue @@ -72,68 +72,23 @@ const config = { params: [], }, { - command: "input_username", - description: "在用户名输入框中填写用户名", + command: "search_project", + description: "搜索项目", action: "input", - selector: "#username, #username-input, input[type='text'][name*='user']", + selector: "#search_project", params: [ { - name: "username", + name: "projectname", type: "string", - description: "要输入的用户名", + description: "要输入的项目名称", }, ], }, - { - command: "input_password", - description: "在密码输入框中填写密码", - action: "input", - selector: "#password, #password-input, input[type='password']", - params: [ - { - name: "password", - type: "string", - description: "要输入的密码", - }, - ], - }, - { - command: "submit_login", - description: "提交登录表单", - action: "click", - selector: "#submit-login, .login-submit, button[type='submit']", - params: [], - }, - { - command: "search_product", - description: "在搜索框中输入关键词", - action: "input", - selector: "#search-input, .search-box, input[type='search']", - params: [ - { - name: "keyword", - type: "string", - description: "搜索关键词", - }, - ], - }, - { - command: "perform_search", - description: "执行搜索操作", - action: "click", - selector: "#search-button, .search-btn, button[type='submit']", - params: [], - }, - { - command: "add_to_cart", - description: "将当前产品添加到购物车", - action: "click", - selector: ".add-to-cart, .cart-btn, [data-add-to-cart]", - params: [], - }, ], }; +const listenStatus = ref(false); + const props = defineProps({ config: { type: Object, @@ -263,7 +218,7 @@ class VoiceControl { if (this.isListening) { // 只有在用户希望继续聆听时才重启 setTimeout(() => { - this.recognition.start(); + this.recognition.start(); }, 100); // 短暂延迟后重启 } else { this.updateUI(); @@ -407,6 +362,9 @@ class VoiceControl { } const element = document.querySelector(commandConfig.selector); + + console.log(element,"-----element"); + if (!element) { throw new Error(`找不到元素: ${commandConfig.selector}`); } @@ -518,8 +476,14 @@ const toggleListening = () => { } if (voiceControl.value.isListening) { + listenStatus.value = false; voiceControl.value.stopListening(); + const voiceBtn = document.getElementById("voice-btn"); + if (voiceBtn) { + voiceBtn.classList.remove("listening"); + } } else { + listenStatus.value = true; voiceControl.value.startListening(); } }; @@ -547,10 +511,6 @@ body { } .container { - max-width: 1200px; - width: 100%; - text-align: center; - padding: 20px; } h1 { diff --git a/src/view/index.vue b/src/view/index.vue index 3028cce..0702e74 100644 --- a/src/view/index.vue +++ b/src/view/index.vue @@ -32,17 +32,6 @@
- -