140 lines
2.7 KiB
Vue
140 lines
2.7 KiB
Vue
<template>
|
||
<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-bubble">
|
||
<textarea v-model="editedVoiceText" class="editable-textarea" placeholder="语音转换结果"></textarea>
|
||
</view>
|
||
<view class="voice-result-actions">
|
||
<view class="action-button cancel" @click="handleCancel">取消</view>
|
||
<view class="action-button send" @click="handleSendText">发送</view>
|
||
</view>
|
||
</view>
|
||
</uni-popup>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, watch } from 'vue'
|
||
|
||
const props = defineProps({
|
||
voiceText: String
|
||
})
|
||
|
||
const emit = defineEmits(['cancel', 'sendText'])
|
||
|
||
const popupRef = ref(null)
|
||
const editedVoiceText = ref(props.voiceText || '')
|
||
|
||
// 监听props变化,更新编辑框内容
|
||
watch(() => props.voiceText,
|
||
(newValue) => {
|
||
editedVoiceText.value = newValue || ''
|
||
}
|
||
)
|
||
|
||
// 打开弹窗
|
||
const open = () => {
|
||
if (popupRef.value) {
|
||
popupRef.value.open()
|
||
}
|
||
}
|
||
|
||
// 关闭弹窗
|
||
const close = () => {
|
||
if (popupRef.value) {
|
||
popupRef.value.close()
|
||
}
|
||
}
|
||
|
||
// 处理取消
|
||
const handleCancel = () => {
|
||
emit('cancel')
|
||
close()
|
||
}
|
||
|
||
// 处理发送文本
|
||
const handleSendText = () => {
|
||
emit('sendText', { text: editedVoiceText.value })
|
||
close()
|
||
}
|
||
|
||
// 暴露方法
|
||
defineExpose({
|
||
open,
|
||
close
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
/* 语音结果弹窗样式 */
|
||
.voice-result-popup {
|
||
width: 100% !important;
|
||
height: 100vh;
|
||
background-color: rgba(0, 0, 0, 0.7);
|
||
padding: 40px 20px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-end;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.voice-result-bubble {
|
||
background-color: #00A6FF;
|
||
color: white;
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
padding: 16px;
|
||
border-radius: 10px;
|
||
margin-bottom: 40px;
|
||
min-height: 120px;
|
||
max-height: 400px;
|
||
font-size: 16px;
|
||
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 {
|
||
display: flex;
|
||
justify-content: center;
|
||
gap: 20px;
|
||
width: 100%;
|
||
max-width: 600px;
|
||
margin-top: 20px;
|
||
padding-bottom: 20px;
|
||
}
|
||
|
||
.action-button {
|
||
padding: 12px 24px;
|
||
border-radius: 30px;
|
||
font-size: 18px;
|
||
min-width: 120px;
|
||
text-align: center;
|
||
}
|
||
|
||
.cancel {
|
||
color: #F5F5F5;
|
||
border: 1px solid;
|
||
border-color: #F5F5F5;
|
||
}
|
||
|
||
.send {
|
||
color: #333;
|
||
background-color: #F5F5F5;
|
||
}
|
||
|
||
</style> |