Skip to content

Commit 44b56b0

Browse files
committed
feat: 增加 TriggerThemeChanged 方法
1 parent 8860c4b commit 44b56b0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/BootstrapBlazor/Services/DefaultThemeProvider.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ public async ValueTask SetThemeAsync(string themeName)
2020
{
2121
var module = await jsRuntime.LoadUtility();
2222
await module.SetThemeAsync(themeName);
23-
24-
if (ThemeChangedAsync is not null)
25-
{
26-
await ThemeChangedAsync(themeName);
27-
}
2823
}
2924

3025
/// <summary>
@@ -35,4 +30,15 @@ public async ValueTask SetThemeAsync(string themeName)
3530
var module = await jsRuntime.LoadUtility();
3631
return await module.GetThemeAsync();
3732
}
33+
34+
/// <summary>
35+
/// <inheritdoc/>
36+
/// </summary>
37+
public void TriggerThemeChanged()
38+
{
39+
if (ThemeChangedAsync is not null)
40+
{
41+
ThemeChangedAsync(string.Empty);
42+
}
43+
}
3844
}

src/BootstrapBlazor/Services/IThemeProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ public interface IThemeProvider
2727
/// The callback when theme changed
2828
/// </summary>
2929
Func<string, Task>? ThemeChangedAsync { get; set; }
30+
31+
/// <summary>
32+
/// Trigger the theme changed event
33+
/// </summary>
34+
void TriggerThemeChanged();
3035
}

0 commit comments

Comments
 (0)