|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="h-full bg-white p-6 flex flex-col">
|
|
|
3
|
+ <!-- 头部 -->
|
|
|
4
|
+ <div class="flex justify-between items-center mb-8">
|
|
|
5
|
+ <h2 class="text-xl font-medium">通话录音</h2>
|
|
|
6
|
+ <el-icon class="cursor-pointer text-gray-400 hover:text-gray-600" @click="drawerVisible = false">
|
|
|
7
|
+ <Close />
|
|
|
8
|
+ </el-icon>
|
|
|
9
|
+ </div>
|
|
|
10
|
+ <!-- 音频播放器 -->
|
|
|
11
|
+ <div class="bg-gray-50 rounded-lg p-6 mb-6">
|
|
|
12
|
+ <div class="flex justify-center mb-4">
|
|
|
13
|
+ <el-button class="w-16 h-16 !rounded-full flex items-center justify-center"
|
|
|
14
|
+ :type="isPlaying ? 'danger' : 'primary'" @click="togglePlay">
|
|
|
15
|
+ <el-icon class="text-2xl">
|
|
|
16
|
+ <component :is="isPlaying ? 'Pause' : 'VideoPlay'" />
|
|
|
17
|
+ </el-icon>
|
|
|
18
|
+ </el-button>
|
|
|
19
|
+ </div>
|
|
|
20
|
+ <!-- 进度条 -->
|
|
|
21
|
+ <div class="mb-2">
|
|
|
22
|
+ <el-slider v-model="progress" :max="100" @change="handleProgressChange" />
|
|
|
23
|
+ </div>
|
|
|
24
|
+ <!-- 时间显示 -->
|
|
|
25
|
+ <div class="flex justify-between text-sm text-gray-500">
|
|
|
26
|
+ <span>{{ formatTime(currentTime) }}</span>
|
|
|
27
|
+ <span>{{ formatTime(duration) }}</span>
|
|
|
28
|
+ </div>
|
|
|
29
|
+ </div>
|
|
|
30
|
+ <!-- 操作按钮 -->
|
|
|
31
|
+ <div class="mb-6">
|
|
|
32
|
+ <el-button type="primary" class="w-full !rounded-button whitespace-nowrap" @click="handleDownload">
|
|
|
33
|
+ <el-icon class="mr-2">
|
|
|
34
|
+ <Download />
|
|
|
35
|
+ </el-icon>
|
|
|
36
|
+ 下载录音
|
|
|
37
|
+ </el-button>
|
|
|
38
|
+ </div>
|
|
|
39
|
+ <!-- 转写内容 -->
|
|
|
40
|
+ <div class="bg-white rounded-lg p-4 flex flex-col flex-grow overflow-hidden">
|
|
|
41
|
+ <h3 class="text-lg font-medium mb-4">语音转写内容</h3>
|
|
|
42
|
+ <div class="text-gray-600 leading-relaxed overflow-y-auto flex-grow space-y-2">
|
|
|
43
|
+ <div v-for="(message, index) in transcriptionMessages" :key="index" @click="jumpToTime(message.startTime)"
|
|
|
44
|
+ :class="[
|
|
|
45
|
+ 'p-3 transition-colors rounded-lg cursor-pointer group',
|
|
|
46
|
+ message.role === 'agent' ? 'bg-gradient-to-r from-gray-100 to-gray-200 hover:from-gray-200 hover:to-gray-300' : 'bg-gradient-to-r from-blue-50 to-blue-100 hover:from-blue-100 hover:to-blue-200'
|
|
|
47
|
+ ]">
|
|
|
48
|
+ <div class="flex justify-between items-center mb-2">
|
|
|
49
|
+ <div class="flex items-center gap-2">
|
|
|
50
|
+ <div class="text-xs text-gray-400">{{ formatTime(message.startTime) }}</div>
|
|
|
51
|
+ <div :class="[
|
|
|
52
|
+ 'px-2 py-1 rounded-full text-xs font-medium whitespace-nowrap',
|
|
|
53
|
+ message.role === 'agent' ? 'bg-gray-200 text-gray-700 border border-gray-300' : 'bg-blue-100 text-blue-600 border border-blue-200'
|
|
|
54
|
+ ]">
|
|
|
55
|
+ {{ message.role === 'agent' ? '客服' : '客户' }}
|
|
|
56
|
+ </div>
|
|
|
57
|
+ </div>
|
|
|
58
|
+ <el-button class="!rounded-button opacity-0 group-hover:opacity-100 transition-opacity" size="small"
|
|
|
59
|
+ type="text" @click.stop="playSegment(message.startTime, message.endTime)">
|
|
|
60
|
+ <el-icon class="text-lg">
|
|
|
61
|
+ <VideoPlay />
|
|
|
62
|
+ </el-icon>
|
|
|
63
|
+ </el-button>
|
|
|
64
|
+ </div>
|
|
|
65
|
+ <div class="text-gray-700">{{ message.content }}</div>
|
|
|
66
|
+ <div class="text-xs text-gray-400 mt-1">置信度: {{ message.confidence }}%</div>
|
|
|
67
|
+ </div>
|
|
|
68
|
+ </div>
|
|
|
69
|
+ </div>
|
|
|
70
|
+ </div>
|
|
|
71
|
+</template>
|
|
|
72
|
+
|
|
|
73
|
+<script lang="ts" setup>
|
|
|
74
|
+import { ref } from 'vue';
|
|
|
75
|
+import { ElMessage } from 'element-plus';
|
|
|
76
|
+import { Close, VideoPlay, Pause, Download } from '@element-plus/icons-vue';
|
|
|
77
|
+const drawerVisible = ref(false);
|
|
|
78
|
+const deleteDialogVisible = ref(false);
|
|
|
79
|
+const isPlaying = ref(false);
|
|
|
80
|
+const progress = ref(0);
|
|
|
81
|
+const currentTime = ref(0);
|
|
|
82
|
+const duration = ref(180); // 示例时长3分钟
|
|
|
83
|
+const transcriptionMessages = ref([
|
|
|
84
|
+ { role: 'agent', content: '您好,这里是顾客服务中心,很高兴为您服务。', startTime: 0, endTime: 4, confidence: 98 },
|
|
|
85
|
+ { role: 'customer', content: '你好,我想咨询一下我前天购买的产品退货问题。', startTime: 5, endTime: 10, confidence: 96 },
|
|
|
86
|
+ { role: 'agent', content: '好的,请问您能提供一下订单号码吗?', startTime: 11, endTime: 15, confidence: 97 },
|
|
|
87
|
+ { role: 'customer', content: '是的,订单号是2023112509876。', startTime: 16, endTime: 20, confidence: 99 },
|
|
|
88
|
+ { role: 'agent', content: '好的,我已经查询到您的订单信息。请问您想退货的原因是什么呢?', startTime: 21, endTime: 27, confidence: 98 },
|
|
|
89
|
+ { role: 'customer', content: '产品规格和我预期的不太一样,我想换一个大一点的型号。', startTime: 28, endTime: 35, confidence: 95 },
|
|
|
90
|
+ { role: 'agent', content: '明白了。根据我们的退换货政策,您的商品符合七天无理由退换货条件。我这边帮您申请退货,您收到退货地址后,请在三天内寄出商品。', startTime: 36, endTime: 48, confidence: 97 },
|
|
|
91
|
+ { role: 'customer', content: '好的,麻烦你了。请问退款大概需要多久?', startTime: 49, endTime: 54, confidence: 98 },
|
|
|
92
|
+ { role: 'agent', content: '商品寄出后,我们收到并确认商品完好,会在1-3个工作日内为您办理退款。退款会原路返回至您的支付账户。', startTime: 55, endTime: 65, confidence: 96 },
|
|
|
93
|
+ { role: 'customer', content: '明白了,谢谢你的解释。', startTime: 66, endTime: 70, confidence: 99 },
|
|
|
94
|
+ { role: 'agent', content: '不客气,很高兴能帮到您。如果您还有其他问题,随时可以联系我们。祝您生活愉快!', startTime: 71, endTime: 80, confidence: 97 }
|
|
|
95
|
+]);
|
|
|
96
|
+const formatTime = (seconds: number): string => {
|
|
|
97
|
+ const minutes = Math.floor(seconds / 60);
|
|
|
98
|
+ const remainingSeconds = Math.floor(seconds % 60);
|
|
|
99
|
+ return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
|
100
|
+};
|
|
|
101
|
+const togglePlay = () => {
|
|
|
102
|
+ isPlaying.value = !isPlaying.value;
|
|
|
103
|
+ if (isPlaying.value) {
|
|
|
104
|
+ // 模拟播放进度
|
|
|
105
|
+ const timer = setInterval(() => {
|
|
|
106
|
+ if (progress.value >= 100) {
|
|
|
107
|
+ clearInterval(timer);
|
|
|
108
|
+ isPlaying.value = false;
|
|
|
109
|
+ progress.value = 0;
|
|
|
110
|
+ currentTime.value = 0;
|
|
|
111
|
+ return;
|
|
|
112
|
+ }
|
|
|
113
|
+ progress.value += 1;
|
|
|
114
|
+ currentTime.value = (progress.value / 100) * duration.value;
|
|
|
115
|
+ }, 1000);
|
|
|
116
|
+ }
|
|
|
117
|
+};
|
|
|
118
|
+const handleProgressChange = (value: number) => {
|
|
|
119
|
+ currentTime.value = (value / 100) * duration.value;
|
|
|
120
|
+};
|
|
|
121
|
+const jumpToTime = (time: number) => {
|
|
|
122
|
+ progress.value = (time / duration.value) * 100;
|
|
|
123
|
+ currentTime.value = time;
|
|
|
124
|
+};
|
|
|
125
|
+const playSegment = (startTime: number, endTime: number) => {
|
|
|
126
|
+ progress.value = (startTime / duration.value) * 100;
|
|
|
127
|
+ currentTime.value = startTime;
|
|
|
128
|
+ isPlaying.value = true;
|
|
|
129
|
+ // 模拟播放到指定片段结束
|
|
|
130
|
+ const timer = setInterval(() => {
|
|
|
131
|
+ if (currentTime.value >= endTime || !isPlaying.value) {
|
|
|
132
|
+ clearInterval(timer);
|
|
|
133
|
+ isPlaying.value = false;
|
|
|
134
|
+ return;
|
|
|
135
|
+ }
|
|
|
136
|
+ progress.value = (currentTime.value / duration.value) * 100;
|
|
|
137
|
+ currentTime.value += 1;
|
|
|
138
|
+ }, 1000);
|
|
|
139
|
+};
|
|
|
140
|
+const handleDownload = () => {
|
|
|
141
|
+ ElMessage.success('录音文件下载中...');
|
|
|
142
|
+};
|
|
|
143
|
+const handleDelete = () => {
|
|
|
144
|
+ deleteDialogVisible.value = true;
|
|
|
145
|
+};
|
|
|
146
|
+const confirmDelete = () => {
|
|
|
147
|
+ deleteDialogVisible.value = false;
|
|
|
148
|
+ drawerVisible.value = false;
|
|
|
149
|
+ ElMessage.success('录音已删除');
|
|
|
150
|
+};
|
|
|
151
|
+const openDrawer = () => {
|
|
|
152
|
+ drawerVisible.value = true;
|
|
|
153
|
+ progress.value = 0;
|
|
|
154
|
+ currentTime.value = 0;
|
|
|
155
|
+ isPlaying.value = false;
|
|
|
156
|
+};
|
|
|
157
|
+</script>
|
|
|
158
|
+<style scoped>
|
|
|
159
|
+.el-drawer__body {
|
|
|
160
|
+ padding: 0;
|
|
|
161
|
+ overflow: hidden;
|
|
|
162
|
+}
|
|
|
163
|
+
|
|
|
164
|
+/* 隐藏滚动条但保留滚动功能 */
|
|
|
165
|
+.overflow-y-auto::-webkit-scrollbar {
|
|
|
166
|
+ display: none;
|
|
|
167
|
+}
|
|
|
168
|
+
|
|
|
169
|
+.overflow-y-auto {
|
|
|
170
|
+ -ms-overflow-style: none;
|
|
|
171
|
+ scrollbar-width: none;
|
|
|
172
|
+}
|
|
|
173
|
+</style>
|