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 db74847c
authored
Jul 17, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 录音路径
1 parent
82270ab6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
51 deletions
env.js
init.js
manifest.json
utils/recordManager/PathUtils.js
utils/recordManager/RecordSaveService.js
utils/recordManager/RecordService.js
env.js
View file @
db74847
const
target
=
[
'ip'
,
'dev'
,
'uat'
,
'prod'
,
'beta'
]
const
target
=
[
'ip'
,
'dev'
,
'uat'
,
'prod'
,
'beta'
]
const
index
=
2
const
index
=
3
/**
/**
*
*
0本地
0本地
...
...
init.js
View file @
db74847
...
@@ -75,12 +75,12 @@ uni.signHttpConfig = {
...
@@ -75,12 +75,12 @@ uni.signHttpConfig = {
if
(
error
&&
error
.
errMsg
==
'request:fail'
)
{
if
(
error
&&
error
.
errMsg
==
'request:fail'
)
{
return
uni
.
showToast
({
return
uni
.
showToast
({
title
:
'网络异常'
,
title
:
'网络异常'
,
icon
:
'none'
,
icon
:
'none'
})
})
}
}
uni
.
showToast
({
uni
.
showToast
({
title
:
error
.
msg
||
'业务异常'
,
title
:
error
.
msg
||
'业务异常'
,
icon
:
'none'
,
icon
:
'none'
})
})
},
},
logout
:
config
=>
{
logout
:
config
=>
{
...
@@ -103,15 +103,15 @@ uni.signHttpConfig = {
...
@@ -103,15 +103,15 @@ uni.signHttpConfig = {
if
(
!
uni
.
$dbRecord
)
{
if
(
!
uni
.
$dbRecord
)
{
uni
.
$dbRecord
=
new
DBRecord
()
uni
.
$dbRecord
=
new
DBRecord
()
}
}
uni
.
$storageMergeDone
=
new
Promise
(
resolve
=>
{
//
uni.$storageMergeDone = new Promise(resolve => {
uni
.
$resolveStorageMerge
=
resolve
//
uni.$resolveStorageMerge = resolve
})
//
})
// 导出数据库初始化 Promise,供其他模块等待
// 导出数据库初始化 Promise,供其他模块等待
if
(
!
uni
.
$dbReady
)
{
if
(
!
uni
.
$dbReady
)
{
uni
.
$dbReady
=
(
async
_
=>
{
uni
.
$dbReady
=
(
async
_
=>
{
try
{
try
{
await
uni
.
$dbRecord
.
init
()
await
uni
.
$dbRecord
.
init
()
await
uni
.
$storageMergeDone
//
await uni.$storageMergeDone
uni
.
$logger
.
local
.
info
(
'数据库初始化与路径合并已完成'
)
uni
.
$logger
.
local
.
info
(
'数据库初始化与路径合并已完成'
)
return
true
return
true
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
manifest.json
View file @
db74847
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
"name"
:
"展业助手"
,
"name"
:
"展业助手"
,
"appid"
:
"__UNI__D3BD3DF"
,
"appid"
:
"__UNI__D3BD3DF"
,
"description"
:
""
,
"description"
:
""
,
"versionName"
:
"2.26.
0
"
,
"versionName"
:
"2.26.
1
"
,
"versionCode"
:
226
0
,
"versionCode"
:
226
1
,
"transformPx"
:
false
,
"transformPx"
:
false
,
"sassImplementationName"
:
"node-sass"
,
"sassImplementationName"
:
"node-sass"
,
/*
5
+App特有相关
*/
/*
5
+App特有相关
*/
...
...
utils/recordManager/PathUtils.js
View file @
db74847
...
@@ -28,7 +28,8 @@ class PathUtils {
...
@@ -28,7 +28,8 @@ class PathUtils {
*/
*/
static
join
(...
args
)
{
static
join
(...
args
)
{
if
(
args
.
length
===
0
)
return
''
if
(
args
.
length
===
0
)
return
''
const
parts
=
args
.
map
((
part
,
index
)
=>
{
const
parts
=
args
.
map
((
part
,
index
)
=>
{
if
(
!
part
)
return
''
if
(
!
part
)
return
''
let
str
=
String
(
part
)
let
str
=
String
(
part
)
if
(
index
!==
0
)
{
if
(
index
!==
0
)
{
...
@@ -38,7 +39,8 @@ class PathUtils {
...
@@ -38,7 +39,8 @@ class PathUtils {
str
=
str
.
replace
(
/
\/
+$/
,
''
)
// 去除结尾的斜杠
str
=
str
.
replace
(
/
\/
+$/
,
''
)
// 去除结尾的斜杠
}
}
return
str
return
str
}).
filter
(
p
=>
p
.
length
>
0
)
})
.
filter
(
p
=>
p
.
length
>
0
)
return
parts
.
join
(
'/'
)
return
parts
.
join
(
'/'
)
}
}
...
@@ -58,8 +60,8 @@ class PathUtils {
...
@@ -58,8 +60,8 @@ class PathUtils {
static
getFilePath
()
{
static
getFilePath
()
{
// 1. 优先使用内存缓存,性能最高
// 1. 优先使用内存缓存,性能最高
if
(
this
.
CACHED_ROOT_PATH
)
{
if
(
this
.
CACHED_ROOT_PATH
)
{
uni
.
$logger
?.
local
?.
info
(
`[PathUtils] 命中内存缓存,根路径:
${
this
.
CACHED_ROOT_PATH
}
`
)
;
uni
.
$logger
?.
local
?.
info
(
`[PathUtils] 命中内存缓存,根路径:
${
this
.
CACHED_ROOT_PATH
}
`
)
return
Promise
.
resolve
(
this
.
CACHED_ROOT_PATH
)
;
return
Promise
.
resolve
(
this
.
CACHED_ROOT_PATH
)
}
}
// 2. 尝试读取持久化缓存
// 2. 尝试读取持久化缓存
...
@@ -74,24 +76,38 @@ class PathUtils {
...
@@ -74,24 +76,38 @@ class PathUtils {
// 3. 无缓存,请求原生文件系统API
// 3. 无缓存,请求原生文件系统API
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
plus
)
{
if
(
!
plus
)
{
reject
(
new
Error
(
'plus runtime 未初始化'
))
;
reject
(
new
Error
(
'plus runtime 未初始化'
))
return
;
return
}
}
plus
.
io
.
requestFileSystem
(
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PRIVATE_DOC
,
plus
.
io
.
PRIVATE_DOC
,
(
fs
)
=>
{
fs
=>
{
const
fullPath
=
fs
.
root
.
fullPath
;
const
fullPath
=
fs
.
root
.
fullPath
uni
.
$logger
?.
local
?.
info
(
`[PathUtils] 请求原生API获取根路径:
${
fullPath
}
`
)
;
uni
.
$logger
?.
local
?.
info
(
`[PathUtils] 请求原生API获取根路径:
${
fullPath
}
`
)
// 写入两级缓存
// 写入两级缓存
this
.
CACHED_ROOT_PATH
=
fullPath
;
this
.
CACHED_ROOT_PATH
=
fullPath
uni
.
setStorageSync
(
this
.
ROOT_PATH_CACHE_KEY
,
fullPath
)
;
uni
.
setStorageSync
(
this
.
ROOT_PATH_CACHE_KEY
,
fullPath
)
resolve
(
fullPath
)
;
resolve
(
fullPath
)
},
},
(
error
)
=>
{
error
=>
{
reject
(
new
Error
(
`[PathUtils] 获取文件系统失败:
${
JSON
.
stringify
(
error
)}
`
))
;
reject
(
new
Error
(
`[PathUtils] 获取文件系统失败:
${
JSON
.
stringify
(
error
)}
`
))
}
}
);
)
});
})
}
/**
* 规范化本地文件路径
* - 去掉前后空白
* - 绝对路径优先转成 file:// 形式
* - 已经是 file:// / http(s):// 的路径保持不变
* @param {string} filePath
* @returns {string}
*/
static
normalizeLocalFilePath
(
filePath
)
{
const
rawPath
=
String
(
filePath
||
''
).
trim
()
if
(
!
rawPath
)
return
''
return
rawPath
.
startsWith
(
'/'
)
?
`file://
${
rawPath
}
`
:
rawPath
}
}
/**
/**
...
@@ -139,12 +155,17 @@ class PathUtils {
...
@@ -139,12 +155,17 @@ class PathUtils {
static
ensureDir
(
dirPath
)
{
static
ensureDir
(
dirPath
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// #ifdef APP-PLUS
// #ifdef APP-PLUS
plus
.
io
.
resolveLocalFileSystemURL
(
dirPath
,
entry
=>
{
plus
.
io
.
resolveLocalFileSystemURL
(
dirPath
,
entry
=>
{
resolve
(
entry
.
fullPath
)
resolve
(
entry
.
fullPath
)
},
()
=>
{
},
()
=>
{
// 目录不存在,尝试创建
// 目录不存在,尝试创建
// NativeRecorder 传的是 "_doc/uniapp_save/"
// NativeRecorder 传的是 "_doc/uniapp_save/"
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PRIVATE_DOC
,
fs
=>
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PRIVATE_DOC
,
fs
=>
{
const
root
=
fs
.
root
const
root
=
fs
.
root
let
path
=
dirPath
let
path
=
dirPath
if
(
path
.
startsWith
(
'_doc/'
))
path
=
path
.
substring
(
5
)
if
(
path
.
startsWith
(
'_doc/'
))
path
=
path
.
substring
(
5
)
...
@@ -154,16 +175,27 @@ class PathUtils {
...
@@ -154,16 +175,27 @@ class PathUtils {
resolve
(
entry
.
fullPath
)
resolve
(
entry
.
fullPath
)
return
return
}
}
entry
.
getDirectory
(
folders
[
0
],
{
create
:
true
},
dirEntry
=>
{
entry
.
getDirectory
(
folders
[
0
],
{
create
:
true
},
dirEntry
=>
{
createDir
(
dirEntry
,
folders
.
slice
(
1
))
createDir
(
dirEntry
,
folders
.
slice
(
1
))
},
err
=>
{
},
err
=>
{
reject
(
new
Error
(
'创建目录失败: '
+
err
.
message
))
reject
(
new
Error
(
'创建目录失败: '
+
err
.
message
))
})
}
)
}
}
createDir
(
root
,
path
.
split
(
'/'
).
filter
(
p
=>
p
))
createDir
(
},
err
=>
reject
(
err
))
root
,
})
path
.
split
(
'/'
).
filter
(
p
=>
p
)
)
},
err
=>
reject
(
err
)
)
}
)
// #endif
// #endif
// #ifndef APP-PLUS
// #ifndef APP-PLUS
resolve
(
dirPath
)
resolve
(
dirPath
)
...
...
utils/recordManager/RecordSaveService.js
View file @
db74847
...
@@ -14,6 +14,7 @@ import dayjs from 'dayjs'
...
@@ -14,6 +14,7 @@ import dayjs from 'dayjs'
import
store
from
'@/store'
import
store
from
'@/store'
import
FileUploadManager
from
'./FileUploadManager.js'
import
FileUploadManager
from
'./FileUploadManager.js'
import
{
Command
}
from
'../../ws/constants'
import
{
Command
}
from
'../../ws/constants'
import
PathUtils
from
'./PathUtils.js'
const
UPLOAD_INTERVAL
=
0.5
*
60
*
1000
const
UPLOAD_INTERVAL
=
0.5
*
60
*
1000
/**
/**
...
@@ -49,7 +50,7 @@ class RecordSaveService {
...
@@ -49,7 +50,7 @@ class RecordSaveService {
this
.
stopPolling
=
this
.
stopPolling
.
bind
(
this
)
this
.
stopPolling
=
this
.
stopPolling
.
bind
(
this
)
this
.
startPolling
=
this
.
startPolling
.
bind
(
this
)
this
.
startPolling
=
this
.
startPolling
.
bind
(
this
)
this
.
setInterval
=
this
.
setInterval
.
bind
(
this
)
this
.
setInterval
=
this
.
setInterval
.
bind
(
this
)
this
.
_onStartPolling
=
(
isForce
)
=>
this
.
startPolling
(
!!
isForce
)
this
.
_onStartPolling
=
isForce
=>
this
.
startPolling
(
!!
isForce
)
uni
.
$on
(
Command
.
StartPolling
,
this
.
_onStartPolling
)
uni
.
$on
(
Command
.
StartPolling
,
this
.
_onStartPolling
)
}
}
...
@@ -166,12 +167,7 @@ class RecordSaveService {
...
@@ -166,12 +167,7 @@ class RecordSaveService {
const
{
data
:
d
,
...
o
}
=
payload
const
{
data
:
d
,
...
o
}
=
payload
const
input
=
serializeIfObject
(
o
)
const
input
=
serializeIfObject
(
o
)
uni
.
$logger
.
local
.
warn
(
`【接待记录保存服务】 == 开始文件信息解析->
${
input
}
`
)
uni
.
$logger
.
local
.
warn
(
`【接待记录保存服务】 == 开始文件信息解析->
${
input
}
`
)
if
(
if
(
payload
.
code
===
0
&&
(
payload
.
message
===
'no file'
||
payload
.
status
===
FileStatus
.
NoFile
||
payload
.
status
===
FileStatus
.
NotExist
))
{
payload
.
code
===
0
&&
(
payload
.
message
===
'no file'
||
payload
.
status
===
FileStatus
.
NoFile
||
payload
.
status
===
FileStatus
.
NotExist
)
)
{
return
this
.
_parseNoFileStatus
({
return
this
.
_parseNoFileStatus
({
recordId
:
payload
.
recordId
,
recordId
:
payload
.
recordId
,
fileName
:
payload
.
fileName
,
fileName
:
payload
.
fileName
,
...
@@ -323,7 +319,7 @@ class RecordSaveService {
...
@@ -323,7 +319,7 @@ class RecordSaveService {
try
{
try
{
// 使用 FileUploadManager 上传文件
// 使用 FileUploadManager 上传文件
await
FileUploadManager
.
uploadRecord
(
record
,
(
result
)
=>
{
await
FileUploadManager
.
uploadRecord
(
record
,
result
=>
{
// 处理上传结果
// 处理上传结果
this
.
handleUploadResult
(
result
)
this
.
handleUploadResult
(
result
)
})
})
...
@@ -333,13 +329,15 @@ class RecordSaveService {
...
@@ -333,13 +329,15 @@ class RecordSaveService {
// 构造错误结果
// 构造错误结果
const
errorResult
=
{
const
errorResult
=
{
detail
:
{
detail
:
{
data
:
[{
data
:
[
{
code
:
-
1
,
code
:
-
1
,
message
:
error
.
message
,
message
:
error
.
message
,
recordId
:
record
.
recordId
,
recordId
:
record
.
recordId
,
fileName
:
record
.
fileName
,
fileName
:
record
.
fileName
,
filePath
:
record
.
filePath
filePath
:
record
.
filePath
}]
}
]
}
}
}
}
...
@@ -480,6 +478,7 @@ class RecordSaveService {
...
@@ -480,6 +478,7 @@ class RecordSaveService {
}
}
for
(
const
file
of
recordUrlList
)
{
for
(
const
file
of
recordUrlList
)
{
try
{
try
{
file
.
file
=
PathUtils
.
normalizeLocalFilePath
(
file
.
file
)
if
(
file
.
status
===
FileStatus
.
Uploaded
||
file
.
status
===
FileStatus
.
Completed
)
continue
if
(
file
.
status
===
FileStatus
.
Uploaded
||
file
.
status
===
FileStatus
.
Completed
)
continue
const
aFullPath
=
file
.
file
.
split
(
'/'
)
const
aFullPath
=
file
.
file
.
split
(
'/'
)
const
fileName
=
aFullPath
.
pop
()
const
fileName
=
aFullPath
.
pop
()
...
@@ -510,7 +509,9 @@ class RecordSaveService {
...
@@ -510,7 +509,9 @@ class RecordSaveService {
urlList
=
[]
urlList
=
[]
}
}
// const __list = urlList.filter(item => item?.file)
// const __list = urlList.filter(item => item?.file)
const
__list
=
urlList
.
filter
(
item
=>
item
?.
file
).
map
(
item
=>
{
const
__list
=
urlList
.
filter
(
item
=>
item
?.
file
)
.
map
(
item
=>
{
if
(
/^https
?
:
\/\/
/i
.
test
(
item
.
file
))
{
if
(
/^https
?
:
\/\/
/i
.
test
(
item
.
file
))
{
item
.
status
=
FileStatus
.
Uploaded
item
.
status
=
FileStatus
.
Uploaded
}
}
...
...
utils/recordManager/RecordService.js
View file @
db74847
...
@@ -43,7 +43,9 @@ class RecordService {
...
@@ -43,7 +43,9 @@ class RecordService {
async
init
()
{
async
init
()
{
try
{
try
{
uni
.
$logger
.
local
.
info
(
'【录音服务RecordService】 == 初始化'
)
uni
.
$logger
.
local
.
info
(
'【录音服务RecordService】 == 初始化'
)
const
saveDir
=
await
PathUtils
.
getFilePath
()
// const saveDir = await PathUtils.getFilePath()
const
saveDir
=
''
uni
.
$logger
.
local
.
info
(
`【接待录音】初始化: saveDir=
${
saveDir
}
`
)
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
.
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
.
initDto
()
...
@@ -216,10 +218,10 @@ class RecordService {
...
@@ -216,10 +218,10 @@ class RecordService {
* @param {number} [seconds=30] - 截取最近多少秒,默认 30 秒
* @param {number} [seconds=30] - 截取最近多少秒,默认 30 秒
* @returns {ArrayBuffer|null} PCM / WAV 格式的 ArrayBuffer,失败返回 null
* @returns {ArrayBuffer|null} PCM / WAV 格式的 ArrayBuffer,失败返回 null
*/
*/
captureRecentAudio(seconds = 30,format = 'pcm') {
captureRecentAudio(seconds = 30,
format = 'pcm') {
const status = this.framePool.getStatus()
const status = this.framePool.getStatus()
uni.$logger.local.info(`
【录音服务
RecordService
】
==
截取音频
:
缓冲池状态
$
{
JSON
.
stringify
(
status
)}
`)
uni.$logger.local.info(`
【录音服务
RecordService
】
==
截取音频
:
缓冲池状态
$
{
JSON
.
stringify
(
status
)}
`)
return this.framePool.capture(seconds,
format)
return this.framePool.capture(seconds,
format)
}
}
/**
/**
...
@@ -311,9 +313,7 @@ class RecordService {
...
@@ -311,9 +313,7 @@ class RecordService {
// HTTP 服务端固定为 /health(可在 AiAssistantBall 内按需覆盖)
// HTTP 服务端固定为 /health(可在 AiAssistantBall 内按需覆盖)
const httpBaseUrl = 'https://lightmodification.glsx.com.cn'
const httpBaseUrl = 'https://lightmodification.glsx.com.cn'
const client = new NativeChannelClient(
const client = new NativeChannelClient(useWs ? { transport } : { transport, baseUrl: httpBaseUrl })
useWs ? { transport } : { transport, baseUrl: httpBaseUrl }
)
this._aiClient = client
this._aiClient = client
if (useWs) {
if (useWs) {
...
...
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