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)" }); }