chore: 更新部分配置修改为全局配置

This commit is contained in:
uye
2024-07-15 14:50:37 +08:00
parent 2aa3dfa182
commit f91cb96ffa
9 changed files with 145 additions and 137 deletions

View File

@@ -102,7 +102,7 @@ namespace MaaWpfGui.Models
private static async Task<string> GetResourceApiAsync()
{
string mirror = ConfigurationHelper.GetValue(ConfigurationKeys.ResourceApi, MaaUrls.MaaResourceApi);
string mirror = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ResourceApi, MaaUrls.MaaResourceApi);
if (mirror != MaaUrls.MaaResourceApi && await IsMirrorAccessibleAsync(mirror))
{
return mirror;
@@ -132,7 +132,7 @@ namespace MaaWpfGui.Models
if (mirror != MaaUrls.MaaResourceApi)
{
ConfigurationHelper.SetValue(ConfigurationKeys.ResourceApi, mirror);
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.ResourceApi, mirror);
}
return mirror;

View File

@@ -232,7 +232,7 @@
<system:String x:Key="TimerCustomConfig">Custom config</system:String>
<system:String x:Key="TimerCustomConfigTip">Restart and switch configuration two minutes in advance</system:String>
<system:String x:Key="Timer">Timer</system:String>
<system:String x:Key="TimerTip">This option page is for global config</system:String>
<system:String x:Key="GlobalConfigTip">This option page is for global config</system:String>
<system:String x:Key="SwitchConfiguration">Configuration</system:String>
<system:String x:Key="ConfigurationName">Config</system:String>
<system:String x:Key="AddConfiguration">Add</system:String>

View File

@@ -232,7 +232,7 @@
<system:String x:Key="TimerCustomConfig">カスタム構成オプション</system:String>
<system:String x:Key="TimerCustomConfigTip">2分前に再起動して設定を切り替えます</system:String>
<system:String x:Key="Timer">タイマー</system:String>
<system:String x:Key="TimerTip">このオプション ページはグローバル設定用です</system:String>
<system:String x:Key="GlobalConfigTip">このオプション ページはグローバル設定用です</system:String>
<system:String x:Key="SwitchConfiguration">構成を切り替える</system:String>
<system:String x:Key="ConfigurationName">構成名</system:String>
<system:String x:Key="AddConfiguration">追加</system:String>

View File

@@ -232,7 +232,7 @@
<system:String x:Key="TimerCustomConfig">사용자 지정 구성 옵션</system:String>
<system:String x:Key="TimerCustomConfigTip">2분 전에 재시작하여 설정을 전환합니다</system:String>
<system:String x:Key="Timer">타이머</system:String>
<system:String x:Key="TimerTip">이 옵션 페이지는 전역 구성용입니다</system:String>
<system:String x:Key="GlobalConfigTip">이 옵션 페이지는 전역 구성용입니다</system:String>
<system:String x:Key="SwitchConfiguration">구성 전환</system:String>
<system:String x:Key="ConfigurationName">구성 이름</system:String>
<system:String x:Key="AddConfiguration">추가</system:String>

View File

@@ -232,7 +232,7 @@
<system:String x:Key="TimerCustomConfig">自定义配置选择</system:String>
<system:String x:Key="TimerCustomConfigTip">将提前两分钟重启并切换配置</system:String>
<system:String x:Key="Timer">定时</system:String>
<system:String x:Key="TimerTip">此选项页为全局配置</system:String>
<system:String x:Key="GlobalConfigTip">此选项页为全局配置</system:String>
<system:String x:Key="SwitchConfiguration">切换配置</system:String>
<system:String x:Key="ConfigurationName">配置名称</system:String>
<system:String x:Key="AddConfiguration">添加</system:String>

View File

@@ -228,7 +228,7 @@
<system:String x:Key="TimerCustomConfig">自定義配置選擇</system:String>
<system:String x:Key="TimerCustomConfigTip">將提前兩分鐘重開並切換配置</system:String>
<system:String x:Key="Timer">定時</system:String>
<system:String x:Key="TimerTip">此選項頁為全局配置</system:String>
<system:String x:Key="GlobalConfigTip">此選項頁為全局配置</system:String>
<system:String x:Key="SwitchConfiguration">切換配置</system:String>
<system:String x:Key="ConfigurationName">配置名稱</system:String>
<system:String x:Key="AddConfiguration">新增</system:String>

View File

