perf(client): improve MkTime performance
This commit is contained in:
		
							parent
							
								
									c89410cab0
								
							
						
					
					
						commit
						697836c17c
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		|  | @ -37,12 +37,13 @@ const relative = $computed(() => { | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| function tick() { | function tick() { | ||||||
| 	// TODO: パフォーマンス向上のため、このコンポーネントが画面内に表示されている場合のみ更新する |  | ||||||
| 	now = new Date(); | 	now = new Date(); | ||||||
|  | 	const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/; | ||||||
|  | 	const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000; | ||||||
| 
 | 
 | ||||||
| 	tickId = window.setTimeout(() => { | 	tickId = window.setTimeout(() => { | ||||||
| 		window.requestAnimationFrame(tick); | 		window.requestAnimationFrame(tick); | ||||||
| 	}, 10000); | 	}, next); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| let tickId: number; | let tickId: number; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue