Skip to content

Commit 8086337

Browse files
committed
fix: 修复主题色问题
1 parent 3158363 commit 8086337

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/modules/shared/AccentColorStyleInjector/AccentColorStyleInjector.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import { useEffect, useState } from 'react';
44
import Chroma from 'chroma-js';
5+
import Color from 'colorjs.io';
56

67
import { createPngNoiseBackground } from '@/lib/noise';
78

89
const hexToOklchString = (hex: string) => {
9-
const color = Chroma(hex);
10-
const oklab = color.oklab();
11-
12-
return oklab.map((value: any) => value.toFixed(2)).join(' ');
10+
return new Color(hex).oklch;
1311
};
1412

1513
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -51,8 +49,9 @@ const AccentColorStyleInjector = () => {
5149
const lightOklch = hexToOklchString(lightColor);
5250
const darkOklch = hexToOklchString(darkColor);
5351

54-
const [hl, sl, ll] = lightOklch.split(' ');
55-
const [hd, sd, ld] = darkOklch.split(' ');
52+
const [hl, sl, ll] = lightOklch;
53+
const [hd, sd, ld] = darkOklch;
54+
console.log(lightColor, hl, sl, ll);
5655

5756
const [lightBgImage, darkBgImage] = await Promise.all([
5857
createPngNoiseBackground(lightColor),

0 commit comments

Comments
 (0)