chore: initialize qiming workspace repository

This commit is contained in:
Codex
2026-05-29 14:22:48 +08:00
commit bfd67a0f2c
10750 changed files with 1885711 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
/**
* 简单检查是否是有效的颜色值
* @param {string} value
* @returns {boolean}
*/
function isValidColor(value : string | null) {
if (value == null) return false;
// 常见颜色格式检查
return (
// 颜色关键字red, blue 等)
/^[a-z]+$/i.test(value!) ||
// 十六进制(#fff, #ffffff
/^#([0-9a-f]{3}){1,2}$/i.test(value!) ||
// rgb/rgba
/^rgba?\([\s\d.,%]+\)$/.test(value!) ||
// hsl/hsla
/^hsla?\([\s\d.,%]+\)$/.test(value!)
);
}
export function getCssVariableColor(element : UniTextElement | null) : string | null {
if (element == null) return null
let value = element!.style.getPropertyValue('color').trim();
// 如果没有找到变量值,直接返回 null
if (value == '') return null;
if(value.startsWith('var(')) {
const innerVar = value.match(/var\(([^,)]+)(?:,\s*(.*))?\)/);
if(innerVar == null) return null
const [, , innerFallback] = innerVar!;
return innerFallback
} else {
return value
}
}