From 06e376ea01f22c022bab1182104b0d4bf1629b05 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Wed, 20 Sep 2023 11:27:56 +0800 Subject: [PATCH] perf(UI): use css filter to adapt dark mode --- .../Service/Apple/AppleDictionary/EZAppleDictionary.m | 6 +++--- .../Service/Apple/AppleDictionary/apple-dictionary.html | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m b/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m index 2f0918be2..daee81a6c 100644 --- a/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m +++ b/Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m @@ -142,14 +142,14 @@ - (NSString *)getAllIframeHTMLResultOfWord:(NSString *)word languages:(NSArray" - @"body { background-color: %@; }" + @"body { background-color: %@; color: %@}" @"@media (prefers-color-scheme: dark) {" - @"body { background-color: %@; }" + @"body { background-color: %@; filter: invert(0.85) hue-rotate(185deg) saturate(200%%) brightness(120%%);}" @"}" @"", - lightBackgroundColorString, darkBackgroundColorString]; + lightBackgroundColorString, lightTextColorString, darkBackgroundColorString]; NSString *dictHTML = [NSString stringWithFormat:@"%@ \n\n%@ \n\n%@", customCSS, dictBackgroundColorCSS, wordHtmlString]; diff --git a/Easydict/Feature/Service/Apple/AppleDictionary/apple-dictionary.html b/Easydict/Feature/Service/Apple/AppleDictionary/apple-dictionary.html index 5ded0f515..94cdd4b4f 100644 --- a/Easydict/Feature/Service/Apple/AppleDictionary/apple-dictionary.html +++ b/Easydict/Feature/Service/Apple/AppleDictionary/apple-dictionary.html @@ -96,7 +96,6 @@ } @media (prefers-color-scheme: dark) { - details summary::before, details summary::after { background: var(--dark-text-color); @@ -444,8 +443,8 @@ } if (isDarkMode()) { - updateAllIframeColor(true); - updateBackgroundColor(true); + // updateAllIframeColor(true); + // updateBackgroundColor(true); } updateAllIframeStyle(); @@ -465,8 +464,8 @@ ); colorSchemeListener.addEventListener(`change`, function (event) { var isDarkMode = event.matches; - updateAllIframeColor(isDarkMode); - updateBackgroundColor(isDarkMode); + // updateAllIframeColor(isDarkMode); + // updateBackgroundColor(isDarkMode); }); };