Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
hupo376787 committed Nov 6, 2024
1 parent a61e7e0 commit 6103d67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions WeiboAlbumDownloader/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptio
e.Handled = true;
}

private void OnStartup(object sender, StartupEventArgs e)
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SentrySdk.ConfigureScope(scope =>
{
scope.SetTag("AppName", Assembly.GetExecutingAssembly().GetName().Name!);
scope.SetTag("DeviceName", Environment.MachineName);
scope.SetTag("AppVersion", GlobalVar.currentVersion.ToString("#0.0"));
scope.SetTag("DeviceName", WeiboAlbumDownloader.MainWindow.currentVersion.ToString("#0.0"));
});
}

Expand Down
2 changes: 0 additions & 2 deletions WeiboAlbumDownloader/GlobalVar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ namespace WeiboAlbumDownloader
{
public class GlobalVar
{
public static double currentVersion = 3.7;

public static string gId = "";
public static long gSinceId;
public static int gPage;
Expand Down
9 changes: 5 additions & 4 deletions WeiboAlbumDownloader/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public partial class MainWindow : MicaWindow
//①此处升级一下GlobalVar版本号
//②Github/Gitee release新建一个新版本Tag
//③上传压缩包删除Settings.json以及uidList.txt
public static double currentVersion = 3.7;

/// <summary>
/// com1是根据uid获取相册id,https://photo.weibo.com/albums/get_all?uid=10000000000&page=1;根据uid和相册id以及相册type获取图片列表,https://photo.weibo.com/photos/get_all?uid=10000000000&album_id=3959362334782071&page=1&type=3
Expand Down Expand Up @@ -93,19 +94,19 @@ private async Task GetVersion()
{
latestVersionString = await GithubHelper.GetGiteeLatestVersion();
}
AppendLog($"当前程序版本 V{GlobalVar.currentVersion},最新版为 V{latestVersionString}");
AppendLog($"当前程序版本 V{currentVersion},最新版为 V{latestVersionString}");

var res = double.TryParse(latestVersionString, out double latestVersion);
if (res)
{
if (latestVersion > GlobalVar.currentVersion)
if (latestVersion > currentVersion)
{
await Application.Current.Dispatcher.InvokeAsync(async () =>
{
var uiMessageBox = new MicaWPF.Dialogs.ContentDialog
{
Title = "提示",
Content = $"检测到新版本 V{latestVersionString},当前程序版本 V{GlobalVar.currentVersion},点击确定下载",
Content = $"检测到新版本 V{latestVersionString},当前程序版本 V{currentVersion},点击确定下载",
PrimaryButtonText = "OK"
};

Expand Down Expand Up @@ -921,7 +922,7 @@ await Task.Run(async () =>
//单个用户结束下载
if (!string.IsNullOrEmpty(nickName))
{
string info = $"{nickName} <a href=\"//weibo.com/u/{userId}\">{userId}{nickName}</a>于{DateTime.Now.ToString("HH:mm:ss")}结束下载,程序版本V{GlobalVar.currentVersion}<img src=\"{headUrl}\">";
string info = $"{nickName} <a href=\"//weibo.com/u/{userId}\">{userId}{nickName}</a>于{DateTime.Now.ToString("HH:mm:ss")}结束下载,程序版本V{currentVersion}<img src=\"{headUrl}\">";
await PushPlusHelper.SendMessage(settings?.PushPlusToken!, "微博相册下载", info);
SentrySdk.CaptureMessage(info);

Expand Down

0 comments on commit 6103d67

Please sign in to comment.