Skip to content

Commit 86babcf

Browse files
authored
feat(ThemeProvider): keep auto value (#8068)
* refactor: 使用三元操作符兼容 net6 * refactor: 支持 auto 值 * refactor: bump version 10.6.5-beta01
1 parent 82a673e commit 86babcf

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.6.4</Version>
4+
<Version>10.6.5-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/wwwroot/modules/utility.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,7 @@ export function getTheme(useLocalstorage = true) {
702702
theme = document.documentElement.getAttribute('data-bs-theme');
703703
}
704704

705-
if (theme === null || theme === 'auto') {
706-
theme = getAutoThemeValue();
707-
}
708-
return theme;
705+
return theme == null ? 'auto' : theme;
709706
}
710707

711708
export function saveTheme(theme) {
@@ -719,8 +716,8 @@ export function getAutoThemeValue() {
719716
}
720717

721718
export function setTheme(theme, sync) {
722-
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
723-
document.documentElement.setAttribute('data-bs-theme', 'dark')
719+
if (theme === 'auto') {
720+
document.documentElement.setAttribute('data-bs-theme', getAutoThemeValue())
724721
}
725722
else {
726723
document.documentElement.setAttribute('data-bs-theme', theme);

0 commit comments

Comments
 (0)