mirror of
https://github.com/potato47/ccc-devtools.git
synced 2024-12-26 03:39:16 +00:00
fix: 修正计时器未正确关闭的问题;适配3.8.x版本api
This commit is contained in:
parent
44836565c0
commit
d50d90d130
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">
|
<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>
|
<div id="dev-app" style="width: 400px;height: 100%;display: flex;flex-direction: column;justify-content: center;"></div>
|
||||||
|
|
||||||
|
@ -12,22 +12,23 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue-demi';
|
import { onMounted, onUnmounted, ref } from 'vue-demi';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
let items = ref<any[]>([]);
|
let items = ref<any[]>([]);
|
||||||
|
let timeoutId: number;
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const cc = window['cc'];
|
const cc = window['cc'];
|
||||||
if (!cc || !cc.profiler || !cc.profiler._stats) {
|
if (!cc || !cc.profiler || !cc.profiler.stats) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const stats = cc.profiler._stats;
|
const stats = cc.profiler.stats;
|
||||||
items.value.forEach(item => {
|
items.value.forEach(item => {
|
||||||
const data = stats[item.key];
|
const data = stats[item.key];
|
||||||
item.desc = data.desc;
|
item.desc = data.desc;
|
||||||
@ -37,7 +38,7 @@ function refresh() {
|
|||||||
item.value = data.counter._value.toFixed(2);
|
item.value = data.counter._value.toFixed(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTimeout(refresh, 1000);
|
timeoutId = setTimeout(refresh, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@ -60,6 +61,12 @@ onMounted(() => {
|
|||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (!isNaN(timeoutId)) {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user