diff --git a/ShengShengBuXi/Hubs/AudioHub.cs b/ShengShengBuXi/Hubs/AudioHub.cs index bd09c44..9238239 100644 --- a/ShengShengBuXi/Hubs/AudioHub.cs +++ b/ShengShengBuXi/Hubs/AudioHub.cs @@ -919,8 +919,15 @@ namespace ShengShengBuXi.Hubs Text = text, Timestamp = DateTime.Now }); + if (!_presetSentences.Contains(text)) + { + _presetSentences.Add(text); + } _presetSentences.Add(text); - _presetSentences2.Add(text); + if (!_presetSentences2.Contains(text)) + { + _presetSentences2.Add(text); + } return false; } @@ -1145,17 +1152,16 @@ namespace ShengShengBuXi.Hubs // 检查队列是否为空 if (_displayTextQueue.IsEmpty) { - // 检查是否需要添加预设文本 - if (DateTime.Now.Subtract(_lastRealUserSpeakTime).TotalSeconds > 30) + if (!_manualScreenControlEnabled) { AddFakeTextToQueue(); } else { - _logger.LogInformation("显示文本队列为空,且不需要添加预设文本"); - // 如果队列为空且不需要添加预设文本,返回空 + await Clients.Caller.SendAsync("ReceiveDisplayText", ""); return; } + } // 从队列中选择最高优先级的消息 @@ -2170,7 +2176,8 @@ namespace ShengShengBuXi.Hubs /// 处理任务 public async Task SavePresetSentences(List sentences) { - sentences = sentences.Where(it => !string.IsNullOrEmpty(it)).ToList(); + sentences = sentences.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList(); + if (!_clients.TryGetValue(Context.ConnectionId, out var clientInfo)) { _logger.LogWarning($"未注册的客户端尝试保存预设句子列表: {Context.ConnectionId}"); diff --git a/ShengShengBuXi/Pages/Admin.cshtml b/ShengShengBuXi/Pages/Admin.cshtml index 71b5514..9e86cb2 100644 --- a/ShengShengBuXi/Pages/Admin.cshtml +++ b/ShengShengBuXi/Pages/Admin.cshtml @@ -33,11 +33,15 @@ --> + type="button" role="tab" aria-controls="recordings" aria-selected="false"> + 用户留言 +
@@ -72,11 +82,17 @@
+ onclick="saveConfig()"> + 保存配置 + + onclick="getLatestConfig()"> + 刷新配置 + + onclick="exportConfig()"> + 导出配置 +
@@ -86,52 +102,52 @@
+ name="network.serverUrl">
WebSocket服务器地址
+ name="network.reconnectAttempts">
+ name="network.reconnectDelayMs">
+ name="network.enableSpeechToText">
+ name="network.enableAudioStreaming">
+ name="network.heartbeatIntervalSeconds">
拨号配置
+ name="dial.minDigitsToDialOut">
拨号所需的最小位数
+ name="dial.autoDialOutAfterSeconds">
无新按键后自动拨出的等待秒数
+ name="dial.resetTimeoutSeconds">
位数不足时,无操作重置的等待秒数
@@ -142,71 +158,71 @@
+ name="recording.recordingFolder">
+ name="recording.recordingDeviceNumber">
+ name="recording.sampleRate">
+ name="recording.channels">
1=单声道,2=立体声
+ name="recording.bufferMilliseconds">
+ name="recording.silenceThreshold" step="0.01">
+ name="recording.silenceTimeoutSeconds">
无声音自动挂断的时间
+ name="recording.allowUserHangup">
+ name="recording.uploadRecordingToServer"> + for="uploadRecordingToServer">上传录音文件到服务器
+ name="recording.recordingsFolder">
+ name="recording.fileNameFormat">
+ id="autoCleanupOldRecordings" name="recording.autoCleanupOldRecordings"> + for="autoCleanupOldRecordings">自动清理旧录音
+ name="recording.keepRecordingsDays">
启用自动清理时有效
@@ -219,37 +235,37 @@
+ name="audioFiles.audioBasePath">
+ name="audioFiles.waitingToneFile">
+ name="audioFiles.waitForPickupFile">
+ name="audioFiles.phonePickupFile">
+ name="audioFiles.promptUserRecordFile">
+ name="audioFiles.beepPromptFile">
+ name="audioFiles.digitToneFileTemplate">
例如: {0}.mp3,用于数字0-9的按键音
@@ -260,19 +276,19 @@
+ name="callFlow.waitForPickupMinSeconds">
等待接电话音频的最小持续时间
+ name="callFlow.waitForPickupMaxSeconds">
等待接电话音频的最大持续时间
+ name="callFlow.playPickupProbability" step="0.01" min="0" max="1">
播放电话接起音频的概率(0-1之间)
@@ -319,7 +335,9 @@
当前播放: + onclick="closeAudioPlayer()"> + 关闭 +
- +
@@ -387,15 +405,21 @@
+ aria-labelledby="display-config-tab">
+ onclick="saveDisplayConfig()"> + 保存配置 + + onclick="getDisplayConfig()"> + 刷新配置 + + onclick="resetDisplayConfig()"> + 重置默认值 +
@@ -409,23 +433,23 @@
+ class="form-label">翻页高度比例 + id="leftTurnPageHeight" step="0.1" min="0.1" max="1.0" + value="0.8">
页面高度比例,值范围0.1-1.0
+ value="16px">
左侧历史记录字体大小,例如16px
+ class="form-label">打字效果速度 + id="leftTypewriterSpeed" min="10" max="500" value="50">
数值越小,打字效果速度越快
@@ -442,7 +466,7 @@
+ value="24px">
右侧主要显示文本的字体大小
@@ -463,9 +487,9 @@
+ class="form-label">打字效果速度 + id="rightTypewriterSpeed" min="10" max="500" value="50">
数值越小,打字效果速度越快
@@ -481,50 +505,50 @@
+ id="waterEffectEnabled" checked> + for="waterEffectEnabled">启用水波纹效果
+ class="form-label">最小间隔(毫秒) + min="100" max="5000" value="800">
+ class="form-label">最大间隔(毫秒) + min="100" max="10000" value="2000">
+ class="form-label">同时涟漪数量 + id="waterSimultaneousDrops" min="1" max="10" value="3">
+ min="0.01" max="1" step="0.01" value="0.1">
+ min="0" max="1" step="0.1" value="0.5">
0表示随机,1表示集中在中心
+ class="form-label">大水滴概率 + id="waterLargeDropProbability" min="0" max="1" step="0.1" + value="0.2">
+ id="waterLargeDropSize" min="3" max="20" value="9">
@@ -539,7 +563,9 @@
+ onclick="getRealUserRecords()"> + 刷新记录 +
@@ -560,7 +586,7 @@
- +
@@ -605,7 +631,7 @@
@section Scripts { - @* *@ +@* *@