Compare commits

...

2 Commits

Author SHA1 Message Date
Lexcubia 118c2805ad refactor(src): 重命名 mock 文件夹为 mocks
- 将 src/mock 重命名为 src/mocks
- 更新 main.js 中的 mock 引入路径
- 移动 mock 相关的文件到新的文件夹中
2025-04-28 10:28:17 +08:00
Lexcubia 6a976fcb12 refactor(chat): 优化语音输入组件逻辑
- 修改 WebSocket 接收数据逻辑,将实时文本追加到 existing value 中
- 移除未使用的 sendAsText 函数,简化代码结构
2025-04-28 10:26:21 +08:00
6 changed files with 4 additions and 17 deletions

View File

@ -4,7 +4,7 @@ globs:
alwaysApply: true alwaysApply: true
--- ---
--- ---
description: description:
globs: globs:
alwaysApply: true alwaysApply: true
--- ---
@ -32,7 +32,7 @@ alwaysApply: true
- api/ # API接口封装 - api/ # API接口封装
- utils/ # 工具函数 - utils/ # 工具函数
- styles/ # 全局样式 - styles/ # 全局样式
- mock/ # Mock数据 - mocks/ # Mock数据
- App.vue # 根组件 - App.vue # 根组件
- main.js # 入口文件 - main.js # 入口文件

View File

@ -15,7 +15,7 @@ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 在开发环境下引入mock // 在开发环境下引入mock
// if (import.meta.env.VITE_APP_MOCK === 'true') { // if (import.meta.env.VITE_APP_MOCK === 'true') {
import('@/mock') import('@/mocks')
// } // }
const pinia = createPinia(); const pinia = createPinia();

View File

@ -117,7 +117,7 @@ const wsConfig = {
try { try {
const data = JSON.parse(event.data) const data = JSON.parse(event.data)
if (data.text) { if (data.text) {
realTimeText.value = data.text realTimeText.value += data.text
} }
} catch (error) { } catch (error) {
console.error('WebSocket message parse error:', error) console.error('WebSocket message parse error:', error)
@ -213,19 +213,6 @@ const confirmVoiceInput = async () => {
closeVoiceModal() closeVoiceModal()
} }
const sendAsText = () => {
if (isRecording.value) {
stopRecording()
isRecording.value = false
if (realTimeText.value) {
emit('sendText', realTimeText.value)
} else {
ElMessage.warning('没有识别到文字')
}
}
closeVoiceModal()
}
const startRecording = (stream) => { const startRecording = (stream) => {
audioChunks = [] audioChunks = []