Merge remote-tracking branch 'origin/dev-3.1' into dev-3.1.1_theme

# Conflicts:
#	nezha-fronted/src/components/common/alert/alertLabel.vue
#	nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue
#	nezha-fronted/src/components/common/i18n.js
#	nezha-fronted/src/components/common/labelFilter/clickSearch.vue
#	nezha-fronted/src/components/common/login.vue
#	nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue
This commit is contained in:
chenjinsong
2021-11-04 14:49:40 +08:00
53 changed files with 1140 additions and 238 deletions

View File

@@ -294,6 +294,15 @@ export function stringTimeParseToUnix (stringTime) {
time = time + localOffset - offset * 60 * 60 * 1000
return parseInt(time / 1000)
}
export function stringTimeParseToUnixMs (stringTime) {
let time = new Date(stringTime).getTime()
let offset = localStorage.getItem('nz-sys-timezone')
offset = moment.tz(offset).format('Z')
offset = Number.parseInt(offset)
const localOffset = new Date().getTimezoneOffset() * 60 * 1000 * -1 // 默认 一分钟显示时区偏移的结果
time = time + localOffset - offset * 60 * 60 * 1000
return parseInt(time)
}
export function getTime (size, unit) { // 计算时间
const now = new Date(bus.computeTimezone(new Date().getTime()))
if (unit) {
@@ -361,6 +370,28 @@ export function calcDurationByStringTimeB (startTime, endTime) {
return result
}
export function calcDurationByStringTimeMs (startTime, endTime) {
let durationSecond = stringTimeParseToUnixMs(endTime) - stringTimeParseToUnixMs(startTime)
let result = ''
if (durationSecond < 1000) {
result = `${durationSecond % 1000}ms`
return result
} else {
durationSecond = durationSecond / 1000
}
result = `${durationSecond % 60}s`
if (durationSecond >= 60 * 60 * 24) {
result = `${(Math.floor(durationSecond / 3600)) % 24}h`
result = `${Math.floor(durationSecond / (60 * 60 * 24))}d ${result}`
} else if (durationSecond >= 60 * 60) {
result = `${(Math.floor(durationSecond / 60)) % 60}m`
result = `${Math.floor(durationSecond / (60 * 60))}h ${result}`
} else if (durationSecond >= 60) {
result = `${(Math.floor(durationSecond / 60)) % 60}m ${result}`
}
return result
}
export function unixTimeParseToString (unixTime, fmt = 'yyyy-MM-dd hh:mm:ss') {
const date = new Date(unixTime * 1000)
const o = {

View File

@@ -76,7 +76,7 @@ export function nzNumber (rule, value, callback) {
}
export function noSpecialChar (rule, value, callback) {
const charReg = /^[\u4e00-\u9fa5a-z0-9A-Z-_.]+$/
const charReg = /[\u0000-\uFFFF]/
setTimeout(() => {
if (charReg.test(value)) {
callback()
@@ -170,7 +170,7 @@ export function checkExprTempAge (rule, value, callback) {
}, 100)
}
export function arrLength (rule, value, callback) { // 校验经纬度
export function arrLength (rule, value, callback) { // 校验数组
if (value.length > 0) {
callback()
} else {