@@ -7,7 +7,7 @@ import { TbWorldWww } from "react-icons/tb";
77import { semTime } from "@App/pkg/utils/dayjs" ;
88import { useTranslation } from "react-i18next" ;
99import { ListHomeRender } from "../utils" ;
10- import { IconEdit , IconLink , IconUserAdd } from "@arco-design/web-react/icon" ;
10+ import { IconEdit , IconLink , IconSync , IconUserAdd } from "@arco-design/web-react/icon" ;
1111import type { SearchType } from "@App/app/service/service_worker/types" ;
1212import type { TFunction } from "i18next" ;
1313import type { SearchFilterKeyEntry , SearchFilterRequest } from "./SearchFilter" ;
@@ -133,52 +133,61 @@ HomeCell.displayName = "HomeCell";
133133
134134export const UpdateTimeCell = React . memo ( ( { className, script } : { className ?: string ; script : ScriptLoading } ) => {
135135 const { t } = useTranslation ( ) ;
136- const { handleClick } = {
137- handleClick : ( ) => {
138- if ( ! script . checkUpdateUrl ) {
139- Message . warning ( t ( "update_not_supported" ) ! ) ;
140- return ;
141- }
142- Message . info ( {
143- id : "checkupdate" ,
144- content : t ( "checking_for_updates" ) ,
145- } ) ;
146- scriptClient
147- . requestCheckUpdate ( script . uuid )
148- . then ( ( res ) => {
149- if ( res ) {
150- Message . warning ( {
151- id : "checkupdate" ,
152- content : t ( "new_version_available" ) ,
153- } ) ;
154- } else {
155- Message . success ( {
156- id : "checkupdate" ,
157- content : t ( "latest_version" ) ,
158- } ) ;
159- }
160- } )
161- . catch ( ( e ) => {
162- Message . error ( {
136+ const [ checking , setChecking ] = React . useState ( false ) ;
137+ const handleClick = ( ) => {
138+ if ( checking ) return ;
139+ if ( ! script . checkUpdateUrl ) {
140+ Message . warning ( t ( "update_not_supported" ) ! ) ;
141+ return ;
142+ }
143+ Message . info ( {
144+ id : "checkupdate" ,
145+ content : t ( "checking_for_updates" ) ,
146+ } ) ;
147+ setChecking ( true ) ;
148+ scriptClient
149+ . requestCheckUpdate ( script . uuid )
150+ . then ( ( res ) => {
151+ if ( res ) {
152+ Message . warning ( {
163153 id : "checkupdate" ,
164- content : ` ${ t ( "update_check_failed" ) } : ${ e . message } ` ,
154+ content : t ( "new_version_available" ) ,
165155 } ) ;
156+ } else {
157+ Message . success ( {
158+ id : "checkupdate" ,
159+ content : t ( "latest_version" ) ,
160+ } ) ;
161+ }
162+ } )
163+ . catch ( ( e ) => {
164+ Message . error ( {
165+ id : "checkupdate" ,
166+ content : `${ t ( "update_check_failed" ) } : ${ e . message } ` ,
166167 } ) ;
167- } ,
168+ } )
169+ . finally ( ( ) => {
170+ setChecking ( false ) ;
171+ } ) ;
168172 } ;
169173
170174 return (
171- < Tooltip content = { t ( "check_update" ) } position = "tl" >
172- < Typography . Text
173- className = { className }
174- style = { {
175- cursor : "pointer" ,
176- } }
177- onClick = { handleClick }
178- >
179- { script . updatetime && semTime ( new Date ( script . updatetime ) ) }
180- </ Typography . Text >
181- </ Tooltip >
175+ < Space size = { 4 } >
176+ < Tooltip content = { t ( "check_update" ) } position = "tl" >
177+ < Typography . Text className = { `tw-cursor-pointer ${ className ?? "" } ` } onClick = { handleClick } >
178+ { script . updatetime && semTime ( new Date ( script . updatetime ) ) }
179+ </ Typography . Text >
180+ </ Tooltip >
181+ { script . checkUpdateUrl && (
182+ < Tooltip content = { t ( "check_update" ) } position = "tl" >
183+ < IconSync
184+ className = { `tw-cursor-pointer tw-opacity-45 hover:tw-opacity-100 tw-transition-opacity ${ checking ? "arco-icon-loading tw-opacity-100" : "" } ` }
185+ spin = { checking }
186+ onClick = { handleClick }
187+ />
188+ </ Tooltip >
189+ ) }
190+ </ Space >
182191 ) ;
183192} ) ;
184193UpdateTimeCell . displayName = "UpdateTimeCell" ;
0 commit comments