Skip to content

Commit

Permalink
Windows支持设置关闭时最小化
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Nov 17, 2023
1 parent 5dcd8e8 commit 52013b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ListenTogether.Model/EnvironmentSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class GeneralSetting
public int AppThemeInt { get; set; }

/// <summary>
/// 关闭时最小化到托盘
/// 关闭时最小化
/// </summary>
public bool IsHideWindowWhenMinimize { get; set; }
public bool IsHideWindowWhenClosed { get; set; } = false;
}

public class SearchSetting
Expand Down
9 changes: 8 additions & 1 deletion src/ListenTogether.Pages/Components/DesktopTitleBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@
}
private Task CloseAsync()
{
WindowTitleBar.Close();
if (Settings.Environment.General.IsHideWindowWhenClosed)
{
WindowTitleBar.Minimize();
}
else
{
WindowTitleBar.Close();
}
return Task.CompletedTask;
}

Expand Down
9 changes: 9 additions & 0 deletions src/ListenTogether.Pages/Pages/SettingsPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<Switch Title="启动时检查更新"
Checked="@(Settings.Environment.General.IsAutoCheckUpdate)"
OnChanged="OnIsAutoCheckUpdateChange" />
<Switch Title="关闭时最小化"
Checked="@(Settings.Environment.General.IsHideWindowWhenClosed)"
OnChanged="OnIsHideWindowWhenClosedChange" />
<div class="d-flex justify-space-between align-center">
<div>外观</div>
<div style="width:100px;">
Expand Down Expand Up @@ -141,6 +144,12 @@
Settings.Environment.General.IsAutoCheckUpdate = value;
await WriteGeneralConfigAsync();
}
private async Task OnIsHideWindowWhenClosedChange(bool value)
{
Settings.Environment.General.IsHideWindowWhenClosed = value;
await WriteGeneralConfigAsync();
}

private async Task OnAppThemeIntChange(int value)
{
Settings.Environment.General.AppThemeInt = value;
Expand Down
4 changes: 2 additions & 2 deletions src/ListenTogether.Service.Maui/EnvironmentConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<EnvironmentSetting> ReadAllSettingsAsync()
{
IsAutoCheckUpdate = generalConfig.IsAutoCheckUpdate,
AppThemeInt = generalConfig.AppThemeInt,
IsHideWindowWhenMinimize = generalConfig.IsHideWindowWhenMinimize,
IsHideWindowWhenClosed = generalConfig.IsHideWindowWhenClosed,
};

//播放设置
Expand Down Expand Up @@ -74,7 +74,7 @@ private async Task<EnvironmentConfigEntity> InitializationEnvironmentSettingAsyn
{
AppThemeInt = 0,
IsAutoCheckUpdate = true,
IsHideWindowWhenMinimize = true
IsHideWindowWhenClosed = false
}).ToJson(),
SearchSettingJson = (new SearchSetting()
{
Expand Down

0 comments on commit 52013b2

Please sign in to comment.