diff --git a/JiayiLauncher/JiayiLauncher.csproj b/JiayiLauncher/JiayiLauncher.csproj
index cbace72..3e0a4c1 100644
--- a/JiayiLauncher/JiayiLauncher.csproj
+++ b/JiayiLauncher/JiayiLauncher.csproj
@@ -135,4 +135,10 @@
+
+
+ Always
+
+
+
diff --git a/JiayiLauncher/Platforms/Windows/App.xaml.cs b/JiayiLauncher/Platforms/Windows/App.xaml.cs
index da87b63..1aa6877 100644
--- a/JiayiLauncher/Platforms/Windows/App.xaml.cs
+++ b/JiayiLauncher/Platforms/Windows/App.xaml.cs
@@ -1,11 +1,7 @@
-using System.Diagnostics;
+using JiayiLauncher.Utils;
+using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
-using Blazored.Toast;
-using Blazored.Toast.Services;
-using JiayiLauncher.Shared.Components.Toasts;
-using JiayiLauncher.Utils;
-using Microsoft.AspNetCore.Components;
using static JiayiLauncher.Utils.Imports;
namespace JiayiLauncher.Platforms.Windows;
@@ -18,15 +14,15 @@ public partial class App : MauiWinUIApplication
public App()
{
InitializeComponent();
-
+
// the first singletons
var log = Singletons.Add();
var arguments = Singletons.Add();
-
+
// log current version
var version = Assembly.GetExecutingAssembly().GetName().Version ?? new Version(0, 0, 0);
log.Write("JiayiLauncher", $"Running version {version.Major}.{version.Minor}.{version.Build}");
-
+
_mutex = new Mutex(true, "Global\\JiayiLauncher", out var createdNew);
if (createdNew) // only one instance of the launcher
@@ -41,39 +37,69 @@ public App()
"at Microsoft.AspNetCore.Components.WebView.WebView2.WebView2WebViewManager.SendMessage(String message)",
"System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request."
};
-
- AppDomain.CurrentDomain.FirstChanceException += (_, ex) =>
+
+ AppDomain.CurrentDomain.FirstChanceException += async (_, ex) =>
{
var exception = ex.Exception.ToString();
if (suppressed.Any(exception.Contains)) return;
-
+
log.Write(ex.Exception, exception, Log.LogLevel.Error);
var windowHandle = FindWindowW(null, "Jiayi Launcher");
var result = MessageBoxW(
- windowHandle,
+ windowHandle,
"""
Jiayi has ran into an issue and needs to close. Please send your log file to the nearest developer.
- Would you like to open the log folder? Your log file is saved as 'Current.log'.
- """,
- "Crash",
+ Would you like to anonymously upload your current log file?
+ """,
+ "Crash",
+ 0x00000004 | 0x00000010);
+
+ if (result == 6) // yes
+ {
+ string current_log = Path.Join(Log.LogPath, "Current.log");
+ if (File.Exists(current_log))
+ {
+ string upload_bat = Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upload.bat");
+
+ ProcessStartInfo psi = new ProcessStartInfo
+ {
+ FileName = upload_bat,
+ WindowStyle = ProcessWindowStyle.Minimized,
+ CreateNoWindow = true,
+ UseShellExecute = true
+ };
+ Process.Start(psi);
+ }
+ }
+
+ result = MessageBoxW(
+ windowHandle,
+ """
+ Would you like to open the log folder?
+
+ Your log file is saved as 'Current.log'.
+ """,
+ "Crash",
0x00000004 | 0x00000010);
-
+
if (result == 6) // yes
{
Process.Start("explorer.exe", Log.LogPath);
}
-
+
+
+
Environment.Exit(1);
};
-
+
return;
}
-
+
// send arguments to the running instance
var ptr = Marshal.StringToHGlobalUni(arguments.Get());
-
+
var hWnd = FindWindowW(null, "Jiayi Launcher");
if (hWnd != nint.Zero)
{
@@ -81,13 +107,13 @@ Would you like to open the log folder? Your log file is saved as 'Current.log'.
cds.dwData = 1;
cds.cbData = (uint)((arguments.Get().Length + 1) * 2);
cds.lpData = ptr;
-
+
var pCds = Marshal.AllocHGlobal(Marshal.SizeOf());
Marshal.StructureToPtr(cds, pCds, false);
SendMessage(hWnd, 0x004A, 0, pCds);
}
-
+
Marshal.FreeHGlobal(ptr);
Environment.Exit(0);
}
diff --git a/JiayiLauncher/upload.bat b/JiayiLauncher/upload.bat
new file mode 100644
index 0000000..0d9ffe2
--- /dev/null
+++ b/JiayiLauncher/upload.bat
@@ -0,0 +1,32 @@
+@echo off
+setlocal
+
+:: Check if file path is provided
+if "%~1"=="" (
+ echo Usage: upload_log.bat "C:\path\to\Current.log"
+ exit /b 1
+)
+
+:: Store the file path
+set FILE_PATH=%~1
+
+:: Check if file exists
+if not exist "%FILE_PATH%" (
+ echo Error: File not found - %FILE_PATH%
+ exit /b 1
+)
+
+:: API endpoint
+set API_URL=https://jiayi-api.vercel.app/api/v1/webhook/error-from-file
+
+:: Perform the file upload using curl
+curl -X POST "%API_URL%" -F "file=@%FILE_PATH%" -H "Content-Type: multipart/form-data"
+
+:: Check if the command was successful
+if %ERRORLEVEL% NEQ 0 (
+ echo Upload failed.
+ exit /b %ERRORLEVEL%
+)
+
+echo Upload successful!
+exit /b 0