Commit 9d3401d8 by liimin

feat(record): 优化录音管理逻辑并增强日志记录能力

- 移除冗余的 mixin 文件 `merge.js` 和 `storge.js`,相关功能已整合或废弃
- 更新 `recorder.js` 中 stop 方法的安全调用方式,避免潜在的未定义错误
- 修复 `uploader.js` 中 snapshot 判断条件,提升上传流程稳定性
- 改进 `LogCat.js` 日志写入机制,增加对 Error 对象及 undefined 的处理兼容性
- 强化 `RemoteLog.js` 上报信息内容,补充设备品牌、型号等上下文数据
- 在 `TempRecord.js` 中新增组件销毁控制与安全检查,防止内存泄漏和无效操作
- 调整部分工具函数执行逻辑,提高代码健壮性和可维护性
1 parent b609a718
import { storageApi } from '@/utils/cache'
export default {
mounted() {
this.mergeRecord()
this.clearPrevFile()
},
methods: {
deleteDirectory(dirPath) {
const _this = this
plus.io.resolveLocalFileSystemURL(
dirPath,
function (entry) {
if (entry.isDirectory) {
const directoryReader = entry.createReader()
directoryReader.readEntries(
function (entries) {
if (entries.length === 0) {
// 如果目录为空,直接删除
entry.remove(
function () {
console.log('目录删除成功:', dirPath)
uni.$logger.local.info(`目录删除成功: ->${dirPath}`)
},
function (e) {
console.log('目录删除失败:', e.message)
uni.$logger.local.info(`目录删除失败: ->${dirPath} ->${e.message}`)
}
)
} else {
// 递归删除子文件和子目录
let deleteCount = 0
const totalEntries = entries.length
function processNextEntry() {
if (deleteCount >= totalEntries) {
// 所有条目处理完毕,尝试删除当前目录
entry.remove(
function () {
console.log('目录删除成功:', dirPath)
uni.$logger.local.info(`目录删除成功: ->${dirPath}`)
},
function (e) {
console.log('目录删除失败:', e.message)
uni.$logger.local.info(`目录删除失败: ->${dirPath} ->${e.message}`)
}
)
return
}
const entry = entries[deleteCount]
entry.getMetadata(
function (metadata) {
if (entry.isFile) {
// 删除文件
entry.remove(
function () {
console.log('文件删除成功:', entry.fullPath)
uni.$logger.local.info(`文件删除成功: ->${entry.fullPath}`)
deleteCount++
processNextEntry() // 处理下一个条目
},
function (e) {
console.log('文件删除失败:', e.message)
uni.$logger.local.info(`文件删除失败: ->${entry.fullPath} ->${e.message}`)
deleteCount++
processNextEntry() // 处理下一个条目
}
)
} else if (entry.isDirectory) {
// 递归删除子目录
_this.deleteDirectory(entry.fullPath)
deleteCount++
processNextEntry() // 处理下一个条目
}
},
function (e) {
console.log('获取元数据失败:', e.message)
deleteCount++
processNextEntry() // 处理下一个条目
}
)
}
// 开始处理第一个条目
processNextEntry()
}
},
function (e) {
console.log('读取目录内容失败:', e.message)
uni.$logger.local.info(`读取目录内容失败: ->${e.message}`)
}
)
} else {
console.log('路径不是目录:', dirPath)
uni.$logger.local.info(`路径不是目录: ->${dirPath}`)
}
},
function (e) {
console.log('无法访问目录:', e.message)
uni.$logger.local.info(`无法访问目录: ->${dirPath}`)
}
)
},
clearPrevFile() {
let version = plus.runtime.version
let clearVersion = uni.$storage.get('clearVersion')
if (clearVersion != version) {
const wwwPath = plus.io.convertLocalFileSystemURL('doc')
// const filesPath = wwwPath.replace(/apps.+/, 'apps/')
// console.log(filesPath)
const filesPath = wwwPath.replace(/gltap.+/, 'gltap/')
this.getDirectoryContents(filesPath)
}
setTimeout(() => {
uni.$storage.set('clearVersion', version)
}, 5000)
},
getDirectoryContents(dirPath) {
// 解析目录路径
const _this = this
const excludeFile = ['databases']
plus.io.resolveLocalFileSystemURL(
dirPath,
function (entry) {
// 创建 DirectoryReader
const directoryReader = entry.createReader()
// 读取目录内容
directoryReader.readEntries(
function (entries) {
console.log('目录内容读取成功:')
_this.directoryList = entries
entries.forEach(function (entry) {
console.log('文件路径:', entry.fullPath)
if (!excludeFile.includes(entry.name)) {
_this.deleteDirectory(entry.fullPath)
}
})
},
function (e) {
console.log('读取目录内容失败:', e.message)
}
)
},
function (e) {
console.log('无法访问目录:', e.message)
}
)
},
async mergeRecord() {
try {
const tempRecords = storageApi.getRecords('preRecordList') || []
uni.$logger.local.info(`获取待合并记录${JSON.stringify(tempRecords)}`)
for (let i = 0; i < tempRecords.length; i++) {
tempRecords[i].recordUrlList.forEach(record => {
record.file = record.file.split('/').pop()
})
uni.$logger.local.info(`合并记录${JSON.stringify(tempRecords[i])}`)
this.record.addRecord(tempRecords[i])
}
storageApi.removeRecords('preRecordList')
} catch (error) {
uni.$logger.error(`【合并异常】 ${JSON.stringify(error?.message)}`)
}
}
}
}
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-26 10:03:54
* @LastEditors: limin
* @LastEditTime: 2025-12-22 11:02:51
* @LastEditTime: 2025-12-22 19:07:50
* @FilePath: \simgle_app\mixin\record\recorder.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -131,11 +131,9 @@ export default {
await this.record.save()
},
stop() {
this.endWatchClick()
this.record.clearLoopTimer()
if (this.audioManager.isRecording) {
this.audioManager.stop()
}
this.endWatchClick?.()
this.record?.destroy()
this.audioManager?.stop()
},
handler(params, fn) {
if (this.audioManager.isRecording || this.record?.currentRecord?.endReasonType == 1) {
......
......@@ -712,7 +712,6 @@ export default {
await this.waitting()
return
}
if (this.snapshot === null) return
if (!this.snapshot || this.snapshot.size === 0) {
await this.enQueue()
await this.waitting()
......@@ -759,6 +758,7 @@ export default {
return false
},
_scheduleNext(ms = 0) {
if(this.snapshot === null) return
if (this._pumpTimer) {
clearTimeout(this._pumpTimer)
this._pumpTimer = null
......
const UPLOAD_STATUS = {
// 上传状态
success: 1,
fail: 2,
};
let wv, getResult;
import { uploadFile, getOssToken } from "@/utils/ossUploadFile/uploadFile.js";
import config from "@/config.js";
export default {
onLoad() {},
mounted() {
// console.log(JSON.stringify(this))
var currentWebview = this.$parent.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
setTimeout(function () {
wv = currentWebview.children()[0];
wv.setStyle({ top: "100%", height: 300 });
}, 1000); //如果是页面初始化调用时,需要延时一下
// console.log(88);
// // this.checkRecord();
// setTimeout(() => {
// this.checkRecord();
// }, 1000 * 6);
},
methods: {
handlerMessage(result) {
console.log(result);
getResult = result;
},
checkRecord() {
uni.$isNetWork().then(async (res) => {
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
for (let i = 0; i < recordList.length; i++) {
try {
await this.handleRerord(recordList[i]);
} catch (error) {
continue;
}
}
});
},
getFilePath() {
return new Promise((resolve) => {
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
resolve(fs.root.fullPath);
});
});
},
setTimeoutResult() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(getResult);
}, 1000);
});
},
/**上传记录*/
async handleRerord(val) {
let recordUrlList = val.recordUrlList;
// 上传失败的记录
for (let i of recordUrlList) {
console.log(i.status == UPLOAD_STATUS.fail);
if (i.status == UPLOAD_STATUS.fail) {
const filePath = i.file.split("/").pop();
const { lsaccessKeySecret, securityToken, lsaccessKeyId } =
await getOssToken();
console.log(lsaccessKeySecret, securityToken, lsaccessKeyId);
const rootPath = await this.getFilePath();
wv.evalJS(
`msgFromUniapp('${lsaccessKeyId}','${lsaccessKeySecret}','${securityToken}','${filePath}','file://${rootPath}uniapp_save/')`
);
for (let k = 0; k < 100; k++) {
const result = await this.setTimeoutResult();
if (result) {
if (result.detail.data[0].code == 0) {
uni.removeSavedFile({
filePath: i.file,
complete: function (res) {
console.log(res);
},
});
i.status = UPLOAD_STATUS.success;
i.file = config.OSS_DOMAIN + "/" + config.FOLDER + filePath;
} else {
this.sendSentry(result.detail.data[0].error);
throw "上传失败";
}
getResult = "";
break;
}
}
// const result = await this.checkFileUpload(filePath);
// if (!(result instanceof Error)) {
// i.status = UPLOAD_STATUS.success;
// i.file = result;
// }
}
}
//目前处于保存中
if (uni.$lock) {
return;
}
// 判断是否全部上传成功
if (recordUrlList.every((i) => i.status == UPLOAD_STATUS.success)) {
val.recordUrlList = val.recordUrlList.map((i) => i.file);
try {
await uni.$api.commonApi.saveRecCustomer(val).then((res) => {
console.log(res);
});
let recordList = JSON.parse(uni.$storage.get("recordList") || "[]");
let idx = recordList.findIndex(
(item) => item.receptionStartTime == val.receptionStartTime
);
recordList.splice(idx, 1);
uni.$storage.set("recordList", JSON.stringify(recordList));
} catch (err) {
Promise.reject(error);
}
}
},
sendSentry(msg) {
const { customerName, phoneNumber, carModel, staffName } =
this.$store.state.user.customerInfo;
const { name } = uni.$storage.get("userInfo");
this.$sendSentry(
`上传失败:手机号-${phoneNumber} 姓名-${customerName} 销售-${staffName} 车型-${carModel} 员工-${name},失败原因-${msg}`
);
},
async checkFileUpload(tempFilePath) {
console.log(tempFilePath);
let attempt = 0;
let errorMsg = "";
while (attempt < 2) {
try {
const result = await uploadFile(tempFilePath);
// 上传成功
return result;
} catch (error) {
errorMsg = error;
attempt++;
// 等待一段时间后重试
await new Promise((resolve) => setTimeout(resolve, 3000)); // 3秒后重试
}
}
// 达到最大尝试次数后,如果上传仍然失败,可以进行相应的处理
console.error("上传失败,达到最大尝试次数");
// 返回一个错误或者进行其他操作
return new Error(errorMsg);
},
},
};
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2024-07-01 09:40:48
* @LastEditors: limin
* @LastEditTime: 2025-01-06 09:37:09
* @FilePath: \gl_tape\utils\RecordManager.js
*/
import { storageApi } from './cache'
import utils from './utils'
/**
* 记录管理器类
* 用于管理记录列表
*/
class RecordManager {
/**
* RecordManager 类的构造函数
* 用于初始化 RecordManager 实例
*/
constructor() {
// storageApi.removeRecords('preRecord')
// this.fileSaveFolderOnClient = utils.getFileSaveFolderOnClient();
}
// 单例模式
static instance = null
// 读写锁
locker = false
/**
* 获取 RecordManager 的单例实例
* 如果 instance 不存在,则创建一个新实例并赋值给 instance
* @return {RecordManager} RecordManager 的单例实例
*/
static getInstance() {
if (!RecordManager.instance) {
RecordManager.instance = new RecordManager()
}
return RecordManager.instance
}
/**
* 异步获取锁
* 如果锁已被占用,则在一段时间后重新尝试获取锁
* 如果成功获取锁,将返回一个 Promise,该 Promise 包含一个解锁函数。
* @return {Promise} 一个 Promise,在锁可用时兑现,并返回一个解锁函数
*/
async lock() {
return new Promise(resolve => {
if (this.locker) {
setTimeout(() => {
this.lock()
}, 100)
} else {
this.locker = true
resolve(this.unlock.bind(this))
}
})
}
/**
* 释放本地存储的读写锁
*/
unlock() {
this.locker = false
}
/**
* 将一条新记录添加到当前对象的记录列表中
*
* @param {Object} record - 要添加的新记录对象
* @returns {Array} - 包含新记录的更新后的记录列表
*/
async addRecord(record, key) {
const records = this.getRecords(key) || []
records.push(record)
this.setRecords(records, key)
return records
}
/**
* 移除一个ID对应的记录
*
* @param {number} id - 要移除的记录的ID
* @returns {Array} - 移除记录后的更新后的记录列表
*/
async removeRecord(id, key) {
let records = this.getRecords(key)
records = records.filter(i => i.id !== id)
this.setRecords(records, key)
return records
}
/**
* 获取并移除当前对象记录列表中的最后一条记录
*
* @returns {Object} - 被移除的最后一条记录对象,如果记录列表为空,则返回 undefined
*/
getRecord(key) {
const records = this.getRecords(key)
return records.pop()
}
/**
* 根据给定的 ID 获取一条记录
*
* @param {number} id - 要获取的记录的 ID
* @returns {Object} - 具有给定 ID 的记录对象,如果没有找到符合条件的记录,则返回 undefined
*
*/
getRecordById(id, key) {
const records = this.getRecords(key)
return records.find(i => i.id === id)
}
/**
* 获取记录列表
*
* @returns {Array} - 从 storageApi 获取的记录列表
*/
getRecords(key) {
return storageApi.getRecords(key) || []
}
/**
* 设置记录列表
*
* @param {Array} records - 要设置的记录列表
* @returns {void} - 此函数不返回任何值
*/
setRecords(records, key) {
storageApi.setRecords(records, key)
}
/**
* 更新记录数组中的记录
* 这个函数用于更新给定记录数组中的特定记录
* 它接受一个参数 record,该参数是要更新的记录对象
*
* @param {Object} record - 要更新的记录对象,必须包含一个唯一的 id 属性
* @throws {Error} 如果记录数组中找不到具有给定 id 的记录,将抛出错误
*/
updateRecord(record, key) {
const records = this.getRecords(key)
const index = records.findIndex(i => i.id === record.id)
if (index !== -1) {
records[index] = record
this.setRecords(records, key)
}
}
/**
* 兼容模式的异步处理函数
* 这个函数用于处理在兼容模式下的文件路径转换和记录属性的修正
* 它首先获取一个锁,以确保在操作过程中数据的一致性
* 然后,它获取客户端文件保存文件夹的路径,并检查是否获取成功
* 接着,它获取所有的记录,并对每个记录执行以下操作:
* - 检查记录的 recordUrlList 是否存在且不为空,对于每个 URL,判断其是否以 'file://' 开头
* - 如果不是,使用路径中的文件名构建一个新的客户端文件路径,并替换掉原来的 URL
* - 如果记录没有 id 属性,随机生成一个 UUID 并设置为记录的 id
*
* 在处理过程中,如果发生任何错误,它将抛出该错误
* 无论成功或失败,最终都会执行 finally 块中的代码。这里首先释放记录锁,然后调用 polling 方法,可能是为了继续下一次文件上传。
*
* @async
* @throws {Error} 如果获取记录失败或发生任何其他错误,将抛出错误
*/
async compatible() {
const unlock = await this.lock()
let path = await utils.getFileSaveFolderOnClient()
try {
let records = this.getRecords()
if (typeof records === 'string') {
records = JSON.parse(records)
}
records.forEach(i => {
if (i.recordUrlList && i.recordUrlList.length) {
i.recordUrlList.forEach(async j => {
if (!j.file.startsWith('file://') && !j.file.startsWith('http')) {
const fileName = j.file.split('/').pop()
j.file = path + fileName
}
})
}
if (!i.id) {
i.id = utils.uuid()
}
})
this.setRecords(records)
} catch (e) {
throw e
} finally {
unlock()
}
}
/**
* 清除所有记录
*
* @returns {void} - 此函数不返回任何值
*/
clearRecords() {
storageApi.removeRecords()
}
}
export default RecordManager
......@@ -20,14 +20,30 @@ class LogCat {
console.log('日志文件存放路径->', this.LogPath)
}
writeLog(tag, messages) {
let msg = serializeIfObject(messages)
let msg = ''
try {
if (messages instanceof Error) {
msg = messages.stack || messages.message
} else if (messages === undefined) {
msg = 'undefined'
} else {
msg = serializeIfObject(messages)
}
} catch (e) {
msg = String(messages)
}
let date = getTime('YYYY-MM-DD')
let datetime = getTime()
//文件名
let fileName = this.LogPath + '/' + date + '.txt'
//写入的内容
let content = `${datetime} [${tag}] : ${msg}\n`
console.log(content.replace(/\n/g, ''))
// 使用对应的 console 方法输出
const logFunc = console[tag] || console.log
logFunc(content.replace(/\n/g, ''))
let path = new this.File(this.LogPath)
if (!path.exists()) {
path.mkdirs() //创建父路径
......
......@@ -20,10 +20,31 @@ class RemoteLog {
}
send(level, { extra = {}, msg, tag = { key: '', value: '' } }) {
this.sentry.withScope(scope => {
scope.setTags(tag.key, tag.value)
if (tag && tag.key) {
scope.setTag(tag.key, tag.value)
}
// 记录更多上下文信息
scope.setExtra(RemoteExtraDataKey, extra)
scope.setLevel(level)
this.sentry.captureException(new Error(msg))
// 添加设备信息到 extra
try {
const systemInfo = uni.getSystemInfoSync()
scope.setExtra('device_brand', systemInfo.brand)
scope.setExtra('device_model', systemInfo.model)
scope.setExtra('os_version', systemInfo.system)
scope.setExtra('app_version', systemInfo.appVersion)
} catch (e) {
// 忽略获取设备信息失败
}
// 区分 Error 对象和普通消息
if (msg instanceof Error) {
this.sentry.captureException(msg)
} else {
this.sentry.captureMessage(String(msg))
}
})
}
}
......
import config from './ossUploadFile/config.js'
import base64 from './ossUploadFile/base64.js'
import Hmac from './ossUploadFile/hmac.js'
import Sha1 from './ossUploadFile/sha1.js'
import Crypto from './ossUploadFile/crypto.js'
/**
* 上传文件到阿里云oss
* @param {string} file 图片信息
* @param {string} dir 表示要传到哪个目录下
* @return 完整的图片地址
*/
const uploadFile = function (file, filePath) {
console.log('上传文件到阿里云oss', file, filePath)
return new Promise(async (resolve, reject) => {
// 添加文件大小限制检查
if (file && file.size) {
// 定义文件类型和大小限制
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
const videoTypes = ['mp4', 'avi', 'mov', 'wmv', 'flv', 'mkv']
// 提取文件后缀
const fileExtension = file ? (file.name ? file.name.split('.').pop().toLowerCase() : file.path.split('.').pop().toLowerCase()) : filePath.split('.').pop().toLowerCase()
// 检查文件大小
const fileSizeMB = file.size / (1024 * 1024) // 转换为MB
// 图片文件大小限制10MB
if (imageTypes.includes(fileExtension) && fileSizeMB > 10) {
uni.showToast({
title: '图片上传最大10MB',
icon: 'none'
})
reject(new Error('图片上传最大10MB'))
return
}
// 视频文件大小限制100MB
if (videoTypes.includes(fileExtension) && fileSizeMB > 100) {
uni.showToast({
title: '视频上传最大100MB',
icon: 'none'
})
reject(new Error('视频上传最大100MB'))
return
}
}
// 提取文件后缀
const fileExtension = file ? (file.name ? file.name.split('.').pop().toLowerCase() : file.path.split('.').pop().toLowerCase()) : filePath.split('.').pop().toLowerCase()
// 生成随机数(使用时间戳+随机字符串)
const timestamp = Date.now()
const randomStr = Math.random().toString(36).substring(2, 10)
const randomNum = timestamp + '_' + randomStr
let aliyunFileKey = config.folder + randomNum + '.' + fileExtension
console.log(aliyunFileKey, 'aliyunFileKey')
const aliyunServerURL = config.uploadUrl // OSS地址
const policyBase64 = getPolicyBase64()
const { signature, securityToken, lsaccessKeyId } = await getSignature(policyBase64) // 获取签名
uni.uploadFile({
url: aliyunServerURL, // 开发者服务器url
filePath: filePath, // 要上传文件资源的路径
name: 'file', // 必须填file
formData: {
key: aliyunFileKey,
policy: policyBase64,
OSSAccessKeyId: lsaccessKeyId,
success_action_status: '200', // 让服务端返回200, 不然默认会返回204
signature: signature,
'x-oss-security-token': securityToken // 使用STS签名时必传。
},
success: function (res) {
console.log(res, 444)
if (res.statusCode != 200) {
reject(
new Error(
'上传错误:' +
JSON.stringify({
statusCode: res.statusCode,
file: file,
key: aliyunFileKey,
policy: policyBase64,
OSSAccessKeyId: lsaccessKeyId,
signature: signature,
'x-oss-security-token': securityToken
})
)
)
} else {
uni.removeSavedFile({
file: file,
complete: function (res) {
console.log(res)
}
})
}
resolve(aliyunServerURL + aliyunFileKey)
},
fail: function (err) {
console.log(err, 555)
err.domainName = aliyunServerURL
reject(err)
}
})
})
}
const getPolicyBase64 = function () {
let date = new Date()
date.setHours(date.getHours() + config.timeout)
let srcT = date.toISOString()
const policyText = {
expiration: srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
conditions: [
['content-length-range', 0, 1024 * 1024 * 1024] // 设置上传文件的大小限制(5m)
]
}
const policyBase64 = base64.encode(JSON.stringify(policyText))
return policyBase64
}
const getOssToken = async function () {
console.log('getOssToken')
const { lsaccessKeySecret, securityToken, lsaccessKeyId } = await uni.$api.commonApi.getToken({})
return {
lsaccessKeySecret,
securityToken,
lsaccessKeyId
}
}
// 生成签名
const getSignature = function (policyBase64) {
return new Promise(async reslove => {
const result = uni.$api.commonApi.getToken({}).then(res => {
const { lsaccessKeySecret, securityToken, lsaccessKeyId } = res
const bytes = Crypto.HmacSHA1(policyBase64, lsaccessKeySecret)
const signature = Crypto.enc.Base64.stringify(bytes)
reslove({
signature,
securityToken,
lsaccessKeyId
})
})
})
}
module.exports = { uploadFile }
......@@ -4,7 +4,7 @@
* @Author: limin
* @Date: 2025-01-02 18:49:17
* @LastEditors: limin
* @LastEditTime: 2025-12-19 19:07:49
* @LastEditTime: 2025-12-22 19:10:04
* @FilePath: \simgle_app\utils\recordManager\TempRecord.js
*/
import utils from '../utils'
......@@ -264,7 +264,7 @@ class TempRecord {
async addNewAudioAndUpdate() {
await this.addNewAudio()
// 只有在内存中成功添加了录音路径,才去更新数据库
if (this.record.tempFilePath) {
if (this.record?.tempFilePath) {
await this.updatePath()
uni.$logger.local.info('〖接待记录Record〗 == 同步数据库路径成功 id: ' + this.record.id)
}
......@@ -285,7 +285,7 @@ class TempRecord {
}
uni.$logger.local.info('〖接待记录Record〗 == 添加一个新的录音' + lastAudio)
const savedPath = await this.saveFilePath(lastAudio)
if (savedPath) {
if (savedPath && this.record) {
this.record.tempFilePath = lastAudio
const last = this.record.recordUrlList[this.record.recordUrlList.length - 1]
if (last && last.file === savedPath) {
......@@ -439,9 +439,20 @@ class TempRecord {
uni.$logger.local.info('〖接待记录Record〗 == 轮询已启动,跳过')
return
}
if(this._isDestroyed) {
uni.$logger.local.warn('〖接待记录Record〗 == 组件已销毁,忽略 startSaveAudioLoop')
return
}
uni.$logger.local.info('〖接待记录Record〗 == 启动轮询 ' + this.timer_interval + 'ms')
this.timer = setInterval(this.saveLastAudio.bind(this), this.timer_interval)
}
async destroy() {
this._isDestroyed = true
this.clearLoopTimer()
await this.clearLocalRecord()
uni.$logger.local.info('〖接待记录Record〗 == TempRecord 实例已销毁')
}
/**
* 停止保存轮询并清理定时器句柄
* @returns {void}
......@@ -449,9 +460,11 @@ class TempRecord {
clearLoopTimer() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
uni.$logger.local.info('〖接待记录Record〗 == 停止轮询 (定时器已清除)')
} else {
uni.$logger.local.info('〖接待记录Record〗 == 停止轮询 (无定时器)')
}
this.timer = null
uni.$logger.local.info('〖接待记录Record〗 == 停止轮询')
}
/**
......
......@@ -106,7 +106,6 @@ async function __getLatestFile(directoryPath, prefix = '') {
// plus.io.resolveLocalFileSystemURL = originalResolve
// }, 0)
// }
plus.io.resolveLocalFileSystemURL(
directoryPath,
e => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!