feat: 新增“定时检测更新”功能

fix #3991
This commit is contained in:
uye
2023-03-24 20:24:38 +08:00
parent b7e026ea19
commit eebd1cfa5e
9 changed files with 57 additions and 7 deletions

View File

@@ -308,6 +308,7 @@ namespace MaaWpfGui
public const string UpdateProxy = "VersionUpdate.Proxy";
public const string VersionType = "VersionUpdate.VersionType";
public const string UpdateCheck = "VersionUpdate.UpdateCheck";
public const string UpdatAutoCheck = "VersionUpdate.ScheduledUpdateCheck";
public const string UseAria2 = "VersionUpdate.UseAria2";
public const string AutoDownloadUpdatePackage = "VersionUpdate.AutoDownloadUpdatePackage";

View File

@@ -1674,6 +1674,21 @@ namespace MaaWpfGui
}
}
private bool _updateAutoCheck = Convert.ToBoolean(Config.Get(Config.UpdatAutoCheck, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to check update.
/// </summary>
public bool UpdatAutoCheck
{
get => _updateAutoCheck;
set
{
SetAndNotify(ref _updateAutoCheck, value);
Config.Set(Config.UpdatAutoCheck, value.ToString());
}
}
private string _proxy = Config.Get(Config.UpdateProxy, string.Empty);
/// <summary>

View File

@@ -189,6 +189,14 @@ namespace MaaWpfGui
return;
}
if (NeedToCheckForUpdates())
{
if (_settingsViewModel.UpdatAutoCheck)
{
_settingsViewModel.ManualUpdate();
}
}
int intMinute = DateTime.Now.Minute;
int intHour = DateTime.Now.Hour;
var timeToStart = false;
@@ -362,7 +370,7 @@ namespace MaaWpfGui
var hour = now.Hour;
var min = now.Minute;
// yj历的16点
// yj历的4/16点
if (min == 0 && hour == 12)
{
return true;
@@ -381,6 +389,21 @@ namespace MaaWpfGui
}
}
private bool NeedToCheckForUpdates()
{
var now = Utils.GetYJTimeNow();
var hour = now.Hour;
var min = now.Minute;
// yj历的4/22点
if (min == 0 && hour == 18)
{
return true;
}
return false;
}
/// <summary>
/// Updates date prompt.
/// </summary>

View File

@@ -138,7 +138,8 @@
<system:String x:Key="CheckBoxesNotSaved">This option is not saved after restart</system:String>
<system:String x:Key="NoAutoNavigation">The feature does not automatically navigate to the stage</system:String>
<system:String x:Key="UpdateAutoCheck">Auto check update</system:String>
<system:String x:Key="StartupUpdateCheck">Startup Update Check</system:String>
<system:String x:Key="UpdatAutoCheck">Scheduled Update Check</system:String>
<system:String x:Key="UpdateAutoDownload">Auto download update</system:String>
<system:String x:Key="UpdateCheckStable">Stable release</system:String>
<system:String x:Key="UpdateCheckBeta">Beta release</system:String>

View File

@@ -139,7 +139,8 @@
<system:String x:Key="CheckBoxesNotSaved">このオプション設定は再起動後に保存されません</system:String>
<system:String x:Key="NoAutoNavigation">このオプションは、対応するステージに自動的に移動するものではありません</system:String>
<system:String x:Key="UpdateAutoCheck">アップデートチェック</system:String>
<system:String x:Key="StartupUpdateCheck">起動時の更新チェック</system:String>
<system:String x:Key="UpdatAutoCheck">定期的な更新チェック</system:String>
<system:String x:Key="UpdateAutoDownload">自動アップデート</system:String>
<system:String x:Key="UpdateCheckStable">安定版</system:String>
<system:String x:Key="UpdateCheckBeta">ベータ版</system:String>

View File

@@ -133,7 +133,8 @@
<system:String x:Key="CheckBoxesNotSaved">재시작 후 변경 사항이 저장되지 않습니다</system:String>
<system:String x:Key="NoAutoNavigation">해당 스테이지로 자동 이동하지 않습니다</system:String>
<system:String x:Key="UpdateAutoCheck">자동으로 업데이트 확인</system:String>
<system:String x:Key="StartupUpdateCheck">시작시 업데이트 확인</system:String>
<system:String x:Key="UpdatAutoCheck">일정 시간마다 업데이트 확인</system:String>
<system:String x:Key="UpdateAutoDownload">자동으로 업데이트</system:String>
<system:String x:Key="UpdateCheckStable">안정 버전</system:String>
<system:String x:Key="UpdateCheckBeta">베타 버전</system:String>

View File

@@ -139,7 +139,8 @@
<system:String x:Key="CheckBoxesNotSaved">该选项设置重启后不保存</system:String>
<system:String x:Key="NoAutoNavigation">该选项不会自动导航至对应关卡</system:String>
<system:String x:Key="UpdateAutoCheck">自动检查更新</system:String>
<system:String x:Key="StartupUpdateCheck">自动检查更新</system:String>
<system:String x:Key="UpdatAutoCheck">定时检查更新</system:String>
<system:String x:Key="UpdateAutoDownload">自动下载更新包</system:String>
<system:String x:Key="UpdateCheckStable">稳定版</system:String>
<system:String x:Key="UpdateCheckBeta">公测版</system:String>

View File

@@ -124,7 +124,8 @@
<system:String x:Key="CheckBoxesNotSaved">該選項設定重啟後不保存</system:String>
<system:String x:Key="NoAutoNavigation">該選項不會自動導航至對應關卡</system:String>
<system:String x:Key="UpdateAutoCheck">自動檢查更新</system:String>
<system:String x:Key="StartupUpdateCheck">啟動時檢查更新</system:String>
<system:String x:Key="UpdatAutoCheck">定時檢查更新</system:String>
<system:String x:Key="UpdateAutoDownload">自動下載更新包</system:String>
<system:String x:Key="UpdateCheckStable">穩定版</system:String>
<system:String x:Key="UpdateCheckBeta">公測版</system:String>

View File

@@ -28,9 +28,15 @@
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdateAutoCheck}"
Content="{DynamicResource StartupUpdateCheck}"
IsChecked="{Binding UpdateCheck}"
IsEnabled="False" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UpdatAutoCheck}"
IsChecked="{Binding UpdatAutoCheck}" />
<CheckBox
Margin="10"
HorizontalAlignment="Left"