feat: 初始化

This commit is contained in:
George
2025-07-07 15:55:44 +08:00
commit 9b7bfcfe5a
969 changed files with 123036 additions and 0 deletions

View File

@ -0,0 +1,54 @@
// @ts-nocheck
// #ifndef APP-IOS || APP-ANDROID
interface CSSProperties {
[key : string] : string | number | null
}
// #endif
// #ifdef VUE3
// #ifdef APP-IOS || APP-ANDROID
type CSSProperties = UTSJSONObject
// #endif
// #endif
/**
* 将字符串转换为带有连字符分隔的小写形式
* @param key - 要转换的字符串
* @returns 转换后的字符串
*/
export function toLowercaseSeparator(key : string):string {
return key.replace(/([A-Z])/g, '-$1').toLowerCase();
}
/**
* 获取样式对象对应的样式字符串
* @param style - CSS样式对象
* @returns 由非空有效样式属性键值对组成的字符串
*/
export function getStyleStr(style : CSSProperties) : string {
// #ifdef APP-IOS || APP-ANDROID
let styleStr = '';
style.toMap().forEach((value, key) => {
if(value !== null && value != '') {
styleStr += `${toLowercaseSeparator(key as string)}: ${value};`
}
})
return styleStr
// #endif
// #ifndef APP-IOS || APP-ANDROID
return Object.keys(style)
.filter(
(key) =>
style[key] !== undefined &&
style[key] !== null &&
style[key] !== '')
.map((key : string) => `${toLowercaseSeparator(key)}: ${style[key]};`)
.join(' ');
// #endif
}
// 示例
// const style = { color: 'red', fontSize: '16px', backgroundColor: '', border: null };
// const styleStr = getStyleStr(style);
// console.log(styleStr);
// 输出: "color: red; font-size: 16px;"

View File

@ -0,0 +1,39 @@
// @ts-nocheck
// #ifndef UNI-APP-X
interface CSSProperties {
[key : string] : string | number
}
// #endif
// #ifdef UNI-APP-X
type CSSProperties = UTSJSONObject
// #endif
/**
* 将字符串转换为带有连字符分隔的小写形式
* @param key - 要转换的字符串
* @returns 转换后的字符串
*/
export function toLowercaseSeparator(key : string) : string {
return key.replace(/([A-Z])/g, '-$1').toLowerCase();
}
/**
* 获取样式对象对应的样式字符串
* @param style - CSS样式对象
* @returns 由非空有效样式属性键值对组成的字符串
*/
export function getStyleStr(style : CSSProperties) : string {
let styleStr = '';
style.toMap().forEach((value, key) => {
if(value !== null && value != '') {
styleStr += `${toLowercaseSeparator(key as string)}: ${value};`
}
})
return styleStr
}
// 示例
// const style = { color: 'red', fontSize: '16px', backgroundColor: '', border: null };
// const styleStr = getStyleStr(style);
// console.log(styleStr);
// 输出: "color: red; font-size: 16px;"