Update MkTime.vue
This commit is contained in:
		
							parent
							
								
									513cef50a2
								
							
						
					
					
						commit
						457670e730
					
				
					 1 changed files with 5 additions and 7 deletions
				
			
		|  | @ -36,23 +36,21 @@ const relative = $computed(() => { | ||||||
| 		i18n.ts._ago.future); | 		i18n.ts._ago.future); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | let tickId: number; | ||||||
|  | 
 | ||||||
| function tick() { | function tick() { | ||||||
| 	now = new Date(); | 	now = new Date(); | ||||||
| 	const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/; | 	const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/; | ||||||
| 	const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000; | 	const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000; | ||||||
| 
 | 
 | ||||||
| 	tickId = window.setTimeout(() => { | 	tickId = window.setTimeout(tick, next); | ||||||
| 		window.requestAnimationFrame(tick); |  | ||||||
| 	}, next); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| let tickId: number; |  | ||||||
| 
 |  | ||||||
| if (props.mode === 'relative' || props.mode === 'detail') { | if (props.mode === 'relative' || props.mode === 'detail') { | ||||||
| 	tickId = window.requestAnimationFrame(tick); | 	tick(); | ||||||
| 
 | 
 | ||||||
| 	onUnmounted(() => { | 	onUnmounted(() => { | ||||||
| 		window.cancelAnimationFrame(tickId); | 		window.clearTimeout(tickId); | ||||||
| 	}); | 	}); | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue