@@ -25,12 +25,12 @@ public static string GetCurrentVersion()
2525 // 获取当前程序的版本号
2626 Assembly assembly = Assembly . GetExecutingAssembly ( ) ;
2727 FileVersionInfo fvi = FileVersionInfo . GetVersionInfo ( assembly . Location ) ;
28- return $ "v{ fvi . ProductVersion . Split ( '+' ) [ 0 ] } ";
28+ return $ "v{ fvi . ProductVersion . Split ( '+' ) [ 0 ] . Replace ( "." , "" ) } ";
2929 }
3030
3131 public static string GetNewVersion ( )
3232 {
33- return releaseInfo [ "name" ] . ToString ( ) ;
33+ return releaseInfo [ "name" ] . ToString ( ) . Replace ( "." , "" ) ;
3434 }
3535 public static string GetNewVersionTime ( )
3636 {
@@ -51,11 +51,8 @@ public static bool GetUpdate()
5151 string jsonResponse = client . GetStringAsync ( repoUrl ) . Result ;
5252 releaseInfo = JObject . Parse ( jsonResponse ) ;
5353
54- string latestVersion = releaseInfo [ "name" ] . ToString ( ) ;
55- Console . WriteLine ( $ "最新版本: { latestVersion } ") ;
56-
5754 // 检查是否为当前版本
58- if ( latestVersion == currentVersion )
55+ if ( GetNewVersion ( ) . Replace ( "." , "" ) == GetCurrentVersion ( ) . Replace ( "." , "" ) )
5956 {
6057 return false ;
6158 }
@@ -70,7 +67,7 @@ public static bool GetUpdate()
7067 }
7168 }
7269
73- public static async Task UpdateCore ( ProgressBar bar , ContentDialog shd )
70+ public static async Task UpdateCore ( ProgressBar bar , ContentDialog shd , Label jd )
7471 {
7572 // 获取系统架构
7673 string architecture = RuntimeInformation . ProcessArchitecture . ToString ( ) . ToLower ( ) ;
@@ -90,7 +87,7 @@ public static async Task UpdateCore(ProgressBar bar,ContentDialog shd)
9087 {
9188 string downloadUrl = installerAsset [ "browser_download_url" ] . ToString ( ) ;
9289 Console . WriteLine ( $ "正在下载: { installerName } ") ;
93- await DownloadFileAsync ( downloadUrl , installerName , bar , shd ) ;
90+ await DownloadFileAsync ( downloadUrl , installerName , bar , shd , jd ) ;
9491 }
9592 else
9693 {
@@ -113,31 +110,32 @@ private static string GetInstallerName(string architecture)
113110 }
114111 }
115112
116- private static async Task DownloadFileAsync ( string url , string fileName , ProgressBar bar , ContentDialog shd )
113+ private static async Task DownloadFileAsync ( string url , string fileName , ProgressBar bar , ContentDialog shd , Label jd )
117114 {
118115 try
119116 {
120117 var downloadOpt = new DownloadConfiguration ( )
121118 {
122119 BufferBlockSize = 10240 ,
123- ChunkCount = 256 ,
120+ ChunkCount = 64 ,
124121 MaxTryAgainOnFailover = 5 ,
125122 ParallelDownload = true ,
126123 ParallelCount = 10 ,
127124 Timeout = 1000 ,
128125 ClearPackageOnCompletionWithFailure = true ,
129- MinimumSizeOfChunking = 64 ,
126+ MinimumSizeOfChunking = 1024 ,
130127 ReserveStorageSpaceBeforeStartingDownload = true
131128 } ;
132129
133130 var downloader = new DownloadService ( downloadOpt ) ;
134131 downloader . DownloadProgressChanged += ( sender , args ) =>
135132 {
136133 // 确保事件被触发
137- Console . WriteLine ( $ "下载进度: { args . ProgressPercentage } %") ;
134+ // Console.WriteLine($"下载进度: {args.ProgressPercentage}%");
138135 Dispatcher . UIThread . InvokeAsync ( ( ) =>
139136 {
140137 bar . Value = args . ProgressPercentage ;
138+ jd . Content = $ "进度:{ args . ProgressPercentage } %";
141139 } ) ;
142140 } ;
143141
0 commit comments