Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e8ff93d3
authored
Jun 26, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 日志冲突
1 parent
668dc98c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
85 additions
and
19 deletions
components/AiAssistantBall/AiAssistantBall.vue
uni_modules/uni-recorder-x/utssdk/app-android/AudioRecorder.kt
uni_modules/uni-recorder-x/utssdk/app-android/index.uts
uni_modules/uni-recorder-x/utssdk/app-android/utils.uts
uni_modules/uni-recorder-x/utssdk/app-ios/UniAudioRecorderManager.swift
utils/recordManager/AudioManager.js
utils/recordManager/FileUploadManager.js
utils/recordManager/NativeSave.js
utils/recordManager/PollingSave.js
utils/recordManager/RecordSaveService.js
utils/recordManager/RecordService.js
utils/recordManager/TempRecord.js
utils/recordManager/helpler.js
components/AiAssistantBall/AiAssistantBall.vue
View file @
e8ff93d
...
...
@@ -30,14 +30,14 @@
<view
class=
"fab-content-idle"
>
<image
class=
"idle-mascot-svg"
src=
"
https://img02.glsx.com.cn/weapp/resource/app-tape
/ai-assistant/side-sparkle-rise-export.svg"
src=
"
/static/images
/ai-assistant/side-sparkle-rise-export.svg"
mode=
"scaleToFill"
></image>
</view>
<view
class=
"fab-content-active"
>
<image
class=
"thinking-orb-svg"
src=
"
https://img02.glsx.com.cn/weapp/resource/app-tape
/ai-assistant/122-eye-blink.svg"
src=
"
/static/images
/ai-assistant/122-eye-blink.svg"
mode=
"scaleToFill"
></image>
<!--
<view
class=
"thinking-capsule-bg"
></view>
-->
...
...
@@ -70,7 +70,7 @@
<text
class=
"help-menu-action-text"
>
✨ 帮我回答顾客刚才的问题(近1分钟)
</text>
<image
class=
"help-menu-action-arrow"
src=
"
https://img02.glsx.com.cn/weapp/resource/app-tape
/ai-assistant/Vector.png"
src=
"
/static/images
/ai-assistant/Vector.png"
mode=
"aspectFit"
/>
</view>
...
...
@@ -78,7 +78,7 @@
<text
class=
"help-menu-action-text"
>
🌟 介绍下谈客助手该如何使用
</text>
<image
class=
"help-menu-action-arrow"
src=
"
https://img02.glsx.com.cn/weapp/resource/app-tape
/ai-assistant/Vector.png"
src=
"
/static/images
/ai-assistant/Vector.png"
mode=
"aspectFit"
/>
</view>
...
...
@@ -132,7 +132,7 @@
<text
class=
"help-menu-action-text"
>
🌟
{{
item
.
query
}}
</text>
<image
class=
"help-menu-action-arrow"
src=
"
https://img02.glsx.com.cn/weapp/resource/app-tape
/ai-assistant/Vector.png"
src=
"
/static/images
/ai-assistant/Vector.png"
mode=
"aspectFit"
/>
</view>
...
...
@@ -1423,7 +1423,7 @@ export default {
}
.result-head.question-content-head
{
height
:
53px
;
padding
:
16px
24px
;
padding
:
28px
24px
16px
24px
;
align-items
:
center
;
flex-shrink
:
0
;
}
...
...
uni_modules/uni-recorder-x/utssdk/app-android/AudioRecorder.kt
View file @
e8ff93d
...
...
@@ -49,6 +49,7 @@ class AudioRecorder() {
// 定义错误码常量
companion
object
{
private
const
val
TAG
=
"uni-recorder-x"
const
val
ERROR_RECORDING_IN_PROGRESS
=
1001
const
val
ERROR_NO_SUPPORTED_SAMPLE_RATE
=
1107602
const
val
ERROR_BUFFER_SIZE_CALCULATION_FAILED
=
1107603
...
...
@@ -151,7 +152,7 @@ class AudioRecorder() {
}
else
{
this
.
filePath
=
null
}
Log
.
d
(
"AudioRecorder"
,
"File path set to:
$filePath"
)
Log
.
i
(
TAG
,
"startRecording: format=$format, saveToFile=$saveToFile, path=
$filePath"
)
// 检测并调整采样率
...
...
@@ -286,6 +287,7 @@ class AudioRecorder() {
}
}
}
catch
(
e
:
IOException
)
{
Log
.
e
(
TAG
,
"write failed: path=$filePath, ${e.message}"
)
notifyError
(
ERROR_FILE_WRITE_FAILED
,
"录音过程中写入文件出错: ${e.message}"
)
}
finally
{
// 清理资源
...
...
@@ -554,6 +556,10 @@ class AudioRecorder() {
}
audioRecord
=
null
val
savedPath
=
filePath
val
fileSize
=
savedPath
?.
let
{
File
(
it
).
takeIf
{
f
->
f
.
exists
()
}
?.
length
()
}
?:
-
1L
Log
.
i
(
TAG
,
"stopRecording: path=$savedPath, size=$fileSize bytes"
)
mainHandler
.
post
{
recordingListener
?.
onRecordingStopped
()
}
...
...
uni_modules/uni-recorder-x/utssdk/app-android/index.uts
View file @
e8ff93d
...
...
@@ -8,6 +8,8 @@ import Base64 from "android.util.Base64";
export { RecorderManagerFailImpl }
const LOG_TAG = '[uni-recorder-x]'
// NOTE 避免被 vue Proxy 污染
const DEFAULT_DURATION = 1000 * 60
const MAX_DURATION = DEFAULT_DURATION * 10
...
...
@@ -75,7 +77,9 @@ class RecorderManagerImpl implements RecorderManager, RecordingListener, AudioDa
this.manager.setRecordingListener(this)
this.manager.setAudioDataListener(this)
this.manager.setMaxRecordingDuration(options.duration!.toLong())
this.manager.startRecording(format, createFile(options.format! as string, options.saveDir))
const filePath = createFile(options.format! as string, options.saveDir)
console.log(`${LOG_TAG} start: format=${options.format}, sampleRate=${options.sampleRate}, channels=${options.numberOfChannels}, filePath=${filePath}`)
this.manager.startRecording(format, filePath)
}
// override pause() : void {
// this.manager.pauseRecording()
...
...
@@ -84,6 +88,7 @@ class RecorderManagerImpl implements RecorderManager, RecordingListener, AudioDa
// this.manager.resumeRecording()
// }
override stop() {
console.log(`${LOG_TAG} stop: filePath=${this.manager.getFilePath()}`)
this.manager.stopRecording()
}
...
...
@@ -151,11 +156,15 @@ class RecorderManagerImpl implements RecorderManager, RecordingListener, AudioDa
// }
override onRecordingStarted() {
let res = new RecorderManagerOnStartResultCallback(this.manager.getFilePath()!)
const filePath = this.manager.getFilePath()!
console.log(`${LOG_TAG} onStart: filePath=${filePath}`)
let res = new RecorderManagerOnStartResultCallback(filePath)
this.startCallback?.(res)
}
override onRecordingStopped() {
this.stopCallback?.(new RecorderManagerOnStopResultCallback(this.manager.getFilePath()!))
const filePath = this.manager.getFilePath()!
console.log(`${LOG_TAG} onStop: filePath=${filePath}`)
this.stopCallback?.(new RecorderManagerOnStopResultCallback(filePath))
}
override onRecordingPaused() {
// this.pauseCallback?.("")
...
...
@@ -164,6 +173,7 @@ class RecorderManagerImpl implements RecorderManager, RecordingListener, AudioDa
// this.resumeCallback?.("")
}
override onRecordingError(errorCode : Int, errorMessage : String) {
console.log(`${LOG_TAG} onError: code=${errorCode}, msg=${errorMessage}`)
var error : IRecorderManagerFail
if ([1107601, 1107602, 1107603, 1107604, 1107605, 1107606, 1107607, 1107608].indexOf(errorCode) >= 0) {
error = new RecorderManagerFailImpl(errorCode, RecorderManagerUniErrors[errorCode]!)
...
...
uni_modules/uni-recorder-x/utssdk/app-android/utils.uts
View file @
e8ff93d
...
...
@@ -11,10 +11,13 @@ export interface StateChangeRes extends RecorderManagerOnStopResult {
export function onRecorderStateChange(state : RecorderState, res ?: StateChangeRes) : void {
}
const LOG_TAG = '[uni-recorder-x]'
export function createFile( format : string, saveDir ?: string | null) : string {
var dirPath : string
if (saveDir != null && saveDir!.length > 0) {
dirPath = saveDir!
console.log(`${LOG_TAG} createFile: 使用自定义目录 saveDir=${saveDir}`)
} else {
let context = UTSAndroid.getAppContext()
var parentPath = UTSAndroid.getAppCachePath()
...
...
@@ -33,6 +36,8 @@ export function createFile( format : string, saveDir ?: string | null) : string
}
const random = UUID.randomUUID().toString().replace(/-/g, '').substring(0, 8)
const fileName = `${Date.now()}_${random}.${format.toLocaleLowerCase()}`
return `${dir.path}/${fileName}`
const filePath = `${dir.path}/${fileName}`
console.log(`${LOG_TAG} createFile: 生成录音文件 path=${filePath}`)
return filePath
}
export const supportFormats = ['aac']
uni_modules/uni-recorder-x/utssdk/app-ios/UniAudioRecorderManager.swift
View file @
e8ff93d
...
...
@@ -67,6 +67,7 @@ typealias UniAudioRecorderErrorEventCallback = (_ result: IRecorderManagerFail)
public
class
UniAudioRecorderManager
:
NSObject
,
RecorderManager
{
public
static
var
shared
=
UniAudioRecorderManager
()
private
let
logTag
=
"[uni-recorder-x]"
private
var
audioRecorder
:
AVAudioRecorder
?
...
...
@@ -150,6 +151,7 @@ public class UniAudioRecorderManager: NSObject, RecorderManager {
public
func
stop
()
{
if
let
isRecording
=
audioRecorder
?
.
isRecording
,
(
isRecording
||
isPaused
)
{
let
savedPath
=
audioRecorder
?
.
url
.
path
??
""
audioRecorder
?
.
stop
()
stopDisplayLink
()
...
...
@@ -157,7 +159,8 @@ public class UniAudioRecorderManager: NSObject, RecorderManager {
result
.
tempFilePath
=
audioRecorder
?
.
url
.
absoluteString
??
""
dispatchStopEvent
(
event
:
.
stop
,
result
:
result
)
print
(
"录音已完成,文件保存在:
\(
audioRecorder
?
.
url
.
absoluteString
??
"未知路径"
)
"
)
let
fileSize
=
(
try
?
FileManager
.
default
.
attributesOfItem
(
atPath
:
savedPath
)[
.
size
]
as?
Int64
)
??
-
1
print
(
"
\(
logTag
)
stop: path=
\(
savedPath
)
, size=
\(
fileSize
)
bytes"
)
audioRecorder
=
nil
}
}
...
...
@@ -292,6 +295,7 @@ extension UniAudioRecorderManager {
]
let
fileURL
=
getAudioRecorderFileURL
()
print
(
"
\(
logTag
)
start: format=
\(
audioFormat
.
rawValue
)
, sampleRate=
\(
sampleRate
)
, channels=
\(
channels
)
, path=
\(
fileURL
.
path
)
"
)
audioRecorder
=
try
AVAudioRecorder
(
url
:
fileURL
,
settings
:
settings
)
audioRecorder
?
.
delegate
=
self
audioRecorder
?
.
isMeteringEnabled
=
true
...
...
@@ -328,7 +332,7 @@ extension UniAudioRecorderManager {
}
catch
{
failedAction
(
1107604
,
errMsg
:
error
.
localizedDescription
)
print
(
"
录音启动失败
:
\(
error
.
localizedDescription
)
"
)
print
(
"
\(
logTag
)
start failed
:
\(
error
.
localizedDescription
)
"
)
}
}
...
...
@@ -363,7 +367,9 @@ extension UniAudioRecorderManager {
}
let
random
=
UUID
()
.
uuidString
.
replacingOccurrences
(
of
:
"-"
,
with
:
""
)
.
prefix
(
8
)
let
fileName
=
Date
()
.
timeIntervalSince1970
.
toString
()
+
"_"
+
random
+
"."
+
suffixName
return
recordPath
.
appendingPathComponent
(
fileName
)
let
fileURL
=
recordPath
.
appendingPathComponent
(
fileName
)
print
(
"
\(
logTag
)
createFile: path=
\(
fileURL
.
path
)
"
)
return
fileURL
}
private
func
ensureDirExist
(
_
path
:
String
)
{
...
...
utils/recordManager/AudioManager.js
View file @
e8ff93d
...
...
@@ -39,6 +39,7 @@ class AudioManager {
onFrameRecordedEnd
,
}
this
.
startOptions
.
saveDir
=
saveDir
uni
.
$logger
.
local
.
info
(
`【接待录音】AudioManager初始化: saveDir=
${
saveDir
}
`
)
}
on
()
{
// 使用策略工厂获取录音管理器实例
...
...
@@ -57,6 +58,7 @@ class AudioManager {
* 此方法用于初始化录音过程,它将配置参数应用到录音管理器,并开始录音
*/
start
()
{
uni
.
$logger
.
local
.
info
(
`【接待录音】开启录音: saveDir=
${
this
.
startOptions
.
saveDir
}
, format=
${
this
.
startOptions
.
format
}
`
)
uni
.
$logger
.
local
.
info
(
'〖录音管理Audio〗 == 开启录音 '
)
this
.
recorderManager
.
start
(
this
.
startOptions
)
}
...
...
@@ -100,6 +102,8 @@ class AudioManager {
* 然后调用events对象上的onStop方法处理具体的停止录音逻辑
*/
async
onStop
(
res
)
{
const
filePath
=
res
?.
tempFilePath
||
res
?.
filePath
||
''
uni
.
$logger
.
local
.
info
(
`【接待录音】停止录音回调: filePath=
${
filePath
}
`
)
uni
.
$logger
.
local
.
info
(
'〖录音管理Audio〗 == 停止录音回调 '
)
await
this
.
events
.
onStop
(
res
)
}
...
...
utils/recordManager/FileUploadManager.js
View file @
e8ff93d
...
...
@@ -187,6 +187,8 @@ class FileUploadManager {
*/
async
uploadRecord
(
record
,
callback
)
{
try
{
const
fullPath
=
(
record
.
filePath
||
''
)
+
(
record
.
fileName
||
''
)
uni
.
$logger
.
local
.
info
(
`【接待录音】上传前: recordId=
${
record
.
recordId
}
, fullPath=
${
fullPath
}
, status=
${
record
.
status
}
`
)
uni
.
$logger
.
local
.
info
(
`[FileUploadManager] 开始上传文件:
${
record
.
fileName
}
`
)
// 处理无文件或文件不存在的情况
if
(
record
.
status
===
FileStatus
.
NoFile
||
record
.
status
===
FileStatus
.
NotExist
)
{
...
...
utils/recordManager/NativeSave.js
View file @
e8ff93d
...
...
@@ -20,11 +20,14 @@ class NativeSave extends TempRecord {
* @returns {Promise<void>}
*/
async
add
(
audio
)
{
const
filePath
=
audio
?.
filePath
||
audio
?.
tempFilePath
||
''
uni
.
$logger
.
local
.
info
(
`【接待录音】NativeSave.add: filePath=
${
filePath
}
`
)
uni
.
$logger
.
local
.
info
(
'〖NativeSave〗 == add called with: '
+
audio
?.
filePath
)
// 创建一个新的记录对象
const
recordUrlList
=
audio
&&
audio
.
filePath
?
[{
file
:
audio
.
filePath
}]
:
[]
// 调用基类通用流程
await
super
.
add
(
recordUrlList
)
uni
.
$logger
.
local
.
info
(
`【接待录音】NativeSave.add完成: recordId=
${
this
.
record
?.
id
},
fileCount
=
$
{
this
.
record
?.
recordUrlList
?.
length
||
0
}
`)
}
}
...
...
utils/recordManager/PollingSave.js
View file @
e8ff93d
...
...
@@ -42,6 +42,7 @@ class PollingSave extends TempRecord {
// 0. 记录旧路径到实例属性,供底层查找时排除
this
.
_excludePath
=
this
.
record
?.
tempFilePath
||
''
uni
.
$logger
.
local
.
info
(
`【接待录音】addAudio开始: recordId=
${
this
.
record
?.
id
||
''
},
excludePath
=
$
{
this
.
_excludePath
}
`)
// 1. 处理旧录音,并获取清理任务 (只更新内存,不更新数据库)
let cleanupTask
...
...
@@ -256,11 +257,11 @@ class PollingSave extends TempRecord {
saveResultPath = saveResult?.savedFilePath
}
if (!saveResultPath) {
uni.$logger.local.error(`【接待录音】持久化失败,路径为空: src=${tempFilePath}`)
uni.$logger.local.error('
〖接待记录
Record
〗
==
保存文件失败,路径为空
')
return
}
// 减少日志输出,仅在调试需要时开启
// uni.$logger.local.info('〖接待记录Record〗 == 保存后的文件路径 saveResultPath ->' + saveResultPath)
uni.$logger.local.info(`【接待录音】持久化临时文件: ${tempFilePath} -> ${saveResultPath}`)
return saveResultPath
} catch (e) {
uni.$logger.local.error('
〖接待记录
Record
〗
==
保存文件异常
:
' + e.message)
...
...
utils/recordManager/RecordSaveService.js
View file @
e8ff93d
...
...
@@ -367,6 +367,7 @@ class RecordSaveService {
const
{
status
,
tempFilePath
,
recordStatus
,
...
record
}
=
data
const
fileList
=
Array
.
isArray
(
record
.
recordUrlList
)
?
record
.
recordUrlList
:
[]
const
isAllCompleted
=
status
===
FileStatus
.
NoFile
||
fileList
.
every
(
i
=>
[
FileStatus
.
Uploaded
,
FileStatus
.
Completed
].
includes
(
i
.
status
))
uni
.
$logger
.
local
.
info
(
`【接待录音】更新记录状态: recordId=
${
record
.
id
}
, isAllCompleted=
${
isAllCompleted
}
, fileCount=
${
fileList
.
length
}
`
)
if
(
isAllCompleted
)
{
await
this
.
_handleCompletedRecord
(
record
,
fileList
)
}
else
{
...
...
@@ -472,6 +473,7 @@ class RecordSaveService {
continue
}
if
(
recordUrlList
.
length
==
0
)
{
uni
.
$logger
.
local
.
warn
(
`【接待录音】记录无语音文件: recordId=
${
cur
.
id
}
`
)
this
.
_addToBlackList
(
cur
.
id
,
'无语音文件'
)
result
.
push
({
status
:
FileStatus
.
NoFile
,
recordId
:
cur
.
id
})
continue
...
...
@@ -485,6 +487,7 @@ class RecordSaveService {
const
file2Up
=
{
...
file
,
recordId
:
cur
.
id
,
fileName
,
filePath
}
const
fileExists
=
await
this
.
checkFileExists
(
file
.
file
)
if
(
!
fileExists
)
{
uni
.
$logger
.
local
.
warn
(
`【接待录音】文件不存在: recordId=
${
cur
.
id
}
, file=
${
file
.
file
}
`
)
this
.
reportError
(
'【接待记录保存服务】 == 记录中有语音文件地址,但是文件不存在'
,
{
record
:
cur
,
file
},
cur
.
id
,
file
.
file
)
file2Up
.
status
=
FileStatus
.
NotExist
}
...
...
@@ -551,6 +554,7 @@ class RecordSaveService {
}
this
.
_taskStartTime
=
Date
.
now
()
this
.
_currentKey
=
this
.
_getTaskKey
(
record
.
recordId
,
record
.
fileName
)
uni
.
$logger
.
local
.
info
(
`【接待录音】开始上传任务: recordId=
${
record
.
recordId
}
, file=
${
record
.
filePath
}${
record
.
fileName
}
, status=
${
record
.
status
}
`
)
try
{
if
(
this
.
_isInBlackList
(
record
.
recordId
))
{
uni
.
$logger
.
local
.
warn
(
`【接待记录保存服务】 == 任务在黑名单中,跳过:
${
this
.
_currentKey
}
`
)
...
...
@@ -655,6 +659,7 @@ class RecordSaveService {
// 从队列取出任务
record
=
this
.
snapshot
.
dequeue
()
uni
.
$logger
.
local
.
info
(
`【接待录音】出队:
${
record
?
`recordId=
${
record
.
recordId
}
, file=
${
record
.
filePath
||
''
}${
record
.
fileName
||
''
}
`
:
'空'
}
`
)
// 执行任务
await
this
.
beginTask
(
record
)
...
...
utils/recordManager/RecordService.js
View file @
e8ff93d
...
...
@@ -44,6 +44,7 @@ class RecordService {
try
{
uni
.
$logger
.
local
.
info
(
'【录音服务RecordService】 == 初始化'
)
const
saveDir
=
await
PathUtils
.
getFilePath
()
uni
.
$logger
.
local
.
info
(
`【接待录音】初始化: saveDir=
${
saveDir
}
`
)
this
.
audioManager
=
new
AudioManager
(
this
.
onAudioStart
.
bind
(
this
),
this
.
onAudioStop
.
bind
(
this
),
this
.
onAudioError
.
bind
(
this
),
this
.
onFrameRecorded
.
bind
(
this
),
this
.
onFrameRecordedEnd
.
bind
(
this
),
saveDir
)
this
.
initDto
()
this
.
record
=
StrategyFactory
.
getSaveStrategy
(
this
.
tempRecord
,
this
.
triggerTempNumber
.
bind
(
this
),
this
.
attributesProvider
.
bind
(
this
))
...
...
@@ -154,6 +155,9 @@ class RecordService {
async
onAudioStart
(
res
)
{
try
{
const
filePath
=
res
?.
filePath
||
res
?.
tempFilePath
||
''
const
recordId
=
this
.
record
?.
currentRecord
?.
id
||
''
uni
.
$logger
.
local
.
info
(
`【接待录音】onAudioStart: counter=
${
this
.
audioManager
.
counter
}
, recordId=
${
recordId
||
'待创建'
}
, filePath=
${
filePath
}
`
)
// 重置帧缓冲池,开始新的录音周期
this
.
framePool
.
reset
()
...
...
@@ -162,6 +166,7 @@ class RecordService {
await
this
.
record
.
add
(
res
)
uni
.
$logger
.
local
.
info
(
'〖RecordService〗 == Record added successfully.'
)
}
else
{
uni
.
$logger
.
local
.
info
(
`【接待录音】续录分段: counter=
${
this
.
audioManager
.
counter
}
, filePath=
${
filePath
}
`
)
this
.
record
.
addAudio
(
res
)
}
// setTimeout(() => {
...
...
@@ -175,9 +180,11 @@ class RecordService {
async
onAudioStop
()
{
if
(
!
this
.
audioManager
)
return
if
(
this
.
audioManager
.
isRecording
)
{
uni
.
$logger
.
local
.
info
(
`【接待录音】录音分段结束,自动续录 counter=
${
this
.
audioManager
.
counter
}
, recordId=
${
this
.
record
?.
currentRecord
?.
id
||
''
}
`)
uni.$logger.local.info('【录音服务RecordService】 == 接待中,再次开启录音! ')
this.audioManager.start()
} else {
uni.$logger.local.info(`
【接待录音】录音停止,不再续录
recordId
=
$
{
this
.
record
?.
currentRecord
?.
id
||
''
}
`)
uni.$logger.local.info('【录音服务RecordService】 == 断开录音! ')
}
}
...
...
@@ -248,6 +255,9 @@ class RecordService {
uni
.
$logger
.
local
.
warn
(
'【录音服务RecordService】 == 未开始接待,不能结束接待! '
)
return
}
const
record
=
this
.
record
?.
currentRecord
const
fileCount
=
record
?.
recordUrlList
?.
length
||
0
uni
.
$logger
.
local
.
info
(
`【接待录音】结束接待: recordId=
${
record
?.
id
||
''
},
fileCount
=
$
{
fileCount
},
isNotSave
=
$
{
isNotSave
}
`)
uni.$logger.local.info('【录音服务RecordService】 == 结束接待! ')
this.stop()
await this._teardownAiClientForReception().catch(() => {})
...
...
@@ -260,6 +270,9 @@ class RecordService {
}
async
saveAndClearRecord
(
isNotSave
=
false
)
{
const
record
=
this
.
record
?.
currentRecord
const
files
=
(
record
?.
recordUrlList
||
[]).
map
(
i
=>
i
.
file
).
join
(
', '
)
uni
.
$logger
.
local
.
info
(
`【接待录音】保存记录: recordId=
${
record
?.
id
||
''
},
files
=
[
$
{
files
}],
isNotSave
=
$
{
isNotSave
}
`)
if (isNotSave) {
//如果不需要保存记录
uni.$logger.local.info('【录音服务RecordService】 == 不保存记录! ')
...
...
@@ -276,6 +289,7 @@ class RecordService {
this.stopAudioRecord()
}
onTimeOut() {
uni.$logger.local.warn(`
【接待录音】闲置超时自动停止
:
recordId
=
$
{
this
.
record
?.
currentRecord
?.
id
||
''
}
`)
store.commit('audio/setReceptionStatus', 0)
this.record.withError()
this.stopAudioRecord()
...
...
@@ -295,7 +309,7 @@ class RecordService {
const useWs = !!wsBase
const transport = useWs ? TransportType.WEBSOCKET : TransportType.HTTP
// HTTP 服务端固定为 /health(可在 AiAssistantBall 内按需覆盖)
const
httpBaseUrl
=
'http
://192.168.3.84:8616
'
const httpBaseUrl = 'http
s://lightmodification.test.glsx.com.cn
'
const client = new NativeChannelClient(
useWs ? { transport } : { transport, baseUrl: httpBaseUrl }
...
...
utils/recordManager/TempRecord.js
View file @
e8ff93d
...
...
@@ -76,6 +76,7 @@ class TempRecord {
try
{
if
(
!
record
)
throw
new
Error
(
'记录对象为空'
)
uni
.
$logger
.
local
.
info
(
'〖接待记录Record〗 == 开始持久化记录 =='
+
JSON
.
stringify
(
record
))
uni
.
$logger
.
local
.
info
(
`【接待录音】转正入库: recordId=
${
record
.
id
}
, fileCount=
${
record
.
recordUrlList
?.
length
||
0
}
`)
uni.$logger.local.info('〖接待记录Record〗 == 更新文件,保存记录!')
// 直接更新原记录,不再插入新记录
await this.dbRecord.updateRecord(toUpdateData, { id: record.id })
...
...
@@ -83,6 +84,7 @@ class TempRecord {
await this.clearLocalRecord(record, false) // 传入 false 表示不删除数据库记录
this.triggerRecordNumChanged()
// 触发轮询开始事件,通知上传管理重新开始轮询
uni.$logger.local.info(`
【接待录音】触发上传轮询
:
recordId
=
$
{
record
.
id
}
`
)
RecordSaveService
.
startPolling
()
}
catch
(
error
)
{
uni
.
$logger
.
local
.
info
(
'〖接待记录Record〗 == 保存记录异常'
+
error
.
message
)
...
...
@@ -96,6 +98,9 @@ class TempRecord {
}
async
save
(
record
=
this
.
record
)
{
const
fileCount
=
record
?.
recordUrlList
?.
length
||
0
const
files
=
(
record
?.
recordUrlList
||
[]).
map
(
i
=>
i
.
file
).
join
(
', '
)
uni
.
$logger
.
local
.
info
(
`【接待录音】TempRecord.save: recordId=
${
record
?.
id
},
fileCount
=
$
{
fileCount
},
files
=
[
$
{
files
}]
`)
await this.beforeSave(record)
return this.__save(record, {})
}
...
...
utils/recordManager/helpler.js
View file @
e8ff93d
...
...
@@ -24,8 +24,13 @@ async function getLatestAudioFilePath(excludePath = '') {
}
const
pathName
=
await
__getAudioPathName
(
excludeName
)
if
(
!
pathName
)
return
''
return
await
__getAudioPath
(
pathName
)
if
(
!
pathName
)
{
uni
.
$logger
.
local
.
warn
(
`【接待录音】未找到录音文件, excludeName=
${
excludeName
}
`
)
return
''
}
const
fullPath
=
await
__getAudioPath
(
pathName
)
uni
.
$logger
.
local
.
info
(
`【接待录音】找到最新录音:
${
fullPath
}
`
)
return
fullPath
}
catch
(
error
)
{
uni
.
$logger
.
local
.
warn
(
'〖接待记录Record〗 == 获取最新录音路径异常: '
+
error
.
message
)
return
''
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment