11// Variables used by Scriptable.
22// These must be at the very top of the file. Do not edit.
33// icon-color: blue; icon-glyph: cloud-download-alt;
4- let ToolVersion = "1.92 " ;
4+ let ToolVersion = "1.93 " ;
55async function delay ( milliseconds ) {
66 var before = Date . now ( ) ;
77 while ( Date . now ( ) < before + milliseconds ) { } ;
@@ -48,7 +48,7 @@ if (fromUrlScheme) {
4848 idx = 1
4949} else {
5050 let alert = new Alert ( )
51- alert . title = "Surge 模块工具"
51+ alert . title = "Surge 模块工具"
5252 //alert.addDestructiveAction("更新文件夹内全部文件")
5353 alert . addDestructiveAction ( "更新本脚本" )
5454 alert . addAction ( "从链接创建" )
@@ -253,7 +253,21 @@ async function update() {
253253 alert . message = "无法获取在线版本"
254254 alert . addCancelAction ( "关闭" )
255255 await alert . presentAlert ( )
256- } else if ( version > ToolVersion ) {
256+ return
257+ } else {
258+ let needUpdate = version > ToolVersion
259+ if ( ! needUpdate ) {
260+ let alert = new Alert ( )
261+ alert . title = "Surge 模块工具"
262+ alert . message = `当前版本: ${ ToolVersion } \n在线版本: ${ version } \n无需更新`
263+ alert . addDestructiveAction ( "强制更新" )
264+ alert . addCancelAction ( "关闭" )
265+ idx = await alert . presentAlert ( )
266+ if ( idx === 0 ) {
267+ needUpdate = true
268+ }
269+ }
270+ if ( needUpdate ) {
257271 fm . writeString ( `${ dict } /${ scriptName } .js` , resp )
258272 console . log ( "更新成功: " + version )
259273 let notification = new Notification ( )
@@ -263,12 +277,8 @@ async function update() {
263277 notification . openURL = `scriptable:///open/${ scriptName } `
264278 notification . addAction ( "打开脚本" , `scriptable:///open/${ scriptName } ` , false )
265279 await notification . schedule ( )
266-
267- } else {
268- let alert = new Alert ( )
269- alert . title = "Surge 模块工具"
270- alert . message = `当前版本: ${ ToolVersion } \n在线版本: ${ version } \n无需更新`
271- alert . addCancelAction ( "关闭" )
272- await alert . presentAlert ( )
280+ }
281+
273282 }
283+
274284}
0 commit comments