diff --git a/PixivFSUWP/App.xaml.cs b/PixivFSUWP/App.xaml.cs index 1c63497..9f3aaa4 100644 --- a/PixivFSUWP/App.xaml.cs +++ b/PixivFSUWP/App.xaml.cs @@ -23,6 +23,8 @@ namespace PixivFSUWP /// sealed partial class App : Application { + Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; + /// /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, /// 已执行,逻辑上等同于 main() 或 WinMain()。 @@ -37,7 +39,8 @@ public App() private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) { e.Handled = true; - MessageDialog dialog = new MessageDialog(string.Format("Unhandled Execption: {0}\nPlease screenshot for later use.", e.Exception.Message), "Exception"); + localSettings.Values["isCrashed"] = true; + MessageDialog dialog = new MessageDialog("Pixiv UWP has crashed. Please restart this app in order to report this issue.\n程序已崩溃,请重启本应用以便于报告此问题。", "Crashed/程序崩溃"); await dialog.ShowAsync(); this.Exit(); } @@ -81,7 +84,7 @@ protected override void OnActivated(IActivatedEventArgs args) /// 将在启动应用程序以打开特定文件等情况下使用。 /// /// 有关启动请求和过程的详细信息。 - protected override void OnLaunched(LaunchActivatedEventArgs e) + protected override async void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; @@ -107,6 +110,22 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) { if (rootFrame.Content == null) { + //检测上次的崩溃 + if (localSettings.Values["isCrashed"] != null && (bool)localSettings.Values["isCrashed"] == true) + { + localSettings.Values.Remove("isCrashed"); + var yesCommand = new UICommand("Yes/是"); + var noCommand = new UICommand("No/否"); + MessageDialog dialog = new MessageDialog("A crash has been detected in your last session. Do you want to report this issue?\n在您上次的会话中我们探测到一次崩溃。请问您要报告此问题吗?", "Crash Report/错误报告"); + dialog.Commands.Add(yesCommand); + dialog.Commands.Add(noCommand); + dialog.DefaultCommandIndex = 0; + var cmd = await dialog.ShowAsync(); + if (cmd == yesCommand) + { + rootFrame.Navigate(typeof(ReportIssuePage), e.Arguments); + } + } // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 diff --git a/PixivFSUWP/PixivFSUWP.csproj b/PixivFSUWP/PixivFSUWP.csproj index 3f77e57..4801149 100644 --- a/PixivFSUWP/PixivFSUWP.csproj +++ b/PixivFSUWP/PixivFSUWP.csproj @@ -170,6 +170,9 @@ MainPage.xaml + + ReportIssuePage.xaml + SearchPage.xaml @@ -236,6 +239,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/PixivFSUWP/ReportIssuePage.xaml b/PixivFSUWP/ReportIssuePage.xaml new file mode 100644 index 0000000..75a00da --- /dev/null +++ b/PixivFSUWP/ReportIssuePage.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/PixivFSUWP/ReportIssuePage.xaml.cs b/PixivFSUWP/ReportIssuePage.xaml.cs new file mode 100644 index 0000000..fffdde1 --- /dev/null +++ b/PixivFSUWP/ReportIssuePage.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 + +namespace PixivFSUWP +{ + /// + /// 可用于自身或导航至 Frame 内部的空白页。 + /// + public sealed partial class ReportIssuePage : Page + { + public ReportIssuePage() + { + this.InitializeComponent(); + } + } +}