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 2a9941c commit 8764d52
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 6 deletions.
12 changes: 8 additions & 4 deletions PixivFSUWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public App()
private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
e.Handled = true;
if (localSettings.Values.ContainsKey("exception"))
localSettings.Values.Remove("exception");
localSettings.Values["exception"] = e.Exception.ToString();
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();
Expand Down Expand Up @@ -125,11 +128,12 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
rootFrame.Navigate(typeof(ReportIssuePage), e.Arguments);
}
else
{
rootFrame.Navigate(typeof(LoginPage), e.Arguments);
}
}
// 当导航堆栈尚未还原时,导航到第一页,
// 并通过将所需信息作为导航参数传入来配置
// 参数
rootFrame.Navigate(typeof(LoginPage), e.Arguments);
else rootFrame.Navigate(typeof(LoginPage), e.Arguments);
}
// 确保当前窗口处于活动状态
Window.Current.Activate();
Expand Down
24 changes: 23 additions & 1 deletion PixivFSUWP/ReportIssuePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="10" Orientation="Vertical">
<TextBlock Margin="15,15,15,0" FontSize="18" FontWeight="Bold">Report an issue/报告问题</TextBlock>
<TextBlock Margin="15,15,15,0">We've detected a crash in your last session. We've collected some details.</TextBlock>
<TextBlock Margin="15,5,15,0">我们在您的上次会话中探测到一次崩溃,我们收集了一些细节。</TextBlock>
</StackPanel>
<ScrollViewer Margin="25,15,25,0" Background="LightGray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
HorizontalScrollMode="Disabled" VerticalScrollBarVisibility="Visible" Grid.Row="1">
<TextBlock x:Name="txtDetails" Margin="10" TextWrapping="Wrap" HorizontalAlignment="Stretch"/>
</ScrollViewer>
<HyperlinkButton x:Name="btnCopy" Margin="25,0,25,0" Grid.Row="2" Click="BtnCopy_Click">Copy all/全部复制</HyperlinkButton>
<StackPanel Orientation="Vertical" Grid.Row="3">
<TextBlock Margin="25 10 25 0">Don't worry. The information you just copied does not contain any private data.</TextBlock>
<TextBlock Margin="25 5 25 0">不要担心,您刚刚所复制的信息不会携带您的任何隐私数据。</TextBlock>
<Button x:Name="btnGitHub" Margin="25 15 25 0" Background="#25c6ff" HorizontalAlignment="Stretch" Click="BtnGitHub_Click">Create a new issue on GitHub (RECOMMENDED)/在GitHub上创建新的Issue(推荐)</Button>
<Button x:Name="btnEmail" Margin="25 10 25 0" HorizontalAlignment="Stretch" Click="BtnEmail_Click">Send an Email to 🐟/给🐟发送邮件</Button>
<Button x:Name="btnContinue" Margin="25 10 25 25" HorizontalAlignment="Stretch" Click="BtnContinue_Click">Continue to Pixiv UWP/继续前往Pixiv UWP</Button>
</StackPanel>
</Grid>
</Page>
54 changes: 53 additions & 1 deletion PixivFSUWP/ReportIssuePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using System;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
Expand All @@ -25,6 +31,52 @@ public sealed partial class ReportIssuePage : Page
public ReportIssuePage()
{
this.InitializeComponent();
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values["exception"] == null)
{
Frame.Navigate(typeof(LoginPage));
return;
}
var lastExeption = (string)localSettings.Values["exception"];
var view = ApplicationView.GetForCurrentView();
view.Title = "Crash Report/崩溃报告";
txtDetails.Text += "General:\n";
txtDetails.Text += string.Format("OS version: build {0}\n", SystemInformation.OperatingSystemVersion.Build);
txtDetails.Text += string.Format("App version: {0}.{1}.{2} {3}\n",
Package.Current.Id.Version.Major,
Package.Current.Id.Version.Minor,
Package.Current.Id.Version.Build,
Package.Current.Id.Architecture);
txtDetails.Text += string.Format("Package ID: {0}\n\n", Package.Current.Id.Name);
txtDetails.Text += "Exception:\n";
txtDetails.Text += lastExeption;
}

private void BtnContinue_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(LoginPage));
}

private async void BtnCopy_Click(object sender, RoutedEventArgs e)
{
DataPackage dataPackage = new DataPackage();
dataPackage.RequestedOperation = DataPackageOperation.Copy;
dataPackage.SetText(txtDetails.Text);
Clipboard.SetContent(dataPackage);
MessageDialog dialog = new MessageDialog("Valuable information has been copied to clipboard./有价值的信息已经被复制到剪贴板。", "Copied/已复制");
await dialog.ShowAsync();
}

private async void BtnGitHub_Click(object sender, RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new
Uri(@"https://github.com/tobiichiamane/pixivfs-uwp/issues/new"));
}

private async void BtnEmail_Click(object sender, RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new
Uri(@"mailto:[email protected]"));
}
}
}

0 comments on commit 8764d52

Please sign in to comment.