Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
添加错误报告页
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed Sep 20, 2019
1 parent 5079edc commit 2a9941c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
23 changes: 21 additions & 2 deletions PixivFSUWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace PixivFSUWP
/// </summary>
sealed partial class App : Application
{
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

/// <summary>
/// 初始化单一实例应用程序对象。这是执行的创作代码的第一行,
/// 已执行,逻辑上等同于 main() 或 WinMain()。
Expand All @@ -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();
}
Expand Down Expand Up @@ -81,7 +84,7 @@ protected override void OnActivated(IActivatedEventArgs args)
/// 将在启动应用程序以打开特定文件等情况下使用。
/// </summary>
/// <param name="e">有关启动请求和过程的详细信息。</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;

Expand All @@ -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);
}
}
// 当导航堆栈尚未还原时,导航到第一页,
// 并通过将所需信息作为导航参数传入来配置
// 参数
Expand Down
7 changes: 7 additions & 0 deletions PixivFSUWP/PixivFSUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReportIssuePage.xaml.cs">
<DependentUpon>ReportIssuePage.xaml</DependentUpon>
</Compile>
<Compile Include="SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -236,6 +239,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ReportIssuePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SearchPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
14 changes: 14 additions & 0 deletions PixivFSUWP/ReportIssuePage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page
x:Class="PixivFSUWP.ReportIssuePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PixivFSUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>

</Grid>
</Page>
30 changes: 30 additions & 0 deletions PixivFSUWP/ReportIssuePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class ReportIssuePage : Page
{
public ReportIssuePage()
{
this.InitializeComponent();
}
}
}

0 comments on commit 2a9941c

Please sign in to comment.