在录音时,不能息屏

This commit is contained in:
zhonghua.li
2026-04-18 22:41:20 +08:00
parent 811f5ad16b
commit e7976c0993
51 changed files with 179 additions and 4 deletions

View File

@@ -133,6 +133,10 @@
<text>结束服务</text>
</view>
</view>
<view v-if="isRecordingItem(item.id)" class="recording-realtime">
<text>已录音{{ formatRecordingElapsed(recordingElapsedSeconds) }}</text>
<text>当前大小{{ formatRecordingSize(recordingEstimatedSizeBytes) }}</text>
</view>
</view>
<view class="service-status-empty" v-if="!serviceStatusLoading && !serviceStatusList.length">
<text>{{ emptyListHint }}</text>
@@ -268,7 +272,11 @@ export default {
recorderSupported: false,
recorderManager: null,
recordingServiceId: null,
recordingContext: null
recordingContext: null,
recordingElapsedSeconds: 0,
recordingEstimatedSizeBytes: 0,
recordingTicker: null,
keepScreenOnEnabled: false
}
},
mounted() {
@@ -280,6 +288,8 @@ export default {
this.fetchServiceStatusList();
},
beforeUnmount() {
this.stopRecordingTicker();
this.setKeepScreenOn(false);
if (this.recorderManager && this.recordingServiceId) {
try {
this.recorderManager.stop();
@@ -300,6 +310,8 @@ export default {
const ctx = this.recordingContext;
this.recordingServiceId = null;
this.recordingContext = null;
this.stopRecordingTicker();
this.setKeepScreenOn(false);
const tempFilePath = res.tempFilePath || '';
if (!ctx || !ctx.id) {
return;
@@ -314,9 +326,60 @@ export default {
this.recorderManager.onError(() => {
this.recordingServiceId = null;
this.recordingContext = null;
this.stopRecordingTicker();
this.setKeepScreenOn(false);
uni.showToast({ title: '录音出错', icon: 'none' });
});
},
setKeepScreenOn(enabled) {
if (typeof uni.setKeepScreenOn !== 'function') {
return;
}
uni.setKeepScreenOn({
keepScreenOn: !!enabled,
success: () => {
this.keepScreenOnEnabled = !!enabled;
},
fail: () => {
this.keepScreenOnEnabled = false;
},
});
},
startRecordingTicker() {
this.stopRecordingTicker();
this.recordingElapsedSeconds = 0;
this.recordingEstimatedSizeBytes = 0;
// 96kbpsencodeBitRate约等于每秒 12000 字节
const bytesPerSecond = 96000 / 8;
this.recordingTicker = setInterval(() => {
this.recordingElapsedSeconds += 1;
this.recordingEstimatedSizeBytes = Math.floor(this.recordingElapsedSeconds * bytesPerSecond);
}, 1000);
},
stopRecordingTicker() {
if (this.recordingTicker) {
clearInterval(this.recordingTicker);
}
this.recordingTicker = null;
this.recordingElapsedSeconds = 0;
this.recordingEstimatedSizeBytes = 0;
},
formatRecordingElapsed(seconds) {
const safeSeconds = Math.max(0, Number(seconds) || 0);
const minutes = String(Math.floor(safeSeconds / 60)).padStart(2, '0');
const remainSeconds = String(safeSeconds % 60).padStart(2, '0');
return `${minutes}:${remainSeconds}`;
},
formatRecordingSize(bytes) {
const size = Math.max(0, Number(bytes) || 0);
if (size < 1024) {
return `${size} B`;
}
if (size < 1024 * 1024) {
return `${(size / 1024).toFixed(1)} KB`;
}
return `${(size / (1024 * 1024)).toFixed(2)} MB`;
},
isRecordingItem(recordId) {
if (!recordId || !this.recordingServiceId) {
return false;
@@ -356,9 +419,13 @@ export default {
encodeBitRate: 96000,
format: 'mp3'
});
this.setKeepScreenOn(true);
this.startRecordingTicker();
} catch (e) {
this.recordingServiceId = null;
this.recordingContext = null;
this.stopRecordingTicker();
this.setKeepScreenOn(false);
uni.showToast({ title: '无法开始录音', icon: 'none' });
}
},
@@ -370,6 +437,8 @@ export default {
if (String(item.id) !== this.recordingServiceId) {
return;
}
this.stopRecordingTicker();
this.setKeepScreenOn(false);
this.recorderManager.stop();
},
/**
@@ -1449,6 +1518,18 @@ export default {
color: #999;
font-size: 28rpx;
}
.recording-realtime {
margin-top: 12rpx;
display: flex;
align-items: center;
gap: 20rpx;
}
.recording-realtime text {
font-size: 24rpx;
color: #FF3B30;
}
/* 补录弹窗样式 */
.supplement-dialog-mask {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

View File

@@ -0,0 +1,8 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 名片/客户卡片图标 -->
<rect x="20" y="25" width="41" height="31" rx="3" fill="none" stroke="#7A7E83" stroke-width="3"/>
<circle cx="30" cy="35" r="5" fill="none" stroke="#7A7E83" stroke-width="2.5"/>
<path d="M 22 45 Q 22 42 30 42 Q 38 42 38 45" fill="none" stroke="#7A7E83" stroke-width="2.5" stroke-linecap="round"/>
<line x1="38" y1="35" x2="55" y2="35" stroke="#7A7E83" stroke-width="2.5" stroke-linecap="round"/>
<line x1="38" y1="42" x2="50" y2="42" stroke="#7A7E83" stroke-width="2.5" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

View File

@@ -0,0 +1,8 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 名片/客户卡片图标 -->
<rect x="20" y="25" width="41" height="31" rx="3" fill="#000000" stroke="#000000" stroke-width="3"/>
<circle cx="30" cy="35" r="5" fill="white"/>
<path d="M 22 45 Q 22 42 30 42 Q 38 42 38 45" fill="white" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
<line x1="38" y1="35" x2="55" y2="35" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
<line x1="38" y1="42" x2="50" y2="42" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

View File

@@ -0,0 +1,15 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 折线图图标 - 表示数据洞察 -->
<rect x="15" y="15" width="51" height="51" rx="2" fill="none" stroke="#7A7E83" stroke-width="2.5"/>
<!-- 网格线 -->
<line x1="15" y1="33" x2="66" y2="33" stroke="#7A7E83" stroke-width="1.5" stroke-dasharray="2,2"/>
<line x1="15" y1="48" x2="66" y2="48" stroke="#7A7E83" stroke-width="1.5" stroke-dasharray="2,2"/>
<!-- 折线 -->
<polyline points="20,55 30,45 40,35 50,40 60,30" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<!-- 数据点 -->
<circle cx="20" cy="55" r="3" fill="#7A7E83"/>
<circle cx="30" cy="45" r="3" fill="#7A7E83"/>
<circle cx="40" cy="35" r="3" fill="#7A7E83"/>
<circle cx="50" cy="40" r="3" fill="#7A7E83"/>
<circle cx="60" cy="30" r="3" fill="#7A7E83"/>
</svg>

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

View File

@@ -0,0 +1,15 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 折线图图标 - 表示数据洞察 -->
<rect x="15" y="15" width="51" height="51" rx="2" fill="none" stroke="#007AFF" stroke-width="2.5"/>
<!-- 网格线 -->
<line x1="15" y1="33" x2="66" y2="33" stroke="#007AFF" stroke-width="1.5" stroke-dasharray="2,2" opacity="0.5"/>
<line x1="15" y1="48" x2="66" y2="48" stroke="#007AFF" stroke-width="1.5" stroke-dasharray="2,2" opacity="0.5"/>
<!-- 折线 -->
<polyline points="20,55 30,45 40,35 50,40 60,30" fill="none" stroke="#007AFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<!-- 数据点 -->
<circle cx="20" cy="55" r="3" fill="#007AFF"/>
<circle cx="30" cy="45" r="3" fill="#007AFF"/>
<circle cx="40" cy="35" r="3" fill="#007AFF"/>
<circle cx="50" cy="40" r="3" fill="#007AFF"/>
<circle cx="60" cy="30" r="3" fill="#007AFF"/>
</svg>

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,8 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 握手图标 - 表示接待 -->
<path d="M 25 45 Q 25 35 30 35 L 35 35 Q 40 35 40 40" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round"/>
<path d="M 56 45 Q 56 35 51 35 L 46 35 Q 41 35 41 40" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round"/>
<ellipse cx="30" cy="40" rx="8" ry="12" fill="none" stroke="#7A7E83" stroke-width="3"/>
<ellipse cx="51" cy="40" rx="8" ry="12" fill="none" stroke="#7A7E83" stroke-width="3"/>
<path d="M 30 40 Q 40.5 45 51 40" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

View File

@@ -0,0 +1,8 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 握手图标 - 表示接待 -->
<path d="M 25 45 Q 25 35 30 35 L 35 35 Q 40 35 40 40" fill="none" stroke="#007AFF" stroke-width="3" stroke-linecap="round"/>
<path d="M 56 45 Q 56 35 51 35 L 46 35 Q 41 35 41 40" fill="none" stroke="#007AFF" stroke-width="3" stroke-linecap="round"/>
<ellipse cx="30" cy="40" rx="8" ry="12" fill="#007AFF" stroke="#007AFF" stroke-width="3"/>
<ellipse cx="51" cy="40" rx="8" ry="12" fill="#007AFF" stroke="#007AFF" stroke-width="3"/>
<path d="M 30 40 Q 40.5 45 51 40" fill="#007AFF" stroke="#007AFF" stroke-width="3" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,16 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 多人协作图标 -->
<circle cx="30" cy="30" r="10" fill="none" stroke="#7A7E83" stroke-width="3"/>
<path d="M 15 50 Q 15 42 30 42 Q 45 42 45 50" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round"/>
<circle cx="51" cy="30" r="10" fill="none" stroke="#7A7E83" stroke-width="3"/>
<path d="M 36 50 Q 36 42 51 42 Q 66 42 66 50" fill="none" stroke="#7A7E83" stroke-width="3" stroke-linecap="round"/>
<!-- 连接线表示协作 -->
<line x1="40" y1="30" x2="41" y2="30" stroke="#7A7E83" stroke-width="2"/>
<line x1="30" y1="50" x2="40.5" y2="60" stroke="#7A7E83" stroke-width="2"/>
<line x1="51" y1="50" x2="40.5" y2="60" stroke="#7A7E83" stroke-width="2"/>
<!-- 底部协作点 -->
<circle cx="40.5" cy="60" r="4" fill="#7A7E83"/>
</svg>

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

View File

@@ -0,0 +1,16 @@
<svg width="81" height="81" viewBox="0 0 81 81" xmlns="http://www.w3.org/2000/svg">
<!-- 多人协作图标 -->
<circle cx="30" cy="30" r="10" fill="#007AFF"/>
<path d="M 15 50 Q 15 42 30 42 Q 45 42 45 50" fill="#007AFF" stroke="#007AFF" stroke-width="3" stroke-linecap="round"/>
<circle cx="51" cy="30" r="10" fill="#007AFF"/>
<path d="M 36 50 Q 36 42 51 42 Q 66 42 66 50" fill="#007AFF" stroke="#007AFF" stroke-width="3" stroke-linecap="round"/>
<!-- 连接线表示协作 -->
<line x1="40" y1="30" x2="41" y2="30" stroke="#007AFF" stroke-width="2"/>
<line x1="30" y1="50" x2="40.5" y2="60" stroke="#007AFF" stroke-width="2"/>
<line x1="51" y1="50" x2="40.5" y2="60" stroke="#007AFF" stroke-width="2"/>
<!-- 底部协作点 -->
<circle cx="40.5" cy="60" r="4" fill="#007AFF"/>
</svg>

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB