Commit 6f9f6034 by yixinjj

获取日志添加消息回馈

1 parent cc99bb22
import { serializeIfObject } from '@/utils/utils.js'
export default class GetLogListWorker { export default class GetLogListWorker {
constructor() {} constructor() {}
work(deviceId, data, ws) { work(deviceId, data, ws) {
......
import config from '@/config.js' import config from '@/config.js'
import { serializeIfObject } from '@/utils/utils.js' import { serializeIfObject,deepClone } from '@/utils/utils.js'
export default class LogsWorker { export default class LogsWorker {
logFile = null logFile = null
constructor() { constructor() {
this.logFile = uni.$logger.local.logger this.logFile = uni.$logger.local.logger
this.isUploading = false this.isUploading = false
this.files = []
} }
getLogFileList() { getLogFileList() {
return this.logFile.getLogFileList() return this.logFile.getLogFileList()
...@@ -13,11 +14,12 @@ export default class LogsWorker { ...@@ -13,11 +14,12 @@ export default class LogsWorker {
if (this.isUploading) { if (this.isUploading) {
const msg = `日志上传中,请稍后再试!` const msg = `日志上传中,请稍后再试!`
uni.$logger.local.info(msg) uni.$logger.local.info(msg)
// this.ws.send(msg) this.ws.send(msg)
return return
} }
this.isUploading = true this.isUploading = true
const files = this.getLogFileList() const files = this.getLogFileList()
this.files = JSON.stringify(files)
if (files?.length) { if (files?.length) {
files.sort((a, b) => a.name.localeCompare(b.name)) files.sort((a, b) => a.name.localeCompare(b.name))
this.process(files, deviceId) this.process(files, deviceId)
...@@ -29,7 +31,9 @@ export default class LogsWorker { ...@@ -29,7 +31,9 @@ export default class LogsWorker {
await this.post(file, deviceId) await this.post(file, deviceId)
setTimeout(() => this.process(files, deviceId), 500) setTimeout(() => this.process(files, deviceId), 500)
} else { } else {
this.ws.send({ code: 200, msg: `日志上传完成 logs -> ${this.files}`})
this.isUploading = false this.isUploading = false
this.files=[]
} }
} }
post({ name, path }, deviceId) { post({ name, path }, deviceId) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!