@@ -110,7 +110,7 @@ namespace MaaWpfGui.ViewModels.UI
LocalizationHelper.GetString("UiSettings"),
LocalizationHelper.GetString("ExternalNotificationSettings"),
LocalizationHelper.GetString("HotKeySettings"),
LocalizationHelper.GetString("UpdateSettings"),
LocalizationHelper.GetString("UpdateSettings")+LocalizationHelper.GetString("UpdateSettings"),
LocalizationHelper.GetString("AboutUs"),
];
@@ -3319,7 +3319,7 @@ namespace MaaWpfGui.ViewModels.UI
private UpdateVersionType _versionType = (UpdateVersionType)Enum.Parse(
typeof(UpdateVersionType),
ConfigurationHelper.GetValue(ConfigurationKeys.VersionType, UpdateVersionType.Stable.ToString()));
ConfigurationHelper.GetGlobalValue(ConfigurationKeys.VersionType, UpdateVersionType.Stable.ToString()));
/// <summary>
/// Gets or sets the type of version to update.
@@ -3331,7 +3331,7 @@ namespace MaaWpfGui.ViewModels.UI
if (_versionType == UpdateVersionType.Nightly && !_allowNightlyUpdates)
{
SetAndNotify(ref _versionType, UpdateVersionType.Beta);
ConfigurationHelper.SetValue(ConfigurationKeys.VersionType, UpdateVersionType.Beta.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.VersionType, UpdateVersionType.Beta.ToString());
}
return _versionType;
@@ -3339,7 +3339,7 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _versionType, value);
ConfigurationHelper.SetValue(ConfigurationKeys.VersionType, value.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.VersionType, value.ToString());
}
}
@@ -3358,7 +3358,7 @@ namespace MaaWpfGui.ViewModels.UI
get => AllVersionTypeList.Where(v => _allowNightlyUpdates || v.Value != UpdateVersionType.Nightly).ToList();
}
private readonly bool _allowNightlyUpdates = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowNightlyUpdates, bool.FalseString));
private readonly bool _allowNightlyUpdates = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.AllowNightlyUpdates, bool.FalseString));
/// <summary>
/// Gets a value indicating whether to update nightly.
@@ -3376,7 +3376,7 @@ namespace MaaWpfGui.ViewModels.UI
get => _versionType == UpdateVersionType.Beta;
}
private bool _updateCheck = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UpdateCheck, bool.TrueString));
private bool _updateCheck = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.UpdateCheck, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to check update.
@@ -3387,11 +3387,11 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _updateCheck, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UpdateCheck, value.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.UpdateCheck, value.ToString());
}
}
private bool _updateAutoCheck = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UpdateAutoCheck, bool.FalseString));
private bool _updateAutoCheck = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.UpdateAutoCheck, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to check update.
@@ -3402,11 +3402,11 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _updateAutoCheck, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UpdateAutoCheck, value.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.UpdateAutoCheck, value.ToString());
}
}
private string _proxy = ConfigurationHelper.GetValue(ConfigurationKeys.UpdateProxy, string.Empty);
private string _proxy = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.UpdateProxy, string.Empty);
/// <summary>
/// Gets or sets the proxy settings.
@@ -3417,7 +3417,7 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _proxy, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UpdateProxy, value);
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.UpdateProxy, value);
}
}
@@ -3435,7 +3435,7 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private bool _autoDownloadUpdatePackage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AutoDownloadUpdatePackage, bool.TrueString));
private bool _autoDownloadUpdatePackage = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.AutoDownloadUpdatePackage, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to auto download update package.
@@ -3446,11 +3446,11 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _autoDownloadUpdatePackage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AutoDownloadUpdatePackage, value.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.AutoDownloadUpdatePackage, value.ToString());
}
}
private bool _autoInstallUpdatePackage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AutoInstallUpdatePackage, bool.FalseString));
private bool _autoInstallUpdatePackage = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.AutoInstallUpdatePackage, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to auto install update package.
@@ -3461,7 +3461,7 @@ namespace MaaWpfGui.ViewModels.UI
set
{
SetAndNotify(ref _autoInstallUpdatePackage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AutoInstallUpdatePackage, value.ToString());
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.AutoInstallUpdatePackage, value.ToString());
}
}

View File

@@ -27,7 +27,7 @@
Grid.Row="0"
HorizontalAlignment="Center"
FontWeight="Bold"
Text="{DynamicResource TimerTip}"
Text="{DynamicResource GlobalConfigTip}"
TextAlignment="Center" />
<StackPanel
Grid.Row="1"

View File

