This commit is contained in:
2026-06-08 04:19:23 +08:00
parent 8351498071
commit f2d8ad0de2
152 changed files with 2362 additions and 2227 deletions

View File

@@ -0,0 +1,27 @@
export function cpm(...classes: (string[] | string)[]) {
const map = new Map<string, string>();
function dealClass(cls: string) {
// 提取前缀和后缀
const prifix = cls.split("--")[0];
// 使用set覆盖自动新建而不是push
map.set(prifix, cls);
}
classes.forEach((item) => {
// 如果是 string 直接处理
if (typeof item === "string") {
dealClass(item);
} else {
// 否则肯定是 string[]
item.forEach((i) => {
dealClass(i);
});
}
});
const resultString = Array.from(map.values()).join(" ");
return resultString;
}