Skip to content

Commit

Permalink
Optimize feedback workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Jul 22, 2024
1 parent ad2e5cb commit 48a4efb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
26 changes: 21 additions & 5 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using MessageBoxImage = AdonisUI.Controls.MessageBoxImage;
using System.Diagnostics;
using System.Windows.Navigation;
using Org.BouncyCastle.Bcpg.Sig;
using NLog.Targets;

namespace SoulsModTranslator
Expand All @@ -20,7 +19,7 @@ public partial class MainWindow : AdonisWindow
{
private static readonly string DbPath = Path.Combine(Directory.GetCurrentDirectory(), "db");
private static readonly string GlossaryPath = Path.Combine(Directory.GetCurrentDirectory(), "glossaries");
private static readonly string SoftwareName = "魂游MOD翻译工具 v2.7";
private static readonly string SoftwareName = "魂游MOD翻译工具 v2.8";

private static MemoryTarget MemoryTarget = new MemoryTarget
{
Expand All @@ -30,8 +29,6 @@ public partial class MainWindow : AdonisWindow

private static void ShowTaskResult(bool success, string succMsg, string failMsg)
{
// var caption = success ? "提示" : "错误";
// var icon = success ? MessageBoxImage.Information : MessageBoxImage.Error;
if (success)
{
AdonisUI.Controls.MessageBox.Show(success ? succMsg : failMsg, "提示",
Expand All @@ -53,7 +50,25 @@ private static void ShowTaskResult(bool success, string succMsg, string failMsg)
AdonisUI.Controls.MessageBoxButtons.Custom("关闭", "close"),
},
};
AdonisUI.Controls.MessageBox.Show(messageBox);
var result = AdonisUI.Controls.MessageBox.Show(messageBox);
if (messageBox.Result == AdonisUI.Controls.MessageBoxResult.Custom)
{
var prompt = "[请在这里礼貌且清晰地描述你遇到的问题。] 以下是错误消息和日志。\n";
var text = "错误消息: " + failMsg + "\n日志:\n" + log;
if (messageBox.ButtonPressed.Id.ToString() == "github")
{
System.Windows.Clipboard.SetText(prompt + "```\n" + text + "\n```");
Utils.OpenURL("https://github.com/hhhxiao/SoulsModTranslator/issues/new");
}
else if (messageBox.ButtonPressed.Id.ToString() == "bilibili")
{

System.Windows.Clipboard.SetText(prompt + text);
Utils.OpenURL("https://www.bilibili.com/video/BV17p421Q7qJ/");
}
}

MemoryTarget.Logs.Clear();
}

private static List<string> LoadDbFiles()
Expand Down Expand Up @@ -105,6 +120,7 @@ public MainWindow()

Logger.Info("\n\n===========================New Instance===================================");
CreateArrayLogger();
Logger.Info(SoftwareName);
InitializeComponent();
//
Glossaries = new ObservableCollection<string>();
Expand Down
4 changes: 3 additions & 1 deletion core/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ private static Action<string, int, string, int> CreateTraverser(DB db, Action<lo

public static ExportResult Export(string rootPath, string dbPath)
{
Logger.Info($"开始导出未翻译文本,msg根目录:{rootPath},数据库路径:{dbPath}");
Logger.Info($"开始导出未翻译文本");
Logger.Info($"msg根目录:{rootPath}");
Logger.Info($"数据库路径:{dbPath}");
var result = new ExportResult
{
Success = false
Expand Down
18 changes: 18 additions & 0 deletions core/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.IO;
using System.Text.Json;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -58,4 +59,21 @@ public static double GetChineseCharacterRatio(string text)
int chineseCharacterCount = Regex.Matches(text, @"[\u4e00-\u9fff]").Count;
return (double)chineseCharacterCount / totalLength;
}

public static void OpenURL(string url)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
}
catch (Exception ex)
{
Logger.Error($"Unable to open link: {ex.Message}");
}

}
}

0 comments on commit 48a4efb

Please sign in to comment.