From cf907321ef6829197f1313104f8f60b9c43b50e6 Mon Sep 17 00:00:00 2001 From: lutinglt Date: Thu, 7 Aug 2025 19:21:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(chroma):=20=E4=BB=A3=E7=A0=81=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/color.ts | 3 +-- src/core/theme.ts | 11 +---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/core/color.ts b/src/core/color.ts index 0a59e0c..bf86dc4 100644 --- a/src/core/color.ts +++ b/src/core/color.ts @@ -57,7 +57,7 @@ type ThemeColor = { /** 定义颜色, 用于生成颜色主题 * @example - * 文件名: "dark.css.tsx" + * 文件名: "dark.css.ts" * import type { Console, Diff, Other } from "src/types"; * import { defineTheme, themeVars } from "src"; * @@ -70,7 +70,6 @@ type ThemeColor = { * ... * } * ... - * // 会经过 lightningcss 打包处理生成最终的 CSS * export default defineTheme({ * isDarkTheme: true, * primary: "#0969da", diff --git a/src/core/theme.ts b/src/core/theme.ts index fb293a0..0783168 100644 --- a/src/core/theme.ts +++ b/src/core/theme.ts @@ -4,15 +4,6 @@ import type { MapLeafNodes, WithOptionalLayer } from "./types"; export type Theme = WithOptionalLayer>; -function stringToBoolean(str: string, name: string): boolean { - try { - return JSON.parse(str); - } catch (error) { - console.error(error); - throw new Error(`Invalid boolean value(${name}): ${str}`); - } -} - export const overlayAppearDown = "overlay-appear-down"; export const animationDown = `200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running ${overlayAppearDown}`; export const overlayAppearUp = "overlay-appear-up"; @@ -42,7 +33,7 @@ const emoji = ` `; export function createTheme(theme: Theme): void { - const isDarkTheme = stringToBoolean(theme.isDarkTheme, "isDarkTheme"); + const isDarkTheme: boolean = JSON.parse(theme.isDarkTheme); if (isDarkTheme) { globalStyle(emoji, { filter: "invert(100%) hue-rotate(180deg)" }); }