11const { shell, dialog, app} = require ( 'electron' ) ;
22const util = require ( './common/app-util' ) ;
33const https = require ( 'https' ) ;
4- const jsdom = require ( 'jsdom' ) ;
54const appToast = require ( './common/app-toast' ) ;
65
7- const url = require ( './common/app-link' ) . url ;
8-
9- const versionPrefix = require ( './common/app-link' ) . versionPrefix ;
6+ const url = require ( './common/app-link' ) . package ;
107
118// 自动检查更新(bool:是否主动操作)
129function autoUpdateApp ( isTip ) {
@@ -21,19 +18,17 @@ function autoUpdateApp(isTip) {
2118 } ) ;
2219 req . on ( 'error' , ( e ) => {
2320 console . error ( e ) ;
24- dialog . showMessageBoxSync ( { message : '网络连接异常' } )
21+ if ( isTip ) {
22+ dialog . showMessageBoxSync ( { message : '网络链接异常' } )
23+ }
2524 } ) ;
2625 req . end ( ) ;
2726}
2827
29- exports . autoUpdateApp = autoUpdateApp ;
30-
3128//解析html获取内容
3229function parseHtml ( result , isTip ) {
33- const dom = new jsdom . JSDOM ( result ) ;
34- const startIndex = dom . window . document . body . innerHTML . indexOf ( versionPrefix ) ;
35- const endIndex = dom . window . document . body . innerHTML . indexOf ( '"' , startIndex ) ;
36- const version = dom . window . document . body . innerHTML . substring ( startIndex + versionPrefix . length , endIndex ) ;
30+ const packageJson = JSON . parse ( result ) ;
31+ const version = packageJson . version ;
3732
3833 if ( ! version ) {
3934 if ( isTip ) {
@@ -71,4 +66,6 @@ function parseHtml(result, isTip) {
7166 autoUpdateApp ( false )
7267 } , 1000 * 60 * 60 )
7368 }
74- }
69+ }
70+
71+ exports . autoUpdateApp = autoUpdateApp ;
0 commit comments