mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
@@ -15,11 +15,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
|
||||
namespace MaaWpfGui.Helper
|
||||
{
|
||||
public class ETagCache
|
||||
{
|
||||
private static readonly ILogger _logger = Log.ForContext<ETagCache>();
|
||||
|
||||
private static readonly string _cacheFile = Path.Combine(Environment.CurrentDirectory, "cache/etag.json");
|
||||
private static Dictionary<string, string> _cache;
|
||||
|
||||
@@ -36,9 +39,13 @@ namespace MaaWpfGui.Helper
|
||||
var jsonStr = File.ReadAllText(_cacheFile);
|
||||
_cache = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonStr);
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
_cache = new Dictionary<string, string>();
|
||||
_logger.Error(e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cache ??= new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace MaaWpfGui.Models
|
||||
|
||||
public static async Task<UpdateResult> Update()
|
||||
{
|
||||
updating = false;
|
||||
_updating = false;
|
||||
|
||||
var ret1 = await updateSingleFiles();
|
||||
var ret2 = await updateFilesWithIndex();
|
||||
@@ -85,7 +85,7 @@ namespace MaaWpfGui.Models
|
||||
|
||||
foreach (var file in MaaSingleFiles)
|
||||
{
|
||||
var sRet = await UpdateFileWithETage(MaaResourceApi, file, file);
|
||||
var sRet = await UpdateFileWithETag(MaaResourceApi, file, file);
|
||||
|
||||
if (sRet == UpdateResult.Failed)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ namespace MaaWpfGui.Models
|
||||
// 这些文件数量不固定,需要先获取索引文件,再根据索引文件下载
|
||||
private static async Task<UpdateResult> updateFilesWithIndex()
|
||||
{
|
||||
var indexSRet = await UpdateFileWithETage(MaaResourceApi, MaaDynamicFilesIndex, MaaDynamicFilesIndex);
|
||||
var indexSRet = await UpdateFileWithETag(MaaResourceApi, MaaDynamicFilesIndex, MaaDynamicFilesIndex);
|
||||
if (indexSRet == UpdateResult.Failed || indexSRet == UpdateResult.NotModified)
|
||||
{
|
||||
return indexSRet;
|
||||
@@ -128,7 +128,7 @@ namespace MaaWpfGui.Models
|
||||
return;
|
||||
}
|
||||
|
||||
var sRet = await UpdateFileWithETage(MaaResourceApi, file, file);
|
||||
var sRet = await UpdateFileWithETag(MaaResourceApi, file, file);
|
||||
if (sRet == UpdateResult.Failed)
|
||||
{
|
||||
ret = UpdateResult.Failed;
|
||||
@@ -143,9 +143,9 @@ namespace MaaWpfGui.Models
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static bool updating = false;
|
||||
private static bool _updating;
|
||||
|
||||
public static async Task<UpdateResult> UpdateFileWithETage(string baseUrl, string file, string saveTo)
|
||||
public static async Task<UpdateResult> UpdateFileWithETag(string baseUrl, string file, string saveTo)
|
||||
{
|
||||
saveTo = Path.Combine(Environment.CurrentDirectory, saveTo);
|
||||
var url = baseUrl + file;
|
||||
@@ -180,9 +180,9 @@ namespace MaaWpfGui.Models
|
||||
return UpdateResult.Failed;
|
||||
}
|
||||
|
||||
if (!updating)
|
||||
if (!_updating)
|
||||
{
|
||||
updating = true;
|
||||
_updating = true;
|
||||
_ = Execute.OnUIThreadAsync(() =>
|
||||
{
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString("GameResourceUpdating"));
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!-- .Net 8 -->
|
||||
<system:String x:Key="Dotnet8">MAA is about to be upgraded, and the upgraded version does not support PCs that do not have the .NET 8.0 runtime installed, so you need to manually download and install it. \n\nAt the same time, we will no longer support Windows 7. \n\nIf you click 'Yes', we will open the .NET 8 runtime download link for you. If you click 'No', we will disable your automatic download feature to prevent unwanted software updates. If you choose to disable automatic downloads, you can still manually re-enable this feature in the software settings.</system:String>
|
||||
<system:String x:Key="Dotnet8Caption">Software Version Upgrade and Support Changes</system:String>
|
||||
@@ -631,7 +634,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
|
||||
<!-- Api -->
|
||||
<system:String x:Key="ApiUpdateSuccess">Stage data retrieval successful</system:String>
|
||||
<system:String x:Key="GameResourceUpdated">Game resource updated, please restart MAA</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">Updating game resource, please wait……</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">Game resources are being updated. Please do not close MAA.</system:String>
|
||||
<!-- Api -->
|
||||
<system:String x:Key="Off">Off</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">Please note: The external notification feature currently only sends "All tasks completed" notifications.</system:String>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!-- 設定 -->
|
||||
<system:String x:Key="Settings">設定</system:String>
|
||||
<system:String x:Key="GeneralSettings">一般設定</system:String>
|
||||
@@ -651,6 +654,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント
|
||||
<system:String x:Key="ExternalNotificationSmtpFrom">[SMTP] 送信者</system:String>
|
||||
<system:String x:Key="ExternalNotificationSmtpTo">[SMTP] 受信者</system:String>
|
||||
<system:String x:Key="UnsupportedLevel">サポートされていないレベルは、レベル名を確認してください!</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">ゲームリソースが更新中です。MAAを閉じないでください。</system:String>
|
||||
<system:String x:Key="GameResourceUpdated">ゲームリソースが更新されました。MAAを再起動してください</system:String>
|
||||
<system:String x:Key="ExternalNotificationEmailTemplateHello">ドクター、新しいお知らせがあります!</system:String>
|
||||
<system:String x:Key="ExternalNotificationEmailTemplateFooterLineOne">このメッセージが表示されるのは、MAA で SMTP サーバーをセットアップし、メール通知サービスを有効にしているためです。</system:String>
|
||||
|
||||
@@ -632,6 +632,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: Zhang San
|
||||
<!-- RootViewModel -->
|
||||
<!-- Api -->
|
||||
<system:String x:Key="ApiUpdateSuccess">스테이지 데이터 획득 성공</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">게임 자원이 업데이트 중입니다. MAA를 닫지 마십시오.</system:String>
|
||||
<!-- Api -->
|
||||
<system:String x:Key="GameResourceUpdating">게임 리소스가 업데이트되고 있으니 기다려 주십시오</system:String>
|
||||
<system:String x:Key="Processing">처리 스테이션</system:String>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!-- .Net 8 -->
|
||||
<system:String x:Key="Dotnet8">MAA 即将升级,升级后的版本不支持未安装 .NET 8.0 运行时 的电脑,需要您手动前往下载。\n\n同时,我们将不再支持 Windows 7 操作系统。\n\n如果您点击 '是',我们将为您打开新的运行时下载链接。如果您点击 '否',我们将禁用您的自动下载功能,以防止不必要的软件更新。如果您选择禁用自动下载,您仍然可以在软件设置中手动重新启用此功能。</system:String>
|
||||
<system:String x:Key="Dotnet8Caption">软件版本升级及支持变更</system:String>
|
||||
@@ -653,7 +656,7 @@
|
||||
<!-- Api -->
|
||||
<system:String x:Key="ApiUpdateSuccess">关卡数据获取成功</system:String>
|
||||
<system:String x:Key="GameResourceUpdated">游戏资源已更新,请重启 MAA</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">正在更新游戏资源,请耐心等待</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">游戏资源正在更新,请勿关闭 MAA</system:String>
|
||||
<!-- Api -->
|
||||
<!-- External Notification -->
|
||||
<system:String x:Key="ExternalNotificationEmailTemplateHello">博士,有新的通知哦!</system:String>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!-- .Net 8 -->
|
||||
<system:String x:Key="Dotnet8">MAA 即將升級,升級後的版本不支援未安裝 .NET 8.0 執行時 的電腦,需要您手動前往下載。\n\n同時,我們將不再支援 Windows 7 作業系統。\n\n如果您點擊 '是',我們將為您打開新的執行時下載連結。如果您點擊 '否',我們將停用您的自動下載功能,以防止不必要的軟體更新。如果您選擇停用自動下載,您仍然可以在軟體設定中手動重新開啟此功能。</system:String>
|
||||
<system:String x:Key="Dotnet8Caption">軟體版本升級及支援變更</system:String>
|
||||
@@ -660,6 +663,6 @@
|
||||
<system:String x:Key="ExternalNotificationTips">請注意:外部通知功能目前僅會發送「所有任務完成」 的通知。</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">外部通知</system:String>
|
||||
<system:String x:Key="ExternalNotificationSmtpTo">[SMTP] 收件者</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">正在更新遊戲資源,請耐心等待</system:String>
|
||||
<system:String x:Key="GameResourceUpdating">遊戲資源正在更新,請勿關閉 MAA</system:String>
|
||||
<system:String x:Key="UnsupportedLevel">不支持的關卡,請檢查關卡名!</system:String>
|
||||
</ResourceDictionary>
|
||||
|
||||
Reference in New Issue
Block a user