Skip to content

Commit

Permalink
feat: 自动展开设置项
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimeNull committed Mar 23, 2024
1 parent fea2b70 commit 5076d3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions OpenGptChat.Avalonia/Views/Pages/ConfigPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
x:Class="OpenGptChat.Views.Pages.ConfigPage"
x:DataType="vm:ConfigPageViewModel"
LostFocus="PageLostFocus"
Tag="StrConfiguration">
Tag="StrConfiguration"
Loaded="PageLoaded">

<Design.DataContext>
<vm:ConfigPageViewModel/>
Expand All @@ -19,7 +20,8 @@
<Grid Name="Layout"
Margin="48">
<StackPanel Name="Settings" Spacing="8">
<fluent:SettingsExpander IconSource="Link"
<fluent:SettingsExpander Name="APISettings"
IconSource="Link"
Header="API"
Description="API Settings">
<fluent:SettingsExpanderItem>
Expand Down
11 changes: 11 additions & 0 deletions OpenGptChat.Avalonia/Views/Pages/ConfigPage.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,16 @@ private void PageLostFocus(object? sender, Avalonia.Interactivity.RoutedEventArg
.GetRequiredService<ConfigService>()
.Save();
}

private void PageLoaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
var config = App.Services
.GetRequiredService<ConfigService>()
.AppConfig;

if (string.IsNullOrWhiteSpace(config.ApiKey) ||
string.IsNullOrWhiteSpace(config.ApiHost))
APISettings.IsExpanded = true;
}
}
}
2 changes: 1 addition & 1 deletion OpenGptChat.Common/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenGptChat
public partial class AppConfig : ObservableObject
{
[ObservableProperty]
private string _apiHost = "openaiapi.elecho.org";
private string _apiHost = "api.openai.com";

[ObservableProperty]
private string _apiKey = string.Empty;
Expand Down

0 comments on commit 5076d3b

Please sign in to comment.