Add prerelease combo box

This commit is contained in:
Jack251970 2025-03-13 12:40:02 +08:00
parent 75397f11c6
commit 35594be2f0
4 changed files with 29 additions and 7 deletions

View file

@ -25,14 +25,16 @@ namespace Flow.Launcher.Core
public string GitHubReleaseRepository { get; }
public string GitHubPrereleaseRepository { get; }
public bool UpdateToPrerelease { get; set; }
public bool UpdateToPrerelease => _settings.PrereleaseUpdateSource;
public string GitHubRepository => UpdateToPrerelease ? GitHubPrereleaseRepository : GitHubReleaseRepository;
private readonly Settings _settings;
private readonly IPublicAPI _api;
public Updater(IPublicAPI publicAPI, string gitHubReleaseRepository, string gitHubPrereleaseRepository)
public Updater(Settings settings, IPublicAPI publicAPI, string gitHubReleaseRepository, string gitHubPrereleaseRepository)
{
_settings = settings;
_api = publicAPI;
GitHubReleaseRepository = gitHubReleaseRepository;
GitHubPrereleaseRepository = gitHubPrereleaseRepository;

View file

@ -55,7 +55,11 @@ namespace Flow.Launcher
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureServices(services => services
.AddSingleton(_ => _settings)
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo, Launcher.Properties.Settings.Default.PrereleaseRepo))
.AddSingleton(sp => new Updater(
_settings,
sp.GetRequiredService<IPublicAPI>(),
Launcher.Properties.Settings.Default.GithubRepo,
Launcher.Properties.Settings.Default.PrereleaseRepo))
.AddSingleton<Portable>()
.AddSingleton<SettingWindowViewModel>()
.AddSingleton<IAlphabet, PinyinAlphabet>()

View file

@ -45,6 +45,16 @@ public partial class SettingsPaneAboutViewModel : BaseModel
_settings.ActivateTimes
);
public int PrereleaseSelectedIndex
{
get => _settings.PrereleaseUpdateSource ? 1 : 0;
set
{
_settings.PrereleaseUpdateSource = value == 1;
OnPropertyChanged();
}
}
public SettingsPaneAboutViewModel(Settings settings, Updater updater)
{
_settings = settings;

View file

@ -31,10 +31,6 @@
Icon="&#xe946;"
Sub="{DynamicResource version}">
<StackPanel Orientation="Horizontal">
<Button
Margin="0 0 10 0"
Command="{Binding UpdateAppCommand}"
Content="{DynamicResource checkUpdates}" />
<Button Padding="0" Style="{StaticResource AccentButtonStyle}">
<Hyperlink
NavigateUri="{Binding SponsorPage}"
@ -49,6 +45,16 @@
</StackPanel>
</cc:Card>
<cc:Card Title="{DynamicResource updateSource}">
<StackPanel Orientation="Horizontal">
<ComboBox Margin="0 0 10 0" SelectedIndex="{Binding PrereleaseSelectedIndex}">
<ComboBoxItem Content="{DynamicResource release}" />
<ComboBoxItem Content="{DynamicResource prerelease}" />
</ComboBox>
<Button Command="{Binding UpdateAppCommand}" Content="{DynamicResource checkUpdates}" />
</StackPanel>
</cc:Card>
<cc:Card Title="{DynamicResource releaseNotes}" Icon="&#xe8fd;">
<cc:HyperLink Text="{DynamicResource releaseNotes}" Uri="{Binding ReleaseNotes}" />
</cc:Card>