Merge branch 'dev-3.10' of git.mesalab.cn:nezha/nezha-fronted into dev-3.11

This commit is contained in:
zyh
2024-08-09 16:14:50 +08:00

View File

@@ -530,19 +530,17 @@ function asciiCompute (num, ascii, units, dot = 2, isBits = false) {
} }
num = Number(num) num = Number(num)
if (isBits) { if (isBits) {
num = num / 8 if (num >= 8) {
if (num < 8) { num = num / 8
} else {
return num.toFixed(dot) + ' ' + units[0] return num.toFixed(dot) + ' ' + units[0]
} }
if (num < ascii) {
return num.toFixed(dot) + ' ' + units[1]
}
} }
const SIGN = num > 0 ? 1 : -1 const SIGN = num > 0 ? 1 : -1
num = Math.abs(num) num = Math.abs(num)
let carry = 0 let carry = 0
if (num > 1) { if (num > 1) {
let log = Math.log(num) / Math.log(ascii) const log = Math.log(num) / Math.log(ascii)
carry = Math.floor(log) carry = Math.floor(log)
num = num / Math.pow(ascii, carry) num = num / Math.pow(ascii, carry)
} }
@@ -551,6 +549,9 @@ function asciiCompute (num, ascii, units, dot = 2, isBits = false) {
// carry = parseInt(log) // carry = parseInt(log)
// num = num / Math.pow(ascii, carry) // num = num / Math.pow(ascii, carry)
// } // }
if (isBits) {
carry++
}
if (Number.isInteger(num)) { if (Number.isInteger(num)) {
return num * SIGN + ' ' + units[carry] return num * SIGN + ' ' + units[carry]
} else { } else {