diff --git a/3rdparty/bin/aria2c.exe b/3rdparty/bin/aria2c.exe
new file mode 100644
index 0000000000..38caa6ab31
Binary files /dev/null and b/3rdparty/bin/aria2c.exe differ
diff --git a/src/MeoAssistance/Version.h b/src/MeoAssistance/Version.h
index 4267cda6fc..8c66dc1375 100644
--- a/src/MeoAssistance/Version.h
+++ b/src/MeoAssistance/Version.h
@@ -2,5 +2,5 @@
namespace asst
{
- constexpr static const char* Version = "v2.1.2";
+ constexpr static const char* Version = "v2.1.3";
}
diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs
index 1608478952..9592010e86 100644
--- a/src/MeoAsstGui/Helper/AsstProxy.cs
+++ b/src/MeoAsstGui/Helper/AsstProxy.cs
@@ -246,7 +246,7 @@ namespace MeoAsstGui
case AsstMsg.RecruitSpecialTag:
string special = detail["tag"].ToString();
- new ToastContentBuilder().AddText("公招特殊Tag:" + special).Show();
+ new ToastContentBuilder().AddText("公招提示:" + special).Show();
break;
case AsstMsg.RecruitResult:
diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj
index 3b0ace33cb..7cf7b1e3ff 100644
--- a/src/MeoAsstGui/MeoAsstGui.csproj
+++ b/src/MeoAsstGui/MeoAsstGui.csproj
@@ -132,6 +132,9 @@
PenguinReportSettingsUserControl.xaml
+
+ VersionUpdateSettingsUserControl.xaml
+
@@ -169,6 +172,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/src/MeoAsstGui/UserControl/AutoRecruitSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/AutoRecruitSettingsUserControl.xaml
index 0032e2e481..870c6eb79c 100644
--- a/src/MeoAsstGui/UserControl/AutoRecruitSettingsUserControl.xaml
+++ b/src/MeoAsstGui/UserControl/AutoRecruitSettingsUserControl.xaml
@@ -13,12 +13,6 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MeoAsstGui/UserControl/PenguinReportSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/PenguinReportSettingsUserControl.xaml
index 15ac7a8012..e0c484e88d 100644
--- a/src/MeoAsstGui/UserControl/PenguinReportSettingsUserControl.xaml
+++ b/src/MeoAsstGui/UserControl/PenguinReportSettingsUserControl.xaml
@@ -9,7 +9,7 @@
d:DesignHeight="300" d:DesignWidth="550">
-
diff --git a/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml
new file mode 100644
index 0000000000..f22253213c
--- /dev/null
+++ b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml.cs
new file mode 100644
index 0000000000..88d55ea268
--- /dev/null
+++ b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml.cs
@@ -0,0 +1,26 @@
+// MeoAssistanceGui - A part of the MeoAssistance-Arknight project
+// Copyright (C) 2021 MistEO and Contributors
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using System.Windows.Controls;
+
+namespace MeoAsstGui
+{
+ ///
+ /// PenguinReportSettingsUserControl.xaml 的交互逻辑
+ ///
+ public partial class VersionUpdateSettingsUserControl : UserControl
+ {
+ public VersionUpdateSettingsUserControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/MeoAsstGui/ViewModels/RootViewModel.cs b/src/MeoAsstGui/ViewModels/RootViewModel.cs
index ec5bc96b58..0fac4a11f1 100644
--- a/src/MeoAsstGui/ViewModels/RootViewModel.cs
+++ b/src/MeoAsstGui/ViewModels/RootViewModel.cs
@@ -61,7 +61,10 @@ namespace MeoAsstGui
{
var task = Task.Run(() =>
{
- return vuvm.CheckAndDownloadUpdate();
+ if (!vuvm.CheckAndDownloadUpdate())
+ {
+ vuvm.ResourceOTA();
+ }
});
await task;
diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs
index 9bb6325bf1..30aa507dc4 100644
--- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs
+++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs
@@ -9,9 +9,10 @@
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Threading.Tasks;
+using System.Runtime.InteropServices;
using Stylet;
using StyletIoC;
@@ -22,17 +23,26 @@ namespace MeoAsstGui
private IWindowManager _windowManager;
private IContainer _container;
+ [DllImport("MeoAssistance.dll")] private static extern IntPtr AsstGetVersion();
+
+ private string _versionInfo = "版本号:" + Marshal.PtrToStringAnsi(AsstGetVersion());
+
+ public string VersionInfo
+ {
+ get { return _versionInfo; }
+ }
+
public SettingsViewModel(IContainer container, IWindowManager windowManager)
{
_container = container;
_windowManager = windowManager;
DisplayName = "设置";
- _listTitle.Add("基建");
+ _listTitle.Add("基建设置");
_listTitle.Add("自动公招");
_listTitle.Add("信用商店");
_listTitle.Add("企鹅数据");
- //_listTitle.Add("连接");
+ _listTitle.Add("软件更新");
//_listTitle.Add("其他");
InfrastInit();
@@ -268,7 +278,7 @@ namespace MeoAsstGui
/* 信用商店设置 */
- private bool _creditShopping = System.Convert.ToBoolean(ViewStatusStorage.Get("Mall.CreditShopping", bool.FalseString));
+ private bool _creditShopping = System.Convert.ToBoolean(ViewStatusStorage.Get("Mall.CreditShopping", bool.TrueString));
public bool CreditShopping
{
@@ -354,5 +364,30 @@ namespace MeoAsstGui
ViewStatusStorage.Set("AutoRecruit.ChooseLevel5", value.ToString());
}
}
+
+ /* 软件更新设置 */
+ private bool _updateBeta = System.Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.UpdateBeta", bool.FalseString));
+
+ public bool UpdateBeta
+ {
+ get { return _updateBeta; }
+ set
+ {
+ SetAndNotify(ref _updateBeta, value);
+ ViewStatusStorage.Set("VersionUpdate.UpdateBeta", value.ToString());
+ }
+ }
+
+ private string _proxy = ViewStatusStorage.Get("VersionUpdate.Proxy", "");
+
+ public string Proxy
+ {
+ get { return _proxy; }
+ set
+ {
+ SetAndNotify(ref _proxy, value);
+ ViewStatusStorage.Set("VersionUpdate.Proxy", value);
+ }
+ }
}
}
diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
index dba61b99ef..40ed1e5a8c 100644
--- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
+++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
+using StyletIoC;
+
+using System.Diagnostics;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
@@ -15,9 +18,11 @@ namespace MeoAsstGui
public class VersionUpdateViewModel : Screen
{
private IWindowManager _windowManager;
+ private IContainer _container;
- public VersionUpdateViewModel(IWindowManager windowManager)
+ public VersionUpdateViewModel(IContainer container, IWindowManager windowManager)
{
+ _container = container;
_windowManager = windowManager;
}
@@ -87,7 +92,8 @@ namespace MeoAsstGui
}
private const string _requestUrl = "https://api.github.com/repos/MistEO/MeoAssistance-Arknights/releases/latest";
- private const string _viewUrl = "https://github.com/MistEO/MeoAssistance-Arknights/releases/latest";
+ private const string _requestBetaUrl = "https://api.github.com/repos/MistEO/MeoAssistance-Arknights/releases";
+ private string _viewUrl;
private JObject _lastestJson;
private string _downloadUrl;
@@ -179,7 +185,7 @@ namespace MeoAsstGui
.AddButton(openUrlToastButton)
.Show();
// 下载压缩包
- const int downloadRetryMaxTimes = 5;
+ const int downloadRetryMaxTimes = 1;
string downloadTempFilename = UpdatePackageName + ".tmp";
bool downloaded = false;
for (int i = 0; i != downloadRetryMaxTimes; ++i)
@@ -194,11 +200,11 @@ namespace MeoAsstGui
{
new ToastContentBuilder()
.AddText("新版本下载失败")
- .AddText("请尝试手动下载后,将压缩包放到exe同级目录_(:з」∠)_")
+ .AddText("请尝试手动下载后,将压缩包放到目录下_(:з」∠)_")
.AddButton(openUrlToastButton)
.Show();
return false;
- }
+ }
File.Copy(downloadTempFilename, UpdatePackageName, true);
File.Delete(downloadTempFilename);
// 把相关信息存下来,更新完之后启动的时候显示
@@ -211,12 +217,20 @@ namespace MeoAsstGui
}
public bool CheckUpdate()
- {
+ {
+ var settings = _container.Get();
string response = string.Empty;
const int requestRetryMaxTimes = 5;
for (int i = 0; i != requestRetryMaxTimes; ++i)
{
- response = RequestApi(_requestUrl);
+ if (settings.UpdateBeta)
+ {
+ response = RequestApi(_requestBetaUrl);
+ }
+ else
+ {
+ response = RequestApi(_requestUrl);
+ }
if (response.Length != 0)
{
break;
@@ -226,8 +240,19 @@ namespace MeoAsstGui
{
return false;
}
- JObject json = (JObject)JsonConvert.DeserializeObject(response);
-
+ JObject json;
+
+ if (settings.UpdateBeta)
+ {
+ JArray all = (JArray)JsonConvert.DeserializeObject(response);
+ json = (JObject)all[0];
+ }
+ else
+ {
+ json = (JObject)JsonConvert.DeserializeObject(response);
+ }
+
+ _viewUrl = json["html_url"].ToString();
_latestVersion = json["tag_name"].ToString();
if (string.Compare(_latestVersion, _curVersion) <= 0
|| ViewStatusStorage.Get("VersionUpdate.Ignore", string.Empty) == _latestVersion)
@@ -242,63 +267,115 @@ namespace MeoAsstGui
_downloadUrl = downUrl;
_lastestJson = json;
return true;
- }
- }
+ }
+ }
return false;
}
- private string RequestApi(string url)
- {
- HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
- httpWebRequest.Method = "GET";
- httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36";
- httpWebRequest.Accept = "application/vnd.github.v3+json";
- //httpWebRequest.Timeout = 20000;
- try
- {
- HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
- StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8);
- string responseContent = streamReader.ReadToEnd();
- streamReader.Close();
- httpWebResponse.Close();
- return responseContent;
- }
- catch (Exception)
- {
- return string.Empty;
- }
+ private string RequestApi(string url)
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
+ httpWebRequest.Method = "GET";
+ httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36";
+ httpWebRequest.Accept = "application/vnd.github.v3+json";
+ var settings = _container.Get();
+ if (settings.Proxy.Length > 0)
+ {
+ httpWebRequest.Proxy = new WebProxy(settings.Proxy);
+ }
+ //httpWebRequest.Timeout = 20000;
+ try
+ {
+ HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
+ StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8);
+ string responseContent = streamReader.ReadToEnd();
+ streamReader.Close();
+ httpWebResponse.Close();
+ return responseContent;
+ }
+ catch (Exception)
+ {
+ return string.Empty;
+ }
}
-
- private bool DownloadFile(string url, string path)
- {
- HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
- httpWebRequest.Method = "GET";
- httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36";
- httpWebRequest.Accept = "application/vnd.github.v3+json";
- httpWebRequest.Timeout = 20 * 1000;
- try
- {
- HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
- Stream reponseStream = httpWebResponse.GetResponseStream();
- Stream fileStream = new FileStream(path, FileMode.Create);
- byte[] bArr = new byte[4096];
- int size = reponseStream.Read(bArr, 0, (int)bArr.Length);
- while (size > 0)
- {
- fileStream.Write(bArr, 0, size);
- size = reponseStream.Read(bArr, 0, (int)bArr.Length);
- };
- fileStream.Close();
- reponseStream.Close();
- httpWebResponse.Close();
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
-
+
+ private bool DownloadFile(string url, string filename)
+ {
+ string cmd = Environment.CurrentDirectory + "\\aria2c.exe";
+ string args = "-c " + url + " -o " + filename;
+
+ var settings = _container.Get();
+ if (settings.Proxy.Length > 0)
+ {
+ args += " --all-proxy " + settings.Proxy;
+ }
+
+ int exit_code = -1;
+
+ ProcessStartInfo startInfo = new ProcessStartInfo();
+ startInfo.FileName = cmd;
+ startInfo.Arguments = args;
+ startInfo.RedirectStandardOutput = true;
+ startInfo.RedirectStandardError = true;
+ startInfo.UseShellExecute = false;
+ startInfo.CreateNoWindow = true;
+
+ Process processTemp = new Process();
+ processTemp.StartInfo = startInfo;
+ processTemp.EnableRaisingEvents = true;
+ try
+ {
+ processTemp.Start();
+ processTemp.WaitForExit();
+ exit_code = processTemp.ExitCode;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+
+ return exit_code == 0;
+ }
+
+ public bool ResourceOTA()
+ {
+ const string base_url = "https://raw.githubusercontent.com/MistEO/MeoAssistance-Arknights/master/";
+ var update_dict = new Dictionary()
+ {
+ { "3rdparty/resource/penguin-stats-recognize/json/stages.json" , "resource/penguin-stats-recognize/json/stages.json"},
+ { "resource/recruit.json", "resource/recruit.json" }
+ };
+ bool updated = false;
+ foreach (var item in update_dict)
+ {
+ string url = base_url + item.Key;
+ string filename = item.Value;
+ string tempname = filename + ".tmp";
+ if (!DownloadFile(url, tempname))
+ {
+ continue;
+ }
+ string src = File.ReadAllText(filename).Replace("\r\n", "\n");
+ string tmp = File.ReadAllText(tempname).Replace("\r\n", "\n");
+
+ if (src.Length < tmp.Length)
+ {
+ File.Copy(tempname, filename, true);
+ updated = true;
+ }
+ File.Delete(tempname);
+ }
+ if (updated)
+ {
+ new ToastContentBuilder().AddText("资源文件已更新").AddText("下次启动软件生效!").Show();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
private static void CopyFilesRecursively(string sourcePath, string targetPath)
{
//Now Create all of the directories
@@ -312,14 +389,14 @@ namespace MeoAsstGui
{
File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true);
}
- }
-
- public void Close()
- {
- RequestClose();
- IsFirstBootAfterUpdate = false;
- UpdateTag = "";
- UpdateInfo = "";
+ }
+
+ public void Close()
+ {
+ RequestClose();
+ IsFirstBootAfterUpdate = false;
+ UpdateTag = "";
+ UpdateInfo = "";
}
}
}
diff --git a/src/MeoAsstGui/Views/SettingsView.xaml b/src/MeoAsstGui/Views/SettingsView.xaml
index 02acb28888..cdce480e22 100644
--- a/src/MeoAsstGui/Views/SettingsView.xaml
+++ b/src/MeoAsstGui/Views/SettingsView.xaml
@@ -32,6 +32,9 @@
+
+
+
diff --git a/tools/zip_release.sh b/tools/zip_release.sh
index b4927a5560..f71ac6f915 100644
--- a/tools/zip_release.sh
+++ b/tools/zip_release.sh
@@ -3,4 +3,4 @@ LatestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
Package="../x64/MeoAssistance_"$LatestTag".zip"
cp ./*.url $TargetDir
-7z.exe a $Package $TargetDir/resource $TargetDir/*.dll $TargetDir/MeoAsstGui.exe $TargetDir/*.url
\ No newline at end of file
+7z.exe a $Package $TargetDir/resource $TargetDir/*.dll $TargetDir/aria2c.exe $TargetDir/MeoAsstGui.exe $TargetDir/*.url
\ No newline at end of file