Skip to content

Commit

Permalink
Merge pull request #246 from primihub/fe-logfixed
Browse files Browse the repository at this point in the history
fix:Log format compatibility handling
  • Loading branch information
quhaiyue authored Mar 25, 2024
2 parents 3ec1327 + 953d1d8 commit d72655a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion primihub-webconsole/src/components/Log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export default {
clearTimeout(this.serverTimeout)
},
methods: {
// 判断是否为json字符串
isJSONString(str) {
try {
JSON.parse(str)
return true
} catch (e) {
return false
}
},
socketInit() {
console.log('init connectCount', this.connectCount)
if (!this.address) {
Expand Down Expand Up @@ -171,7 +180,9 @@ export default {
}
return item.values
} else {
let log = JSON.parse(item.values[0][1]).log
const valuesStr = item.values[0][1]
// 如果是字符串对象,解析后取log值;如果是普通字符串,直接赋值
let log = this.isJSONString(valuesStr) ? JSON.parse(valuesStr).log : valuesStr
log = log.replace(/\[\d+m/ig, '')
log = log.replace(/\\+/ig, '')
return log
Expand Down

0 comments on commit d72655a

Please sign in to comment.