Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
simgle_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 47d844c0
authored
Dec 22, 2025
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
dde65788
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
116 additions
and
71 deletions
hybrid/html/js/OSSUpLoader.js
mixin/record/recorder.js
mixin/record/uploader.js
mixin/timeout.js
utils/DBManager.js
utils/logger/LocalLog.js
utils/recordManager/AudioManager.js
utils/recordManager/TempRecord.js
utils/recordManager/helpler.js
hybrid/html/js/OSSUpLoader.js
View file @
47d844c
...
@@ -10,7 +10,7 @@ class OSSUpLoader {
...
@@ -10,7 +10,7 @@ class OSSUpLoader {
/**
/**
* 文件的 MIME 类型
* 文件的 MIME 类型
*/
*/
mime
=
'audio/mp
3
'
mime
=
'audio/mp
eg
'
/**
/**
* 本地保存文件路径(待上传文件路径)
* 本地保存文件路径(待上传文件路径)
*/
*/
...
@@ -65,6 +65,7 @@ class OSSUpLoader {
...
@@ -65,6 +65,7 @@ class OSSUpLoader {
*/
*/
retryInterval
=
3
*
1000
retryInterval
=
3
*
1000
currentCheckpoint
currentCheckpoint
lastProgress
=
0
/**
/**
* OSS 存储桶中的目标文件夹路径
* OSS 存储桶中的目标文件夹路径
*/
*/
...
@@ -74,7 +75,7 @@ class OSSUpLoader {
...
@@ -74,7 +75,7 @@ class OSSUpLoader {
*/
*/
constructor
({
region
=
this
.
region
,
bucket
=
this
.
bucket
,
accessKeyId
,
accessKeySecret
,
stsToken
,
mime
=
this
.
mime
,
partSize
=
this
.
partSize
,
parallel
=
this
.
parallel
,
timeout
=
this
.
timeout
,
filePath
,
retryCountMax
=
this
.
retryCountMax
,
retryInterval
=
this
.
retryInterval
,
ossFolder
=
this
.
ossFolder
})
{
constructor
({
region
=
this
.
region
,
bucket
=
this
.
bucket
,
accessKeyId
,
accessKeySecret
,
stsToken
,
mime
=
this
.
mime
,
partSize
=
this
.
partSize
,
parallel
=
this
.
parallel
,
timeout
=
this
.
timeout
,
filePath
,
retryCountMax
=
this
.
retryCountMax
,
retryInterval
=
this
.
retryInterval
,
ossFolder
=
this
.
ossFolder
})
{
if
(
partSize
<
this
.
minPartSize
)
{
if
(
partSize
<
this
.
minPartSize
)
{
throw
new
Error
(
common
.
constants
.
COD
E
.
FILE_PART_SIZE_TOO_SMALL
)
throw
new
Error
(
common
.
constants
.
MESSAG
E
.
FILE_PART_SIZE_TOO_SMALL
)
}
}
this
.
mime
=
mime
this
.
mime
=
mime
this
.
partSize
=
partSize
this
.
partSize
=
partSize
...
@@ -93,6 +94,16 @@ class OSSUpLoader {
...
@@ -93,6 +94,16 @@ class OSSUpLoader {
stsToken
stsToken
})
})
}
}
_normalizeFileName
(
fileName
)
{
let
name
=
String
(
fileName
||
''
)
name
=
name
.
split
(
/
[\/\\]
+/
).
pop
()
name
=
name
.
replace
(
/
\.\.
+/g
,
''
)
name
=
name
.
replace
(
/
[^
a-zA-Z0-9._-
]
/g
,
''
)
if
(
!
name
)
{
name
=
Date
.
now
()
+
'.mp3'
}
return
name
}
/**
/**
* 上传文件到指定的 OSS 存储空间
* 上传文件到指定的 OSS 存储空间
* @param {string} fileName - 要上传的文件名
* @param {string} fileName - 要上传的文件名
...
@@ -100,11 +111,12 @@ class OSSUpLoader {
...
@@ -100,11 +111,12 @@ class OSSUpLoader {
* @throws {Error} 如果文件路径转换失败,将抛出错误
* @throws {Error} 如果文件路径转换失败,将抛出错误
*/
*/
upload
(
fileName
,
callback
)
{
upload
(
fileName
,
callback
)
{
const
safeName
=
this
.
_normalizeFileName
(
fileName
)
this
.
_pathToFile
(
this
.
_pathToFile
(
this
.
filePath
+
fil
eName
,
this
.
filePath
+
saf
eName
,
function
(
result
)
{
function
(
result
)
{
if
(
result
.
code
===
common
.
constants
.
CODE
.
FILE_PATH_TRANSFORM_SUCCESS
)
{
if
(
result
.
code
===
common
.
constants
.
CODE
.
FILE_PATH_TRANSFORM_SUCCESS
)
{
this
.
_upload
(
fil
eName
,
result
.
data
.
file
,
callback
)
this
.
_upload
(
saf
eName
,
result
.
data
.
file
,
callback
)
}
else
{
}
else
{
callback
(
result
)
callback
(
result
)
}
}
...
@@ -127,7 +139,9 @@ class OSSUpLoader {
...
@@ -127,7 +139,9 @@ class OSSUpLoader {
// 获取分片上传进度、断点和返回值。
// 获取分片上传进度、断点和返回值。
progress
:
(
p
,
checkpoint
,
res
)
=>
{
progress
:
(
p
,
checkpoint
,
res
)
=>
{
this
.
currentCheckpoint
=
checkpoint
this
.
currentCheckpoint
=
checkpoint
console
.
log
(
p
)
if
(
p
-
this
.
lastProgress
>=
0.1
||
p
===
1
)
{
this
.
lastProgress
=
p
}
},
},
// 设置并发上传的分片数量。
// 设置并发上传的分片数量。
parallel
:
this
.
parallel
,
parallel
:
this
.
parallel
,
...
@@ -142,6 +156,7 @@ class OSSUpLoader {
...
@@ -142,6 +156,7 @@ class OSSUpLoader {
// console.log('upload success: %j', JSON.stringify(res));
// console.log('upload success: %j', JSON.stringify(res));
this
.
currentCheckpoint
=
null
this
.
currentCheckpoint
=
null
this
.
retryCount
=
0
this
.
retryCount
=
0
this
.
lastProgress
=
0
callback
(
callback
(
common
.
genCallBacks
(
'FILE_UPLOAD_OSS_SUCCESS'
,
{
common
.
genCallBacks
(
'FILE_UPLOAD_OSS_SUCCESS'
,
{
oss
:
res
oss
:
res
...
@@ -150,7 +165,7 @@ class OSSUpLoader {
...
@@ -150,7 +165,7 @@ class OSSUpLoader {
}
else
{
}
else
{
callback
(
callback
(
common
.
genCallBacks
(
'FILE_UPLOAD_OSS_FAIL'
,
{
common
.
genCallBacks
(
'FILE_UPLOAD_OSS_FAIL'
,
{
errMsg
:
`OSS返回错误 状态码:
${
res
.
status
}
`
,
errMsg
:
`OSS返回错误 状态码:
${
res
&&
res
.
res
&&
res
.
res
.
statusCode
?
res
.
res
.
statusCode
:
res
&&
res
.
status
?
res
.
status
:
'unknown'
}
`
,
oss
:
res
oss
:
res
})
})
)
)
...
@@ -205,11 +220,11 @@ class OSSUpLoader {
...
@@ -205,11 +220,11 @@ class OSSUpLoader {
callback
(
common
.
genCallBacks
(
'FILE_PATH_TRANSFORM_FAIL'
))
callback
(
common
.
genCallBacks
(
'FILE_PATH_TRANSFORM_FAIL'
))
}
}
}
}
xhr
.
onerror
=
function
(
e
rrType
,
errMsg
)
{
xhr
.
onerror
=
function
(
e
vent
)
{
callback
(
callback
(
common
.
genCallBacks
(
'FILE_PATH_REQUEST_FAIL'
,
{
common
.
genCallBacks
(
'FILE_PATH_REQUEST_FAIL'
,
{
errType
,
errType
:
event
&&
event
.
type
,
errMsg
errMsg
:
'network error'
})
})
)
)
}
}
...
@@ -222,6 +237,8 @@ class OSSUpLoader {
...
@@ -222,6 +237,8 @@ class OSSUpLoader {
destroy
()
{
destroy
()
{
this
.
retryCount
=
0
this
.
retryCount
=
0
this
.
client
=
null
this
.
client
=
null
this
.
currentCheckpoint
=
null
this
.
lastProgress
=
0
}
}
}
}
...
...
mixin/record/recorder.js
View file @
47d844c
...
@@ -2,13 +2,12 @@
...
@@ -2,13 +2,12 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-26 10:03:54
* @Date: 2024-12-26 10:03:54
* @LastEditors: limin
* @LastEditors: limin
* @LastEditTime: 2025-
08-12 10:32:25
* @LastEditTime: 2025-
12-22 11:02:51
* @FilePath: \
gl_tape
\mixin\record\recorder.js
* @FilePath: \
simgle_app
\mixin\record\recorder.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
import
{
AudioManager
,
TempRecord
,
RecordDto
,
helpler
}
from
'../../utils/recordManager/index'
import
{
AudioManager
,
TempRecord
,
RecordDto
,
helpler
}
from
'../../utils/recordManager/index'
import
{
mapMutations
,
mapState
,
mapGetters
}
from
'vuex'
import
{
mapMutations
,
mapState
,
mapGetters
}
from
'vuex'
import
utils
from
'@/utils/utils.js'
import
{
storageApi
}
from
'@/utils/cache'
import
{
storageApi
}
from
'@/utils/cache'
import
permision
from
'@/js_sdk/wa-permission/permission.js'
import
permision
from
'@/js_sdk/wa-permission/permission.js'
export
default
{
export
default
{
...
@@ -18,7 +17,7 @@ export default {
...
@@ -18,7 +17,7 @@ export default {
}
}
},
},
async
mounted
()
{
async
mounted
()
{
this
.
audioManager
=
new
AudioManager
(
this
.
onAudioStart
,
this
.
onAudioStop
,
this
.
onError
)
this
.
audioManager
=
new
AudioManager
(
this
.
onAudioStart
,
this
.
onAudioStop
,
this
.
on
Audio
Error
)
this
.
initDto
()
this
.
initDto
()
this
.
record
=
new
TempRecord
(
this
.
tempRecord
,
this
.
triggleTempNumber
)
this
.
record
=
new
TempRecord
(
this
.
tempRecord
,
this
.
triggleTempNumber
)
this
.
triggleTempNumber
()
this
.
triggleTempNumber
()
...
@@ -64,14 +63,22 @@ export default {
...
@@ -64,14 +63,22 @@ export default {
...
mapMutations
(
'audio'
,
[
'setReceptionStatus'
,
'setBooks'
,
'setPerRecordNumber'
]),
...
mapMutations
(
'audio'
,
[
'setReceptionStatus'
,
'setBooks'
,
'setPerRecordNumber'
]),
...
mapMutations
([
'clearCustomerInfo'
]),
...
mapMutations
([
'clearCustomerInfo'
]),
//开始录音
//开始录音
startAudio
:
utils
.
throttle
(
async
function
(
isInitData
=
true
)
{
async
startAudio
(
isInitData
=
true
)
{
if
(
this
.
_startAudioPromise
)
return
this
.
_startAudioPromise
this
.
_startAudioPromise
=
(
async
()
=>
{
try
{
const
isPermission
=
await
this
.
checkBeforeStart
()
const
isPermission
=
await
this
.
checkBeforeStart
()
if
(
!
isPermission
)
return
if
(
!
isPermission
)
return
uni
.
$logger
.
local
.
info
(
'〖接待管理Recorder〗 == 开始接待 '
)
uni
.
$logger
.
local
.
info
(
'〖接待管理Recorder〗 == 开始接待 '
)
isInitData
&&
this
.
initReception
()
isInitData
&&
this
.
initReception
()
this
.
initTime
()
this
.
initTime
()
this
.
audioManager
.
start
()
this
.
audioManager
.
start
()
},
300
),
}
finally
{
this
.
_startAudioPromise
=
null
}
})()
return
this
.
_startAudioPromise
},
initReception
()
{
initReception
()
{
this
.
setBooks
([])
this
.
setBooks
([])
...
@@ -105,7 +112,12 @@ export default {
...
@@ -105,7 +112,12 @@ export default {
async
stopAudio
(
isNotSave
=
false
)
{
async
stopAudio
(
isNotSave
=
false
)
{
uni
.
$logger
.
local
.
info
(
'〖接待管理Recorder〗 == 结束接待! '
)
uni
.
$logger
.
local
.
info
(
'〖接待管理Recorder〗 == 结束接待! '
)
this
.
stop
()
this
.
stop
()
try
{
await
this
.
saveAndClearRecord
(
isNotSave
)
await
this
.
saveAndClearRecord
(
isNotSave
)
}
catch
(
error
)
{
uni
.
$logger
.
local
.
error
(
`〖接待管理Recorder〗 == 结束接待保存失败:
${
error
.
message
}
`
)
this
.
reportError
(
'结束接待保存失败'
,
error
.
message
)
}
},
},
async
saveAndClearRecord
(
isNotSave
=
false
)
{
async
saveAndClearRecord
(
isNotSave
=
false
)
{
if
(
isNotSave
)
{
if
(
isNotSave
)
{
...
@@ -136,7 +148,7 @@ export default {
...
@@ -136,7 +148,7 @@ export default {
this
.
tempRecord
=
null
this
.
tempRecord
=
null
},
},
initDto
()
{
initDto
()
{
const
{
shopMerchantId
,
phone
,
sceneType
,
uuid
,
name
,
merchantId
,
channelType
,
merchantName
}
=
storageApi
.
getUserInfo
()
const
{
shopMerchantId
,
phone
,
sceneType
,
uuid
,
name
,
merchantId
,
channelType
,
merchantName
}
=
storageApi
.
getUserInfo
()
||
{}
const
{
deviceId
:
appCode
}
=
uni
.
getDeviceInfo
()
const
{
deviceId
:
appCode
}
=
uni
.
getDeviceInfo
()
const
dto
=
new
RecordDto
({
const
dto
=
new
RecordDto
({
staffUuid
:
uuid
,
staffUuid
:
uuid
,
...
@@ -198,6 +210,7 @@ export default {
...
@@ -198,6 +210,7 @@ export default {
return
this
.
record
return
this
.
record
},
},
async
triggleTempNumber
()
{
async
triggleTempNumber
()
{
if
(
!
this
.
record
)
return
const
_records
=
await
this
.
record
.
getRecords
()
const
_records
=
await
this
.
record
.
getRecords
()
this
.
setPerRecordNumber
(
_records
.
length
)
this
.
setPerRecordNumber
(
_records
.
length
)
},
},
...
...
mixin/record/uploader.js
View file @
47d844c
This diff is collapsed.
Click to expand it.
mixin/timeout.js
View file @
47d844c
/*
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @Date: 2024-04-08 11:28:48
* @LastEditors:
yangming@didihu.com.cn yangming@didihu.com.c
n
* @LastEditors:
limi
n
* @LastEditTime: 2025-
05-21 15:17:55
* @LastEditTime: 2025-
12-19 13:55:50
* @FilePath: \
gl_tape
\mixin\timeout.js
* @FilePath: \
simgle_app
\mixin\timeout.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
const
TIMER_DURATION
=
40
*
60
*
1000
//40分钟
const
TIMER_DURATION
=
40
*
60
*
1000
//40分钟
...
@@ -13,15 +13,23 @@ export default {
...
@@ -13,15 +13,23 @@ export default {
methods
:
{
methods
:
{
//结束提示
//结束提示
stopRecorder
()
{
stopRecorder
()
{
if
(
typeof
this
.
setReceptionStatus
===
'function'
)
{
this
.
setReceptionStatus
(
0
)
this
.
setReceptionStatus
(
0
)
}
if
(
this
.
record
&&
typeof
this
.
record
.
withError
===
'function'
)
{
this
.
record
.
withError
()
this
.
record
.
withError
()
}
if
(
typeof
this
.
stop
===
'function'
)
{
this
.
stop
()
this
.
stop
()
}
uni
.
$logger
.
local
.
info
(
'== 长时间未触碰平板断开录音 =='
)
uni
.
$logger
.
local
.
info
(
'== 长时间未触碰平板断开录音 =='
)
},
},
//监听点击事件
//监听点击事件
initTime
()
{
initTime
()
{
uni
.
$logger
.
local
.
info
(
'== 触碰平板开始计时 =='
)
uni
.
$logger
.
local
.
info
(
'== 触碰平板开始计时 =='
)
this
.
endWatchClick
()
this
.
endWatchClick
()
this
.
__counter
=
0
this
.
__timer
=
null
this
.
__timer
=
setInterval
(()
=>
{
this
.
__timer
=
setInterval
(()
=>
{
if
(
this
.
__counter
>=
TIMER_TIMEOUT
)
{
if
(
this
.
__counter
>=
TIMER_TIMEOUT
)
{
//关闭录音
//关闭录音
...
@@ -37,10 +45,10 @@ export default {
...
@@ -37,10 +45,10 @@ export default {
endWatchClick
()
{
endWatchClick
()
{
if
(
this
.
__timer
)
{
if
(
this
.
__timer
)
{
clearInterval
(
this
.
__timer
)
clearInterval
(
this
.
__timer
)
}
this
.
__timer
=
null
this
.
__timer
=
null
this
.
__counter
=
0
this
.
__counter
=
0
uni
.
$logger
.
local
.
info
(
'== 停止监听未触碰平板事件 == __timer:'
+
this
.
__timer
+
' __counter:'
+
this
.
__counter
)
uni
.
$logger
.
local
.
info
(
'== 停止监听未触碰平板事件 == __timer:'
+
this
.
__timer
+
' __counter:'
+
this
.
__counter
)
}
},
},
handleTouchStart
()
{
handleTouchStart
()
{
if
(
this
.
__counter
>
0
)
{
if
(
this
.
__counter
>
0
)
{
...
@@ -53,5 +61,7 @@ export default {
...
@@ -53,5 +61,7 @@ export default {
if
(
this
.
__timer
)
{
if
(
this
.
__timer
)
{
clearInterval
(
this
.
__timer
)
clearInterval
(
this
.
__timer
)
}
}
this
.
__timer
=
null
this
.
__counter
=
0
}
}
}
}
utils/DBManager.js
View file @
47d844c
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
* @Author: limin
* @Author: limin
* @Date: 2024-11-22 08:18:23
* @Date: 2024-11-22 08:18:23
* @LastEditors: limin
* @LastEditors: limin
* @LastEditTime: 2025-
08-06 00:56:24
* @LastEditTime: 2025-
12-22 11:05:15
* @FilePath: \
gl_tape
\utils\DBManager.js
* @FilePath: \
simgle_app
\utils\DBManager.js
*/
*/
import
{
SQLite
}
from
'../lib'
import
{
SQLite
}
from
'../lib'
/**
/**
...
@@ -34,23 +34,23 @@ class DBManager {
...
@@ -34,23 +34,23 @@ class DBManager {
await
this
.
db
.
init
()
await
this
.
db
.
init
()
}
}
const
isTableExists
=
await
this
.
db
.
isTableExists
(
this
.
table_name
)
const
isTableExists
=
await
this
.
db
.
isTableExists
(
this
.
table_name
)
console
.
log
(
isTableExists
,
'isTableExists'
)
uni
.
$logger
.
info
(
`数据库是否存在isTableExists:
${
isTableExists
}
`
)
uni
.
$logger
.
info
(
`数据库是否存在isTableExists:
${
isTableExists
}
`
)
if
(
!
isTableExists
)
{
if
(
!
isTableExists
)
{
await
this
.
db
.
createTable
(
this
.
table_name
,
this
.
table_columns
)
await
this
.
db
.
createTable
(
this
.
table_name
,
this
.
table_columns
)
}
else
{
//如果存在 判断需要新增的字段是否存在 不存在则添加
const
isColumnExists
=
await
this
.
db
.
isColumnExists
(
this
.
table_name
,
'carBrand'
)
console
.
log
(
isColumnExists
,
'isColumnExists'
)
uni
.
$logger
.
info
(
`字段是否存在isColumnExists:
${
isColumnExists
}
`
)
if
(
!
isColumnExists
)
{
await
this
.
db
.
addColumns
(
this
.
table_name
,
[
{
name
:
'carBrand'
,
definition
:
'TEXT DEFAULT ""'
},
{
name
:
'carBrandId'
,
definition
:
'INTEGER DEFAULT 0'
},
{
name
:
'oneCarBrand'
,
definition
:
'TEXT DEFAULT ""'
},
{
name
:
'oneCarBrandId'
,
definition
:
'INTEGER DEFAULT 0'
}
])
}
}
}
// else { //如果存在 判断需要新增的字段是否存在 不存在则添加
// const isColumnExists = await this.db.isColumnExists(this.table_name, 'carBrand')
// console.log(isColumnExists, 'isColumnExists')
// uni.$logger.info(`字段是否存在isColumnExists: ${isColumnExists}`)
// if (!isColumnExists) {
// await this.db.addColumns(this.table_name, [
// { name: 'carBrand', definition: 'TEXT DEFAULT ""' },
// { name: 'carBrandId', definition: 'INTEGER DEFAULT 0' },
// { name: 'oneCarBrand', definition: 'TEXT DEFAULT ""' },
// { name: 'oneCarBrandId', definition: 'INTEGER DEFAULT 0' }
// ])
// }
// }
return
true
return
true
}
catch
(
error
)
{
}
catch
(
error
)
{
uni
.
$logger
.
error
(
`初始化数据库失败 error - >
${
error
.
message
}
`
)
uni
.
$logger
.
error
(
`初始化数据库失败 error - >
${
error
.
message
}
`
)
...
...
utils/logger/LocalLog.js
View file @
47d844c
...
@@ -5,19 +5,19 @@ class LocalLog {
...
@@ -5,19 +5,19 @@ class LocalLog {
logger
=
null
logger
=
null
constructor
()
{
constructor
()
{
this
.
logger
=
{}
this
.
logger
=
{}
//
this.logger = new LogCat()
this
.
logger
=
new
LogCat
()
}
}
debug
(
msg
)
{
debug
(
msg
)
{
//
this.logger.writeLog(LogLevel.DEBUG, msg)
this
.
logger
.
writeLog
(
LogLevel
.
DEBUG
,
msg
)
}
}
info
(
msg
)
{
info
(
msg
)
{
//
this.logger.writeLog(LogLevel.INFO, msg)
this
.
logger
.
writeLog
(
LogLevel
.
INFO
,
msg
)
}
}
warn
(
msg
)
{
warn
(
msg
)
{
//
this.logger.writeLog(LogLevel.WARN, msg)
this
.
logger
.
writeLog
(
LogLevel
.
WARN
,
msg
)
}
}
error
(
msg
)
{
error
(
msg
)
{
//
this.logger.writeLog(LogLevel.ERROR, msg)
this
.
logger
.
writeLog
(
LogLevel
.
ERROR
,
msg
)
}
}
getFiles
(
beginDate
,
endDate
)
{
getFiles
(
beginDate
,
endDate
)
{
const
logFiles
=
this
.
logger
.
getLogFileList
()
const
logFiles
=
this
.
logger
.
getLogFileList
()
...
...
utils/recordManager/AudioManager.js
View file @
47d844c
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
* @Author: limin
* @Author: limin
* @Date: 2024-12-04 18:17:23
* @Date: 2024-12-04 18:17:23
* @LastEditors: limin
* @LastEditors: limin
* @LastEditTime: 2025-
01-06 18:50:33
* @LastEditTime: 2025-
12-19 16:48:28
* @FilePath: \
gl_tape
\utils\recordManager\AudioManager.js
* @FilePath: \
simgle_app
\utils\recordManager\AudioManager.js
*/
*/
class
AudioManager
{
class
AudioManager
{
startOptions
=
{
startOptions
=
{
duration
:
1
0
*
60
*
1000
,
//默认10分钟
duration
:
1
*
60
*
1000
,
//默认10分钟
sampleRate
:
16000
,
sampleRate
:
16000
,
numberOfChannels
:
1
numberOfChannels
:
1
}
}
...
@@ -121,7 +121,6 @@ class AudioManager {
...
@@ -121,7 +121,6 @@ class AudioManager {
get
counter
()
{
get
counter
()
{
return
this
.
__counter
return
this
.
__counter
}
}
onError
(
err
)
{}
/**
/**
* 重置录音状态
* 重置录音状态
...
...
utils/recordManager/TempRecord.js
View file @
47d844c
This diff is collapsed.
Click to expand it.
utils/recordManager/helpler.js
View file @
47d844c
...
@@ -5,8 +5,14 @@ import utils from '../utils'
...
@@ -5,8 +5,14 @@ import utils from '../utils'
* 此函数调用 `getAudioPathName` 获取文件名,并通过 `getAudioPath` 获取完整路径。
* 此函数调用 `getAudioPathName` 获取文件名,并通过 `getAudioPath` 获取完整路径。
*/
*/
async
function
getLatestAudioFilePath
()
{
async
function
getLatestAudioFilePath
()
{
try
{
const
pathName
=
await
__getAudioPathName
()
const
pathName
=
await
__getAudioPathName
()
return
__getAudioPath
(
pathName
)
if
(
!
pathName
)
return
''
return
await
__getAudioPath
(
pathName
)
}
catch
(
error
)
{
uni
.
$logger
.
local
.
warn
(
'〖接待记录Record〗 == 获取最新录音路径异常: '
+
error
.
message
)
return
''
}
}
}
/**
/**
...
@@ -55,15 +61,27 @@ async function __getLatestFilePath(directoryPath) {
...
@@ -55,15 +61,27 @@ async function __getLatestFilePath(directoryPath) {
return
latestFile
?
directoryPath
+
'/'
+
latestFile
.
name
:
''
return
latestFile
?
directoryPath
+
'/'
+
latestFile
.
name
:
''
}
}
/**
/**
* 获取
指定目录中修改时间最晚的文件
* 获取
文件的元数据
*
*
* @param {string} directoryPath - 目录路径
* @param {object} fileEntry - 文件条目
* @param {string} prefix - 文件名前缀(可选)
* @returns {Promise<object>} - 文件元数据
* @returns {Promise<object|null>} - 修改时间最晚的文件对象或 null
*/
*/
async
function
__getLatestFile
(
directoryPath
,
prefix
=
''
)
{
async
function
__getLatestFile
(
directoryPath
,
prefix
=
''
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// [测试注入] 模拟系统异常:劫持 API 强制失败
const
originalResolve
=
plus
.
io
.
resolveLocalFileSystemURL
plus
.
io
.
resolveLocalFileSystemURL
=
function
(
path
,
success
,
fail
)
{
uni
.
$logger
.
local
.
info
(
`〖接待记录Record〗 == [测试模拟] 拦截目录读取:
${
path
}
`
)
setTimeout
(()
=>
{
fail
&&
fail
({
code
:
12
,
message
:
'Simulated Path Not Found'
})
// 恢复 API,避免影响全局
plus
.
io
.
resolveLocalFileSystemURL
=
originalResolve
},
0
)
}
plus
.
io
.
resolveLocalFileSystemURL
(
plus
.
io
.
resolveLocalFileSystemURL
(
directoryPath
,
directoryPath
,
e
=>
{
e
=>
{
...
@@ -76,30 +94,17 @@ async function __getLatestFile(directoryPath, prefix = '') {
...
@@ -76,30 +94,17 @@ async function __getLatestFile(directoryPath, prefix = '') {
const
latest
=
results
.
reduce
((
acc
,
current
)
=>
(
current
.
modificationTime
>
acc
.
modificationTime
?
current
:
acc
),
{
modificationTime
:
0
})
const
latest
=
results
.
reduce
((
acc
,
current
)
=>
(
current
.
modificationTime
>
acc
.
modificationTime
?
current
:
acc
),
{
modificationTime
:
0
})
resolve
(
latest
.
name
?
latest
:
null
)
resolve
(
latest
.
name
?
latest
:
null
)
},
},
err
=>
reject
(
err
)
err
=>
{
uni
.
$logger
.
local
.
warn
(
`〖接待记录Record〗 == 读取目录项失败:
${
directoryPath
}
, err:
${
JSON
.
stringify
(
err
)}
${
err
.
message
}
`
)
resolve
(
null
)
}
)
)
},
},
err
=>
reject
(
err
)
err
=>
{
)
// 目录不存在或无法访问,视为无文件
})
uni
.
$logger
.
local
.
warn
(
`〖接待记录Record〗 == 目录不存在或无法访问:
${
directoryPath
}
err:
${
JSON
.
stringify
(
err
)}
${
err
.
message
}
`
)
}
resolve
(
null
)
}
/**
* 获取文件的元数据
*
* @param {object} fileEntry - 文件条目
* @returns {Promise<object>} - 文件元数据
*/
async
function
__getFileMetadata
(
fileEntry
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fileEntry
.
getMetadata
(
metadata
=>
{
resolve
({
name
:
fileEntry
.
name
,
modificationTime
:
new
Date
(
metadata
.
modificationTime
).
getTime
()
})
},
err
=>
reject
(
err
)
)
)
})
})
}
}
...
@@ -110,3 +115,4 @@ export default {
...
@@ -110,3 +115,4 @@ export default {
getLatestAudioFilePath
,
getLatestAudioFilePath
,
sleep
sleep
}
}
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