perf: 修改 labels 组件

This commit is contained in:
ibuler
2024-04-23 17:27:00 +08:00
parent 8e06dde724
commit dcd59ca69f
4 changed files with 44 additions and 7 deletions

View File

@@ -84,11 +84,22 @@ export function changeMenuColor(themeColors) {
colors['--menu-hover'] = menuHover
}
const lights = [15, 40, 60, 80]
const darks = [15, 30, 40, 60]
for (const key in colors) {
const currentColor = colors[key]
elementStyle.setProperty(key, currentColor)
if (key.includes('--color')) {
for (const [i, light] of lights.entries()) {
const color = mix(white, currentColor.replace(/#/g, ''), light)
elementStyle.setProperty(key + '-light' + '-' + i, color)
}
for (const [i, dark] of darks.entries()) {
const color = mix(black, currentColor.replace(/#/g, ''), dark)
elementStyle.setProperty(key + '-dark' + '-' + i, color)
}
const lightColor = mix(white, currentColor.replace(/#/g, ''), 70)
const darkColor = mix(black, currentColor.replace(/#/g, ''), 70)
elementStyle.setProperty(key + '-light', lightColor)