@@ -27,6 +27,7 @@ const UpdateModal: React.FC = () => {
2727 const [ progress , setProgress ] = useState ( { percent : 0 , speed : '' , total : 0 , transferred : 0 } ) ;
2828 const [ errorMsg , setErrorMsg ] = useState ( '' ) ;
2929 const [ downloadPath , setDownloadPath ] = useState ( '' ) ;
30+ const [ releasePageUrl , setReleasePageUrl ] = useState ( '' ) ;
3031 const [ useAutoUpdate , setUseAutoUpdate ] = useState ( true ) ; // 默认使用自动更新
3132 const [ autoUpdateInfo , setAutoUpdateInfo ] = useState < { version : string ; releaseNotes ?: string } | null > ( null ) ;
3233
@@ -38,10 +39,19 @@ const UpdateModal: React.FC = () => {
3839 setProgress ( { percent : 0 , speed : '' , total : 0 , transferred : 0 } ) ;
3940 setErrorMsg ( '' ) ;
4041 setDownloadPath ( '' ) ;
42+ setReleasePageUrl ( '' ) ;
4143 setAutoUpdateInfo ( null ) ;
4244 } ;
4345
4446 const includePrerelease = useMemo ( ( ) => localStorage . getItem ( 'update.includePrerelease' ) === 'true' , [ visible ] ) ;
47+ const hasCompatibleManualAsset = Boolean ( updateInfo ?. recommendedAsset ) ;
48+
49+ const openReleasePage = ( ) => {
50+ if ( ! releasePageUrl ) return ;
51+ void ipcBridge . shell . openExternal . invoke ( releasePageUrl ) . catch ( ( error ) => {
52+ console . error ( 'Failed to open release page:' , error ) ;
53+ } ) ;
54+ } ;
4555
4656 const checkForUpdates = async ( ) => {
4757 setStatus ( 'checking' ) ;
@@ -60,6 +70,11 @@ const UpdateModal: React.FC = () => {
6070 setCurrentVersion ( manualRes . data ?. currentVersion || '' ) ;
6171 if ( manualRes . data ?. latest ) {
6272 setUpdateInfo ( manualRes . data . latest ) ;
73+ setReleasePageUrl ( manualRes . data . latest . htmlUrl || '' ) ;
74+ if ( ! manualRes . data . latest . recommendedAsset ) {
75+ setUseAutoUpdate ( false ) ;
76+ setErrorMsg ( t ( 'update.noCompatibleAssetManual' ) ) ;
77+ }
6378 }
6479 }
6580 setStatus ( 'available' ) ;
@@ -79,11 +94,16 @@ const UpdateModal: React.FC = () => {
7994
8095 if ( res . data ?. updateAvailable && res . data . latest ) {
8196 setUpdateInfo ( res . data . latest ) ;
97+ setReleasePageUrl ( res . data . latest . htmlUrl || '' ) ;
98+ if ( ! res . data . latest . recommendedAsset ) {
99+ setErrorMsg ( t ( 'update.noCompatibleAssetManual' ) ) ;
100+ }
82101 setStatus ( 'available' ) ;
83102 return ;
84103 }
85104
86105 setUpdateInfo ( res . data ?. latest || null ) ;
106+ setReleasePageUrl ( res . data ?. latest ?. htmlUrl || '' ) ;
87107 setStatus ( 'upToDate' ) ;
88108 } catch ( err : unknown ) {
89109 const msg = err instanceof Error ? err . message : String ( err ) ;
@@ -99,6 +119,10 @@ const UpdateModal: React.FC = () => {
99119 try {
100120 // 使用自动更新模式
101121 if ( useAutoUpdate ) {
122+ if ( updateInfo && ! updateInfo . recommendedAsset ) {
123+ setUseAutoUpdate ( false ) ;
124+ throw new Error ( t ( 'update.noCompatibleAssetManual' ) ) ;
125+ }
102126 const res = await ipcBridge . autoUpdate . download . invoke ( ) ;
103127 if ( ! res ?. success ) {
104128 throw new Error ( res ?. msg || t ( 'update.downloadStartFailed' ) ) ;
@@ -110,7 +134,7 @@ const UpdateModal: React.FC = () => {
110134 if ( ! updateInfo ) return ;
111135 const asset = updateInfo . recommendedAsset ;
112136 if ( ! asset ) {
113- throw new Error ( t ( 'update.noCompatibleAsset ' ) ) ;
137+ throw new Error ( t ( 'update.noCompatibleAssetManual ' ) ) ;
114138 }
115139
116140 const res = await ipcBridge . update . download . invoke ( {
@@ -302,12 +326,15 @@ const UpdateModal: React.FC = () => {
302326 </ div >
303327 </ div >
304328 < div className = 'flex items-center gap-12px' >
305- { ! useAutoUpdate && (
329+ { ! hasCompatibleManualAsset && releasePageUrl ? (
330+ < Button type = 'primary' size = 'small' onClick = { openReleasePage } className = '!px-16px' >
331+ { t ( 'update.goToRelease' ) }
332+ </ Button >
333+ ) : ! useAutoUpdate ? (
306334 < Button type = 'primary' size = 'small' onClick = { startDownload } className = '!px-16px' >
307335 { t ( 'update.downloadButton' ) }
308336 </ Button >
309- ) }
310- { useAutoUpdate && (
337+ ) : (
311338 < Button type = 'primary' size = 'small' onClick = { startDownload } className = '!px-16px' >
312339 { t ( 'update.downloadAndInstall' ) }
313340 </ Button >
@@ -318,9 +345,11 @@ const UpdateModal: React.FC = () => {
318345 { /* 自动更新开关 / Auto update toggle */ }
319346 < div className = 'flex items-center justify-between px-24px py-12px bg-fill-1 border-b border-border-2' >
320347 < div className = 'text-13px text-t-secondary' > { t ( 'update.autoUpdateMode' ) } </ div >
321- < Switch checked = { useAutoUpdate } onChange = { setUseAutoUpdate } size = 'small' />
348+ < Switch checked = { useAutoUpdate } onChange = { setUseAutoUpdate } size = 'small' disabled = { ! hasCompatibleManualAsset } />
322349 </ div >
323350
351+ { ! hasCompatibleManualAsset && < div className = 'mx-24px mt-12px px-12px py-10px text-12px rounded-8px bg-[rgb(var(--warning-6))]/10 text-[rgb(var(--warning-6))]' > { t ( 'update.noCompatibleAssetManual' ) } </ div > }
352+
324353 { /* 更新日志内容 / Release notes content */ }
325354 < div className = 'flex-1 min-h-0 overflow-y-auto px-24px py-16px custom-scrollbar' >
326355 { updateInfo ?. name && < div className = 'text-14px font-500 text-t-primary mb-12px' > { updateInfo . name } </ div > }
@@ -395,9 +424,16 @@ const UpdateModal: React.FC = () => {
395424 </ div >
396425 < div className = 'text-16px text-t-primary font-600 mb-8px' > { t ( 'update.errorTitle' ) } </ div >
397426 < div className = 'text-13px text-t-tertiary mb-24px text-center max-w-360px' > { errorMsg } </ div >
398- < Button size = 'small' onClick = { checkForUpdates } icon = { < Refresh size = '14' /> } className = '!px-16px' >
399- { t ( 'common.retry' ) }
400- </ Button >
427+ < div className = 'flex gap-12px' >
428+ < Button size = 'small' onClick = { checkForUpdates } icon = { < Refresh size = '14' /> } className = '!px-16px' >
429+ { t ( 'common.retry' ) }
430+ </ Button >
431+ { releasePageUrl && (
432+ < Button type = 'primary' size = 'small' onClick = { openReleasePage } className = '!px-16px' >
433+ { t ( 'update.goToRelease' ) }
434+ </ Button >
435+ ) }
436+ </ div >
401437 </ div >
402438 ) ;
403439 }
0 commit comments