Skip to content

Commit

Permalink
保存加载语言设置
Browse files Browse the repository at this point in the history
  • Loading branch information
None authored and None committed Dec 15, 2024
1 parent f873a6f commit 15d9ed8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions MultiOpenBrowser.Core/Entitys/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class Option : INotifyPropertyChanged
{
public string? Language { get; set; }
/// <summary>
/// 默认浏览器数据文件夹
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion MultiOpenBrowser/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public App()
EventBus.OnLanguageChange += OnLanguageChangeHandle;
}

private void OnLanguageChangeHandle(string langName)
private async void OnLanguageChangeHandle(string langName)
{
if (Application.LoadComponent(new Uri(@"Views\Resources\" + langName + ".xaml", UriKind.Relative)) is ResourceDictionary langRd)
{
Resources.MergedDictionaries[0] = langRd;
GlobalData.Option.Language = langName;
await CacheRepo.SetAsync(nameof(Option), GlobalData.Option, null);
}
}

Expand All @@ -34,6 +36,11 @@ private async void Application_Startup(object sender, StartupEventArgs e)

await ArgsHelper.StartWebEnvironmentAsync(e.Args);

if (!string.IsNullOrWhiteSpace(GlobalData.Option.Language))
{
OnLanguageChangeHandle(GlobalData.Option.Language!);
}

StartupUri = new Uri("Views/Windows/MainWindow.xaml", UriKind.Relative);
}

Expand Down

0 comments on commit 15d9ed8

Please sign in to comment.