@@ -25,6 +25,13 @@ function formatBytes(value: number): string {
2525 return `${ amount . toFixed ( index === 0 ? 0 : 1 ) } ${ units [ index ] } `
2626}
2727
28+ function formatReleaseNotes ( value ?: string ) : string {
29+ if ( ! value ) return ''
30+ const document = new DOMParser ( ) . parseFromString ( value , 'text/html' )
31+ const text = document . body . textContent ?. replace ( / \s + / g, ' ' ) . trim ( ) || ''
32+ return text . replace ( / ^ F u l l C h a n g e l o g \s * : / i, '完整更新记录:' )
33+ }
34+
2835export default function AppUpdater ( ) {
2936 const [ state , setState ] = useState < AppUpdateState > ( initialState )
3037 const [ open , setOpen ] = useState ( false )
@@ -61,6 +68,7 @@ export default function AppUpdater() {
6168
6269 const hasUpdate = state . status === 'available' || state . status === 'downloading' || state . status === 'downloaded'
6370 const progress = Math . max ( 0 , Math . min ( 100 , state . progress ?. percent || 0 ) )
71+ const releaseNotes = formatReleaseNotes ( state . releaseNotes )
6472
6573 const renderContent = ( ) => {
6674 if ( state . status === 'checking' || state . status === 'idle' ) {
@@ -83,7 +91,7 @@ export default function AppUpdater() {
8391 < span > 当前版本 { state . currentVersion } </ span >
8492 </ div >
8593 </ div >
86- { state . releaseNotes && < div className = "app-update-notes" > { state . releaseNotes } </ div > }
94+ { releaseNotes && < div className = "app-update-notes" > { releaseNotes } </ div > }
8795 </ div >
8896 )
8997 }
@@ -152,6 +160,7 @@ export default function AppUpdater() {
152160 if ( state . status === 'available' ) {
153161 return (
154162 < >
163+ < Button onClick = { ( ) => void api . updater . openRelease ( ) } > 查看 Release</ Button >
155164 < Button onClick = { ( ) => setOpen ( false ) } > 稍后提醒</ Button >
156165 < Button variant = "primary" icon = { < DownloadOutlined /> } onClick = { ( ) => void api . updater . download ( ) } > 下载更新</ Button >
157166 </ >
0 commit comments