Bläddra i källkod

修改植物专家用户消息框的样式

丸子 3 månader sedan
förälder
incheckning
74af6390ba
2 ändrade filer med 20 tillägg och 3 borttagningar
  1. 1 1
      src/components/MarkdownView/index.vue
  2. 19 2
      src/components/ai/voice/VoiceInput.vue

+ 1 - 1
src/components/MarkdownView/index.vue

@@ -39,7 +39,7 @@ const renderedMarkdown = computed(() => {
 
 <style lang="scss">
 .markdown-view {
-  font-family: PingFang SC;
+  font-family: 'SourceHanSansCN-Normal';
   font-size: 1rem;
   font-weight: 400;
   line-height: 1.6rem;

+ 19 - 2
src/components/ai/voice/VoiceInput.vue

@@ -53,14 +53,26 @@ const isRecording = ref(false) // 录音状态
 const recognition = ref(null) // 语音识别实例
 const countdown = ref(0) // 倒计时剩余秒数
 const countdownTimer = ref(null) // 倒计时定时器
+const isBrowserSupported = ref(true) // 浏览器是否支持语音识别
 
-// 初始化语音识别
-const initSpeechRecognition = () => {
+// 检测浏览器是否支持语音识别
+const checkBrowserSupport = () => {
   const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
   if (!SpeechRecognition) {
     ElMessage.warning('当前浏览器不支持语音输入功能')
+    isBrowserSupported.value = false
+    return false
+  }
+  return true
+}
+
+// 初始化语音识别
+const initSpeechRecognition = () => {
+  if (!checkBrowserSupport()) {
     return null
   }
+  
+  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
 
   const instance = new SpeechRecognition()
   instance.lang = props.lang
@@ -144,6 +156,11 @@ const toggleSpeechInput = () => {
   }
 }
 
+// 组件挂载时检测浏览器支持
+onMounted(() => {
+  checkBrowserSupport()
+})
+
 // 组件卸载时清理资源
 onUnmounted(() => {
   clearInterval(countdownTimer.value)