1515 <transition name =" el-fade-in-linear" >
1616 <el-card class =" custom-speech-card" :class =" isTouching ? '' : 'active'" v-if =" dialogVisible" >
1717 <p >
18- <el-text type =" info" v-if =" isTouching" >{{ '00:06' }}</el-text >
18+ <el-text type =" info" v-if =" isTouching"
19+ >00:{{ props.time < 10 ? `0${props.time}` : props.time }}</el-text
20+ >
1921 <span class =" lighter" v-else >
2022 {{ message }}
2123 </span >
3638</template >
3739
3840<script setup lang="ts">
39- import { ref } from ' vue'
41+ import { el } from ' element-plus/es/locale'
42+ import { ref , watch } from ' vue'
43+ const props = defineProps ({
44+ time: {
45+ type: Number ,
46+ default: 0
47+ },
48+ start: {
49+ type: Boolean ,
50+ default: false
51+ }
52+ })
53+ const emit = defineEmits ([' TouchStart' , ' TouchEnd' ])
4054// 移动端语音
4155const startY = ref (0 )
4256const isTouching = ref (false )
4357const dialogVisible = ref (false )
4458const message = ref (' 按住说话' )
59+
60+ watch (
61+ () => props .time ,
62+ (val ) => {
63+ if (val && val === 60 ) {
64+ dialogVisible .value = false
65+ emit (' TouchEnd' , isTouching .value )
66+ isTouching .value = false
67+ }
68+ }
69+ )
70+ watch (
71+ () => props .start ,
72+ (val ) => {
73+ if (val ) {
74+ isTouching .value = true
75+ dialogVisible .value = true
76+ message .value = ' 松开发送,上滑取消'
77+ } else {
78+ dialogVisible .value = false
79+ isTouching .value = false
80+ }
81+ }
82+ )
83+
4584function onTouchStart(event : any ) {
46- isTouching . value = true
85+ emit ( ' TouchStart ' )
4786 startY .value = event .touches [0 ].clientY
48- dialogVisible . value = true
49- message . value = ' 松开发送,上滑取消 '
87+ // 阻止默认滚动行为
88+ event . preventDefault ()
5089}
5190function onTouchMove(event : any ) {
5291 if (! isTouching .value ) return
@@ -62,13 +101,7 @@ function onTouchMove(event: any) {
62101 }
63102}
64103function onTouchEnd() {
65- if (isTouching .value ) {
66- message .value = ' 发送成功'
67- } else {
68- message .value = ' 已取消'
69- }
70- isTouching .value = false
71- dialogVisible .value = false
104+ emit (' TouchEnd' , isTouching .value )
72105}
73106 </script >
74107
@@ -85,10 +118,12 @@ function onTouchEnd() {
85118 z-index : 999 ;
86119 text-align : center ;
87120 color : var (--app-text-color-secondary );
88- user-select : none ; /* 禁止选中 */
89- -webkit-user-select : none ; /* Safari */
90- -moz-user-select : none ; /* 老版Firefox */
91- -ms-user-select : none ; /* IE 10及以下 */
121+ -webkit-touch-callout : none ;
122+ -webkit-user-select : none ;
123+ -khtml-user-select : none ;
124+ -moz-user-select : none ;
125+ -ms-user-select : none ;
126+ user-select : none ;
92127 .close {
93128 box-shadow : 0px 4px 8px 0px rgba (31 , 35 , 41 , 0.1 );
94129 border : 1px solid rgba (222 , 224 , 227 , 1 );
0 commit comments