mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat: 日志包一并打包gui配置文件 (#12310)
* feat: 日志包一并打包gui配置文件 (#12310) * perf: 复制调整 * chore: Auto update by pre-commit hooks [skip changelog] --------- Co-authored-by: BxFS <15606086+BxFS@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3128,8 +3128,8 @@
|
||||
"template": "MedicineConfirm.png",
|
||||
"reduceOtherTimes": [],
|
||||
"postDelay": 500,
|
||||
"exceededNext": [ "CloseStonePage" ],
|
||||
"next": [ "StoneConfirmWait", "StoneConfirm#next" ]
|
||||
"exceededNext": ["CloseStonePage"],
|
||||
"next": ["StoneConfirmWait", "StoneConfirm#next"]
|
||||
},
|
||||
"NoStone": {
|
||||
"roi": [800, 250, 350, 250],
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace MaaWpfGui.Configuration
|
||||
{
|
||||
public static class ConfigFactory
|
||||
{
|
||||
private static readonly string _configurationFile = Path.Combine(Environment.CurrentDirectory, "config/gui.new.json");
|
||||
public const string ConfigFileName = "config/gui.new.json";
|
||||
private static readonly string _configurationFile = Path.Combine(Environment.CurrentDirectory, ConfigFileName);
|
||||
|
||||
// TODO: write backup method. WIP: https://github.com/Cryolitia/MaaAssistantArknights/tree/config
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace MaaWpfGui.Helper
|
||||
{
|
||||
public class ConfigurationHelper
|
||||
{
|
||||
private static readonly string _configurationFile = Path.Combine(Environment.CurrentDirectory, "config/gui.json");
|
||||
public const string ConfigurationFile = "config/gui.json";
|
||||
private static readonly string _configurationFile = Path.Combine(Environment.CurrentDirectory, ConfigurationFile);
|
||||
private static readonly string _configurationBakFile = Path.Combine(Environment.CurrentDirectory, "config/gui.json.bak");
|
||||
private static readonly string _configurationErrorFile = Path.Combine(Environment.CurrentDirectory, "config/gui.error.json");
|
||||
private static ConcurrentDictionary<string, ConcurrentDictionary<string, string>> _kvsMap;
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace MaaWpfGui.Main
|
||||
|
||||
private static Mutex _mutex;
|
||||
private static bool _hasMutex;
|
||||
public const string LogFilename = "debug/gui.log";
|
||||
public const string LogBakFilename = "debug/gui.bak.log";
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <remarks>初始化些啥自己加。</remarks>
|
||||
@@ -66,8 +68,6 @@ namespace MaaWpfGui.Main
|
||||
Directory.CreateDirectory("debug");
|
||||
}
|
||||
|
||||
const string LogFilename = "debug/gui.log";
|
||||
const string LogBakFilename = "debug/gui.bak.log";
|
||||
if (File.Exists(LogFilename) && new FileInfo(LogFilename).Length > 4 * 1024 * 1024)
|
||||
{
|
||||
if (File.Exists(LogBakFilename))
|
||||
|
||||
@@ -19,7 +19,9 @@ using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
using MaaWpfGui.Configuration;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using Serilog;
|
||||
using Stylet;
|
||||
|
||||
@@ -35,21 +37,21 @@ public class IssueReportUserControlModel : PropertyChangedBase
|
||||
Instance = new();
|
||||
}
|
||||
|
||||
private static readonly string[] LogFileNames = ["gui.log", "gui.bak.log", "asst.log", "asst.bak.log"];
|
||||
private static readonly string[] PayloadFileNames = [Bootstrapper.LogFilename, Bootstrapper.LogBakFilename, "debug/asst.log", "debug/asst.bak.log", ConfigurationHelper.ConfigurationFile, ConfigFactory.ConfigFileName];
|
||||
private const string DebugDir = "debug";
|
||||
|
||||
public static IssueReportUserControlModel Instance { get; }
|
||||
|
||||
public void OpenDebugFolder()
|
||||
{
|
||||
string path = "debug";
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
if (!Directory.Exists(DebugDir))
|
||||
{
|
||||
Directory.CreateDirectory("debug");
|
||||
Directory.CreateDirectory(DebugDir);
|
||||
}
|
||||
|
||||
Process.Start("explorer.exe", path);
|
||||
Process.Start("explorer.exe", DebugDir);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -62,39 +64,34 @@ public class IssueReportUserControlModel : PropertyChangedBase
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = "debug";
|
||||
string zipPath = Path.Combine(path, "log.zip");
|
||||
string tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory("debug");
|
||||
return;
|
||||
}
|
||||
|
||||
string zipPath = Path.Combine(DebugDir, $"report_{DateTimeOffset.Now:MM-dd_HH-mm-ss}.zip");
|
||||
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
if (File.Exists(zipPath))
|
||||
{
|
||||
File.Delete(zipPath);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(tempDir);
|
||||
foreach (var file in Directory.EnumerateFiles(path, "*.log").Where(f => LogFileNames.Contains(Path.GetFileName(f))))
|
||||
Directory.CreateDirectory(tempPath);
|
||||
foreach (var file in PayloadFileNames)
|
||||
{
|
||||
string dest = Path.Combine(tempDir, Path.GetFileName(file));
|
||||
File.Copy(file, dest, overwrite: true);
|
||||
if (File.Exists(file))
|
||||
{
|
||||
string dest = Path.Combine(tempPath, Path.GetFileName(file));
|
||||
File.Copy(file, dest, overwrite: true);
|
||||
}
|
||||
}
|
||||
|
||||
using (FileStream zipToOpen = new FileStream(zipPath, FileMode.Create))
|
||||
{
|
||||
using var archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create);
|
||||
foreach (var file in Directory.GetFiles(tempDir))
|
||||
foreach (var file in Directory.GetFiles(tempPath))
|
||||
{
|
||||
string entryName = Path.GetFileName(file);
|
||||
archive.CreateEntryFromFile(file, entryName, CompressionLevel.Optimal);
|
||||
}
|
||||
}
|
||||
|
||||
Directory.Delete(tempDir, recursive: true);
|
||||
Directory.Delete(tempPath, recursive: true);
|
||||
ShowGrowl(LocalizationHelper.GetString("GenerateSupportPayloadSuccessful"));
|
||||
OpenDebugFolder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user