11import { useState , useEffect } from 'react' ;
22import { useTranslation } from 'react-i18next' ;
3- import { DownloadIcon , CheckCircleIcon , XIcon , Loader2Icon , RefreshCwIcon } from 'lucide-react' ;
3+ import { DownloadIcon , CheckCircleIcon , XIcon , Loader2Icon , RefreshCwIcon , FolderOpenIcon , ExternalLinkIcon } from 'lucide-react' ;
44import ReactMarkdown from 'react-markdown' ;
55import remarkGfm from 'remark-gfm' ;
66
@@ -35,6 +35,7 @@ export function UpdateDialog({ isOpen, onClose, initialStatus }: UpdateDialogPro
3535 const { t } = useTranslation ( ) ;
3636 const [ updateStatus , setUpdateStatus ] = useState < UpdateStatus | null > ( initialStatus || null ) ;
3737 const [ currentVersion , setCurrentVersion ] = useState < string > ( '' ) ;
38+ const [ platform , setPlatform ] = useState < string > ( '' ) ;
3839
3940 useEffect ( ( ) => {
4041 if ( initialStatus ) {
@@ -43,8 +44,9 @@ export function UpdateDialog({ isOpen, onClose, initialStatus }: UpdateDialogPro
4344 } , [ initialStatus ] ) ;
4445
4546 useEffect ( ( ) => {
46- // 获取当前版本
47+ // 获取当前版本和平台
4748 window . electron ?. updater ?. getVersion ( ) . then ( setCurrentVersion ) ;
49+ window . electron ?. updater ?. getPlatform ?.( ) . then ( setPlatform ) ;
4850
4951 // 监听更新状态
5052 const handleStatus = ( status : UpdateStatus ) => {
@@ -216,6 +218,7 @@ export function UpdateDialog({ isOpen, onClose, initialStatus }: UpdateDialogPro
216218 ) ;
217219
218220 case 'downloaded' :
221+ const isMac = platform === 'darwin' ;
219222 return (
220223 < div className = "py-4" >
221224 < div className = "flex items-center gap-3 mb-4" >
@@ -225,16 +228,30 @@ export function UpdateDialog({ isOpen, onClose, initialStatus }: UpdateDialogPro
225228 < div >
226229 < h3 className = "font-semibold text-lg" > { t ( 'settings.downloadComplete' ) } </ h3 >
227230 < p className = "text-sm text-muted-foreground" >
228- { t ( 'settings.downloadCompleteDesc' ) }
231+ { isMac ? '' : t ( 'settings.downloadCompleteDesc' ) }
229232 </ p >
230233 </ div >
231234 </ div >
235+ { isMac && (
236+ < div className = "mb-4 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20" >
237+ < p className = "text-sm text-amber-600 dark:text-amber-400 whitespace-pre-line" >
238+ { t ( 'settings.macManualInstall' ) }
239+ </ p >
240+ </ div >
241+ ) }
232242 < div className = "flex gap-2" >
233243 < button
234244 onClick = { handleInstall }
235245 className = "flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-primary text-white hover:bg-primary/90 transition-colors"
236246 >
237- { t ( 'settings.installNow' ) }
247+ { isMac ? (
248+ < >
249+ < FolderOpenIcon className = "w-4 h-4" />
250+ { t ( 'settings.openDownloadFolder' ) }
251+ </ >
252+ ) : (
253+ t ( 'settings.installNow' )
254+ ) }
238255 </ button >
239256 < button
240257 onClick = { onClose }
@@ -253,12 +270,22 @@ export function UpdateDialog({ isOpen, onClose, initialStatus }: UpdateDialogPro
253270 < XIcon className = "w-6 h-6 text-red-500" />
254271 </ div >
255272 < h3 className = "font-semibold text-lg mb-1 text-red-500" > { t ( 'common.error' ) } </ h3 >
256- < p className = "text-sm text-muted-foreground break-all whitespace-pre-wrap max-h-40 overflow-y-auto" >
273+ < p className = "text-sm text-muted-foreground break-all whitespace-pre-wrap max-h-32 overflow-y-auto mb-4 " >
257274 { updateStatus . error }
258275 </ p >
276+ < div className = "p-3 rounded-lg bg-muted/50 mb-4" >
277+ < p className = "text-sm text-muted-foreground mb-2" > { t ( 'settings.manualDownloadHint' ) } </ p >
278+ < button
279+ onClick = { ( ) => window . electron ?. updater ?. openReleases ( ) }
280+ className = "flex items-center justify-center gap-2 w-full px-4 py-2 rounded-lg bg-primary text-white hover:bg-primary/90 transition-colors"
281+ >
282+ < ExternalLinkIcon className = "w-4 h-4" />
283+ { t ( 'settings.manualDownload' ) }
284+ </ button >
285+ </ div >
259286 < button
260287 onClick = { handleCheckUpdate }
261- className = "mt-4 px-4 py-2 rounded-lg bg-muted hover:bg-muted/80 transition-colors"
288+ className = "px-4 py-2 rounded-lg bg-muted hover:bg-muted/80 transition-colors"
262289 >
263290 { t ( 'settings.checkUpdate' ) }
264291 </ button >
0 commit comments