@@ -57,6 +57,11 @@ function initApp() {
5757 } ) ;
5858 document . getElementById ( 'btn-recheck' ) . addEventListener ( 'click' , checkPermissions ) ;
5959
60+ // 检查更新按钮
61+ document . getElementById ( 'btn-check-update' ) . addEventListener ( 'click' , function ( ) {
62+ checkForUpdates ( true ) ;
63+ } ) ;
64+
6065 // 添加项目按钮
6166 document . getElementById ( 'add-keyword' ) . addEventListener ( 'click' , function ( ) {
6267 showInlineInput ( 'keyword-list' , function ( val ) {
@@ -446,12 +451,12 @@ function setupDelaySlider() {
446451}
447452
448453// ===================== 自动更新 =====================
449- async function checkForUpdates ( ) {
454+ async function checkForUpdates ( manual = false ) {
450455 if ( ! window . __TAURI__ ) return ;
451456
452457 try {
453458 const { check } = window . __TAURI__ . updater ;
454- const { ask } = window . __TAURI__ . dialog ;
459+ const { ask, message } = window . __TAURI__ . dialog ;
455460 const { relaunch } = window . __TAURI__ . process ;
456461
457462 const update = await check ( ) ;
@@ -471,9 +476,23 @@ async function checkForUpdates() {
471476 await update . downloadAndInstall ( ) ;
472477 await relaunch ( ) ;
473478 }
479+ } else if ( manual ) {
480+ // 手动检查时,如果没有更新也要提示
481+ await message ( '当前已是最新版本!' , {
482+ title : 'AutoCode 更新' ,
483+ kind : 'info'
484+ } ) ;
474485 }
475486 } catch ( error ) {
476487 console . log ( '检查更新失败:' , error ) ;
488+ if ( manual ) {
489+ // 手动检查时显示错误
490+ const { message } = window . __TAURI__ . dialog ;
491+ await message ( '检查更新失败,请稍后重试' , {
492+ title : 'AutoCode 更新' ,
493+ kind : 'error'
494+ } ) ;
495+ }
477496 }
478497}
479498
0 commit comments