feat(All):Initial

This commit is contained in:
2025-10-04 23:36:07 +08:00
commit 2b4e5d2668
1321 changed files with 415958 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
/**
* 递归访问嵌套属性
* @param {object} obj
* @param {string} path 属性路径字符串,eg: "a.b.c"
*/
export function getNestedProperty(obj:object, path:string):any {
return path.split('.').reduce((o, key) => o?.[key], obj);
}
/**
* 转义正则特殊字符
* @param {string} str
*/
export function escapeRegExp(str:string) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
/**
* 获取系统主题色
*/
export function getOsTheme(){
const isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)"); // 是深色
if (isDarkTheme.matches) {
return 'dark';
} else {
return "light";
}
}
/**
* 获取rem的px值
*/
export function remToPxNumber(rem: number): number {
const f = parseFloat(document.documentElement.style.fontSize);
return f * rem;
}