feat: 语音样式调整

This commit is contained in:
zoujing
2025-08-07 17:07:45 +08:00
parent 42780eff0a
commit a432c32fb5
4 changed files with 64 additions and 42 deletions

View File

@@ -2,6 +2,7 @@
<uni-popup position="center" :mask-click-able="false" ref="popupRef" type="center" :safe-area="false" :custom-style="{width: '100%', height: '100vh', borderRadius: 0, position: 'fixed', top: '0', left: '0', zIndex: 9999}"> <uni-popup position="center" :mask-click-able="false" ref="popupRef" type="center" :safe-area="false" :custom-style="{width: '100%', height: '100vh', borderRadius: 0, position: 'fixed', top: '0', left: '0', zIndex: 9999}">
<view class="recording-popup"> <view class="recording-popup">
<view class="recording-wave"> <view class="recording-wave">
<!-- 波形动画 --> <!-- 波形动画 -->
<view class="wave-animation"></view> <view class="wave-animation"></view>
</view> </view>

View File

@@ -1,12 +1,11 @@
<template> <template>
<uni-popup position="center" :mask-click-able="false" ref="popupRef" type="center" :safe-area="false" :custom-style="{width: '100%', height: '100vh', borderRadius: 0, position: 'fixed', top: '0', left: '0', zIndex: 9999}"> <uni-popup position="center" :mask-click-able="false" ref="popupRef" type="center" :safe-area="false" :custom-style="{ width: '100%', maxWidth: '100vw', borderRadius: 0, position: 'fixed', top: '0', left: '0', zIndex: 9999 }">
<view class="voice-result-popup"> <view class="voice-result-popup">
<view class="voice-result-bubble"> <view class="voice-result-bubble">
{{ voiceText }} <textarea v-model="editedVoiceText" class="editable-textarea" placeholder="语音转换结果"></textarea>
</view> </view>
<view class="voice-result-actions"> <view class="voice-result-actions">
<view class="action-button cancel" @click="handleCancel">取消</view> <view class="action-button cancel" @click="handleCancel">取消</view>
<view class="action-button voice" @click="handleSendVoice">发送原语音</view>
<view class="action-button send" @click="handleSendText">发送</view> <view class="action-button send" @click="handleSendText">发送</view>
</view> </view>
</view> </view>
@@ -14,15 +13,23 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref, watch } from 'vue'
const props = defineProps({ const props = defineProps({
voiceText: String voiceText: String
}) })
const emit = defineEmits(['cancel', 'sendVoice', 'sendText']) const emit = defineEmits(['cancel', 'sendText'])
const popupRef = ref(null) const popupRef = ref(null)
const editedVoiceText = ref(props.voiceText || '')
// 监听props变化更新编辑框内容
watch(() => props.voiceText,
(newValue) => {
editedVoiceText.value = newValue || ''
}
)
// 打开弹窗 // 打开弹窗
const open = () => { const open = () => {
@@ -44,15 +51,9 @@ const handleCancel = () => {
close() close()
} }
// 处理发送原语音
const handleSendVoice = () => {
emit('sendVoice', { text: props.voiceText })
close()
}
// 处理发送文本 // 处理发送文本
const handleSendText = () => { const handleSendText = () => {
emit('sendText', { text: props.voiceText }) emit('sendText', { text: editedVoiceText.value })
close() close()
} }
@@ -67,57 +68,73 @@ defineExpose({
/* 语音结果弹窗样式 */ /* 语音结果弹窗样式 */
.voice-result-popup { .voice-result-popup {
width: 100% !important; width: 100% !important;
height: 100vh !important; height: 100vh;
background-color: white; background-color: rgba(0, 0, 0, 0.7);
border-radius: 0;
padding: 40px 20px; padding: 40px 20px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: flex-end;
position: fixed; box-sizing: border-box;
top: 0;
left: 0;
z-index: 9999;
} }
.voice-result-bubble { .voice-result-bubble {
background-color: #4CD964; background-color: #00A6FF;
color: white; color: white;
padding: 25px; box-sizing: border-box;
border-radius: 18px; width: 100%;
border-top-left-radius: 4px; padding: 16px;
border-radius: 10px;
margin-bottom: 40px; margin-bottom: 40px;
min-height: 100px; min-height: 120px;
font-size: 20px; max-height: 400px;
flex: 1; font-size: 16px;
overflow-y: auto; overflow-y: auto;
box-shadow: 2px 2px 6px 0px rgba(0,0,0,0.1);
border-radius: 20px 4px 20px 20px;
border: 1px solid;
border-color: #FFFFFF;
}
.editable-textarea {
width: 100%;
height: 100%;
background: transparent;
color: white;
font-size: 16px;
}
.editable-textarea:focus {
outline: none;
} }
.voice-result-actions { .voice-result-actions {
display: flex; display: flex;
justify-content: space-between; justify-content: center;
gap: 20px;
width: 100%;
max-width: 600px;
margin-top: 20px; margin-top: 20px;
padding-bottom: 40px; padding-bottom: 20px;
} }
.action-button { .action-button {
padding: 12px 24px; padding: 12px 24px;
border-radius: 30px; border-radius: 30px;
font-size: 18px; font-size: 18px;
min-width: 120px;
text-align: center;
} }
.cancel { .cancel {
color: #666666; color: #F5F5F5;
background-color: #F5F5F5; border: 1px solid;
} border-color: #F5F5F5;
.voice {
color: #007AFF;
background-color: #E8F0FE;
} }
.send { .send {
color: white; color: #333;
background-color: #007AFF; background-color: #F5F5F5;
} }
</style> </style>

View File

@@ -20,7 +20,7 @@
@touchend.stop="stopRecording" @touchend.stop="stopRecording"
@touchmove.stop="handleTouchMove" @touchmove.stop="handleTouchMove"
> >
按住说话 按住说话
</view> --> </view> -->
<view v-if="isVoiceMode" class="hold-to-talk-button" @click.stop="startRecording"> <view v-if="isVoiceMode" class="hold-to-talk-button" @click.stop="startRecording">
按住说话 按住说话
@@ -201,7 +201,11 @@ const cancelVoice = () => {
const testPopup = () => { const testPopup = () => {
// 模拟开始录音,打开录音弹窗 // 模拟开始录音,打开录音弹窗
isRecording.value = true isRecording.value = true
console.log("===========1")
if (recordingPopupRef.value) { if (recordingPopupRef.value) {
console.log("===========2")
recordingPopupRef.value.open() recordingPopupRef.value.open()
} }
@@ -215,7 +219,7 @@ const testPopup = () => {
if (voiceResultPopupRef.value) { if (voiceResultPopupRef.value) {
voiceResultPopupRef.value.open() voiceResultPopupRef.value.open()
} }
}, 2000) }, 3000)
} }

View File

@@ -88,8 +88,8 @@
z-index: 1; z-index: 1;
transition: padding-bottom 0.3s ease; transition: padding-bottom 0.3s ease;
/* 确保输入区域始终可见 */ /* 确保输入区域始终可见 */
transform: translateZ(0); // transform: translateZ(0);
-webkit-transform: translateZ(0); // -webkit-transform: translateZ(0);
} }
.area-input { .area-input {