Skip to content

Commit

Permalink
Merge pull request #134 from ConchbrainClub/main
Browse files Browse the repository at this point in the history
fixed some warning & upgrade dependences
  • Loading branch information
lixinyang123 authored Feb 20, 2024
2 parents 586049d + 635c8bd commit d7936f0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions MixApp.Web/MixApp.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

<ItemGroup>
<PackageReference Include="Append.Blazor.Notifications" Version="1.1.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Diagnostics" Version="8.0.0" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.3.1" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.3.1" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.4.1" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 11 additions & 8 deletions MixApp.Web/Pages/Setting.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public Option<string>? SelectedLocale
set
{
selectedLocale = value;
LocalStorage.SetItemAsStringAsync("locale", value?.Value).AsTask();
JSRunTime!.InvokeVoidAsync("reload").AsTask();
Task.Run(async () =>
{
await LocalStorage.SetItemAsStringAsync("locale", value?.Value ?? string.Empty);
_ = JSRunTime!.InvokeVoidAsync("reload").AsTask();
});
}
}

Expand All @@ -46,7 +49,7 @@ public Option<string>? SelectedTheme
selectedTheme = value;
Task.Run(async () =>
{
await LocalStorage.SetItemAsStringAsync("theme", value?.Value);
await LocalStorage.SetItemAsStringAsync("theme", value?.Value ?? string.Empty);
GlobalEvent.ChangeTheme();
});
}
Expand All @@ -66,7 +69,7 @@ public string? SelectedColor
selectedColor = value;
Task.Run(async () =>
{
await LocalStorage.SetItemAsStringAsync("color", value);
await LocalStorage.SetItemAsStringAsync("color", value ?? string.Empty);
GlobalEvent.ChangeTheme();
});
}
Expand Down Expand Up @@ -101,7 +104,7 @@ public string? DownloadProxy
// =============================================
// Check Download proxy is correct

LocalStorage.SetItemAsStringAsync("download_proxy", value).AsTask();
LocalStorage.SetItemAsStringAsync("download_proxy", value ?? string.Empty).AsTask();
downloadProxy = value;
}
}
Expand All @@ -117,7 +120,7 @@ protected override async Task OnInitializedAsync()
new Option<string> { Text = "p.setting.en_us", Value = "en-US" }
];

string locale = await LocalStorage.GetItemAsStringAsync("locale").AsTask();
string? locale = await LocalStorage.GetItemAsStringAsync("locale").AsTask();
selectedLocale = LocaleOptions.SingleOrDefault(i => i.Value == locale);

// Init theme options
Expand All @@ -129,14 +132,14 @@ protected override async Task OnInitializedAsync()
new Option<string> { Text = "p.setting.light", Value = "#f5f5f5" }
];

string theme = await LocalStorage.GetItemAsStringAsync("theme").AsTask();
string? theme = await LocalStorage.GetItemAsStringAsync("theme").AsTask();

selectedTheme = ThemeOptions.SingleOrDefault(i => i.Value == theme)
?? ThemeOptions.Single(i => i.Text == "p.setting.theme_auto");

// Init base color

string color = await LocalStorage.GetItemAsStringAsync("color").AsTask();
string? color = await LocalStorage.GetItemAsStringAsync("color").AsTask();

if (string.IsNullOrEmpty(color))
{
Expand Down
2 changes: 1 addition & 1 deletion MixApp.Web/Services/GlobalEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public async void DownloadInstaller(Manifest manifest, Installer? installer = nu
string url = DownloadProxy + installer?.InstallerUrl;

// Check if user set the custome download proxy
string customeProxy = await LocalStorage.GetItemAsStringAsync("download_proxy").AsTask();
string? customeProxy = await LocalStorage.GetItemAsStringAsync("download_proxy").AsTask();
if (!string.IsNullOrEmpty(customeProxy))
{
url = customeProxy + installer?.InstallerUrl;
Expand Down
4 changes: 2 additions & 2 deletions MixApp.Web/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override async Task OnInitializedAsync()

private async Task InitTheme()
{
string theme = await LocalStorage.GetItemAsStringAsync("theme");
string? theme = await LocalStorage.GetItemAsStringAsync("theme");

if (string.IsNullOrEmpty(theme))
{
Expand All @@ -57,7 +57,7 @@ private async Task InitTheme()
Theme = theme;
}

string color = await LocalStorage.GetItemAsStringAsync("color");
string? color = await LocalStorage.GetItemAsStringAsync("color");

if (!string.IsNullOrEmpty(color))
{
Expand Down

0 comments on commit d7936f0

Please sign in to comment.