mirror of
				https://github.com/potato47/ccc-devtools.git
				synced 2025-10-31 03:15:50 +00:00 
			
		
		
		
	fix: 修正计时器未正确关闭的问题;适配3.8.x版本api
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								release/preview-template/dist/index.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								release/preview-template/dist/index.html
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| <script type="module" crossorigin src="/dist/assets/index.691dfd76.js"></script> | ||||
| <script type="module" crossorigin src="/dist/assets/index.95bf25f5.js"></script> | ||||
| <link rel="stylesheet" href="/dist/assets/index.741f95c0.css"> | ||||
| <div id="dev-app" style="width: 400px;height: 100%;display: flex;flex-direction: column;justify-content: center;"></div> | ||||
|  | ||||
|   | ||||
| @@ -12,22 +12,23 @@ | ||||
| </template> | ||||
|  | ||||
| <script lang="ts" setup> | ||||
| import { onMounted, ref } from 'vue-demi'; | ||||
| import { onMounted, onUnmounted, ref } from 'vue-demi'; | ||||
|  | ||||
| const props = defineProps({ | ||||
|     show: Boolean, | ||||
| }); | ||||
|  | ||||
| let items = ref<any[]>([]); | ||||
| let timeoutId: number; | ||||
|  | ||||
| function refresh() { | ||||
|     // @ts-ignore | ||||
|     const cc = window['cc']; | ||||
|     if (!cc || !cc.profiler || !cc.profiler._stats) { | ||||
|     if (!cc || !cc.profiler || !cc.profiler.stats) { | ||||
|         return; | ||||
|     } | ||||
|     // @ts-ignore | ||||
|     const stats = cc.profiler._stats; | ||||
|     const stats = cc.profiler.stats; | ||||
|     items.value.forEach(item => { | ||||
|         const data = stats[item.key]; | ||||
|         item.desc = data.desc; | ||||
| @@ -37,7 +38,7 @@ function refresh() { | ||||
|             item.value = data.counter._value.toFixed(2); | ||||
|         } | ||||
|     }); | ||||
|     setTimeout(refresh, 1000); | ||||
|     timeoutId = setTimeout(refresh, 1000); | ||||
| } | ||||
|  | ||||
| function init() { | ||||
| @@ -60,6 +61,12 @@ onMounted(() => { | ||||
|   init(); | ||||
| }); | ||||
|  | ||||
| onUnmounted(() => { | ||||
|     if (!isNaN(timeoutId)) { | ||||
|         clearTimeout(timeoutId); | ||||
|     } | ||||
| }); | ||||
|  | ||||
| </script> | ||||
|  | ||||
| <style> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user