From 4d7c66acc172aad3cab11b43cfc85d58fff0c099 Mon Sep 17 00:00:00 2001 From: lucy-cl Date: Fri, 13 May 2022 16:12:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=9A=E6=AC=A1=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=97=B6=20css=20=E5=8F=98=E9=87=8F=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E5=90=88=E5=B9=B6=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/themes/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/themes/index.ts b/src/themes/index.ts index 7e83dbf6..54e9bb32 100644 --- a/src/themes/index.ts +++ b/src/themes/index.ts @@ -54,6 +54,7 @@ const themes: Themes = { setTheme, }; let currentThemeName = ''; +let currentRawCss = {}; export function getTheme(name?: string) { if (!name) { @@ -74,14 +75,15 @@ export function setTheme(theme: string | Theme = defaultTheme, refreshChart: boo newTheme = themeMap[theme].js; currentThemeName = theme; setThemeStyle(themeMap[theme].css); + currentRawCss = themeMap[theme].rawCSS; // 打点 themeLog(theme); } else if (typeof theme === 'object') { // 传入对象,直接覆盖对应的key和css newTheme = convertKey(theme); - // TODO 多次传入对象,css 每次都会在 current 的基础上直接处理,而不会集成前一次的结果。需要改进。 - const newCSS = Object.assign({}, themeMap[currentThemeName].rawCSS, theme); + // 多次传入对象,css 会在 currentRawCss 的基础上处理 + const newCSS = Object.assign({}, currentRawCss, theme); setThemeStyle(convertCSS(newCSS)); // 打点 themeLog(newTheme.name || 'customTheme');