Major changes: - New frontend (platform/web/): Vite + React 18 + TypeScript + Tailwind - 4-module navigation: 数据送标 / 模型管理 / 车队管理 / 系统管理 - Data catalog with charts (DMS/ADAS/Lane 3-tab view) - Quality review workflow (标注质检): Good/Fine/Bad scoring with auto-advance - Audit enhancements: batch operations, rejection categories, Feishu notifications - Operation audit log (操作日志) - World model simulation studio (仿真工坊) - Dataset version management with snapshots and diff - ADAS 7-class dataset integration (138K images organized + compressed) - User management with Feishu integration and pagination - CRUD/search/filter on all pages, card layout redesign - PIL-optimized image overlay rendering - Auto-snapshot on build, in_review workflow stage - Removed embedded algorithm code (now in workspace)
98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
let FractionJs = require('fraction.js')
|
|
|
|
let Prefixer = require('./prefixer')
|
|
let utils = require('./utils')
|
|
|
|
const REGEXP = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpcm|dpi|x)/gi
|
|
const SPLIT = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpcm|dpi|x)/i
|
|
|
|
class Resolution extends Prefixer {
|
|
/**
|
|
* Remove prefixed queries
|
|
*/
|
|
clean(rule) {
|
|
if (!this.bad) {
|
|
this.bad = []
|
|
for (let prefix of this.prefixes) {
|
|
this.bad.push(this.prefixName(prefix, 'min'))
|
|
this.bad.push(this.prefixName(prefix, 'max'))
|
|
}
|
|
}
|
|
|
|
rule.params = utils.editList(rule.params, queries => {
|
|
return queries.filter(query => this.bad.every(i => !query.includes(i)))
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Return prefixed query name
|
|
*/
|
|
prefixName(prefix, name) {
|
|
if (prefix === '-moz-') {
|
|
return name + '--moz-device-pixel-ratio'
|
|
} else {
|
|
return prefix + name + '-device-pixel-ratio'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return prefixed query
|
|
*/
|
|
prefixQuery(prefix, name, colon, value, units) {
|
|
value = new FractionJs(value)
|
|
|
|
// 1dpcm = 2.54dpi
|
|
// 1dppx = 96dpi
|
|
if (units === 'dpi') {
|
|
value = value.div(96)
|
|
} else if (units === 'dpcm') {
|
|
value = value.mul(2.54).div(96)
|
|
}
|
|
value = value.simplify()
|
|
|
|
if (prefix === '-o-') {
|
|
value = value.n + '/' + value.d
|
|
}
|
|
return this.prefixName(prefix, name) + colon + value
|
|
}
|
|
|
|
/**
|
|
* Add prefixed queries
|
|
*/
|
|
process(rule) {
|
|
let parent = this.parentPrefix(rule)
|
|
let prefixes = parent ? [parent] : this.prefixes
|
|
|
|
rule.params = utils.editList(rule.params, (origin, prefixed) => {
|
|
for (let query of origin) {
|
|
if (
|
|
!query.includes('min-resolution') &&
|
|
!query.includes('max-resolution')
|
|
) {
|
|
prefixed.push(query)
|
|
continue
|
|
}
|
|
|
|
for (let prefix of prefixes) {
|
|
let processed = query.replace(REGEXP, str => {
|
|
let parts = str.match(SPLIT)
|
|
return this.prefixQuery(
|
|
prefix,
|
|
parts[1],
|
|
parts[2],
|
|
parts[3],
|
|
parts[4]
|
|
)
|
|
})
|
|
prefixed.push(processed)
|
|
}
|
|
prefixed.push(query)
|
|
}
|
|
|
|
return utils.uniq(prefixed)
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = Resolution
|