@@ -17,126 +17,134 @@
d:DesignHeight="300"
d:DesignWidth="550"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel
<StackPanel>
<controls:TextBlock
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center">
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource StartupUpdateCheck}"
IsChecked="{Binding UpdateCheck}"
IsEnabled="False" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdateAutoCheck}"/>
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdateAutoDownload}"
IsChecked="{Binding AutoDownloadUpdatePackage}"/>
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource AutoInstallUpdatePackage}"
IsChecked="{Binding AutoInstallUpdatePackage}"/>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<controls:TextBlock
Margin="10,10,0,10"
Block.TextAlignment="Center"
Text="{DynamicResource UpdateCheck}" />
<ComboBox
Width="120"
HorizontalAlignment="Center"
FontWeight="Bold"
Text="{DynamicResource GlobalConfigTip}"
TextAlignment="Center" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center">
<CheckBox
Margin="10"
DisplayMemberPath="Display"
ItemsSource="{Binding VersionTypeList}"
SelectedValue="{Binding VersionType}"
SelectedValuePath="Value" />
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource StartupUpdateCheck}"
IsChecked="{Binding UpdateCheck}"
IsEnabled="False" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdateAutoCheck}" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdateAutoDownload}"
IsChecked="{Binding AutoDownloadUpdatePackage}" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource AutoInstallUpdatePackage}"
IsChecked="{Binding AutoInstallUpdatePackage}" />
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<controls:TextBlock
Margin="10,10,0,10"
Block.TextAlignment="Center"
Text="{DynamicResource UpdateCheck}" />
<ComboBox
Width="120"
Margin="10"
DisplayMemberPath="Display"
ItemsSource="{Binding VersionTypeList}"
SelectedValue="{Binding VersionType}"
SelectedValuePath="Value" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel
Grid.Row="0"
Grid.Column="1"
Margin="3"
VerticalAlignment="Center">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Grid.Column="1"
Margin="3"
VerticalAlignment="Center">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<controls:TextBlock
Grid.Row="0"
Margin="1"
VerticalAlignment="Center"
Text="Http Proxy" />
<TextBox
Grid.Row="1"
Width="150"
Margin="10"
VerticalAlignment="Center"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding Proxy}" />
<StackPanel Grid.Row="2">
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
<controls:TextBlock
Grid.Row="0"
Margin="1"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding ResourceVersion}"
PreviewMouseDown="ResourceVersionClick"
Status="{Binding ResourceVersion, Mode=OneWay}"
Subject="{DynamicResource ResourceVersion}"
Color="#6969AA" />
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
Text="Http Proxy" />
<TextBox
Grid.Row="1"
Width="150"
Margin="10"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding UiVersion}"
PreviewMouseDown="UiVersionClick"
Status="{Binding UiVersion, Mode=OneWay}"
Subject="{DynamicResource UiVersion}"
Color="#6969AA" />
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding CoreVersion}"
PreviewMouseDown="CoreVersionClick"
Status="{Binding CoreVersion, Mode=OneWay}"
Subject="{DynamicResource CoreVersion}"
Color="#6969AA" />
</StackPanel>
<StackPanel
Grid.Row="3"
Margin="5"
VerticalAlignment="Center">
<Button
InputMethod.IsInputMethodEnabled="False"
Text="{Binding Proxy}" />
<StackPanel Grid.Row="2">
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding ResourceVersion}"
PreviewMouseDown="ResourceVersionClick"
Status="{Binding ResourceVersion, Mode=OneWay}"
Subject="{DynamicResource ResourceVersion}"
Color="#6969AA" />
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding UiVersion}"
PreviewMouseDown="UiVersionClick"
Status="{Binding UiVersion, Mode=OneWay}"
Subject="{DynamicResource UiVersion}"
Color="#6969AA" />
<hc:Shield
Margin="0,5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:FloatingBlock.Content="{Binding CoreVersion}"
PreviewMouseDown="CoreVersionClick"
Status="{Binding CoreVersion, Mode=OneWay}"
Subject="{DynamicResource CoreVersion}"
Color="#6969AA" />
</StackPanel>
<StackPanel
Grid.Row="3"
Margin="5"
Command="{s:Action ManualUpdate}"
Content="{DynamicResource UpdateCheckNow}"
IsEnabled="{c:Binding !IsCheckingForUpdates}" />
<Button
Margin="5"
Command="{s:Action ShowChangelog}"
Content="{DynamicResource ShowChangelog}"
IsEnabled="{c:Binding !IsCheckingForUpdates}" />
</StackPanel>
</Grid>
</StackPanel>
</Grid>
VerticalAlignment="Center">
<Button
Margin="5"
Command="{s:Action ManualUpdate}"
Content="{DynamicResource UpdateCheckNow}"
IsEnabled="{c:Binding !IsCheckingForUpdates}" />
<Button
Margin="5"
Command="{s:Action ShowChangelog}"
Content="{DynamicResource ShowChangelog}"
IsEnabled="{c:Binding !IsCheckingForUpdates}" />
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</StackPanel>
</UserControl>