Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/pages/detail/advanced/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';

import { getPurchaseList } from '@/api/detail';
import { t } from '@/locales';
Expand Down Expand Up @@ -203,8 +203,9 @@ const pagination = ref({

const updateCurrent = ref(0);

const intervalId = ref();
const stepUpdate = () => {
setInterval(() => {
intervalId.value = setInterval(() => {
if (updateCurrent.value > 5) {
updateCurrent.value = -1;
}
Expand All @@ -225,6 +226,12 @@ const fetchData = async () => {
}
};

onUnmounted(() => {
if (intervalId.value) {
clearInterval(intervalId.value);
}
});

onMounted(() => {
stepUpdate();
fetchData();
Expand Down
6 changes: 5 additions & 1 deletion src/pages/detail/deploy/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ const visible = ref(false);
// monitorChart logic
let monitorContainer: HTMLElement;
let monitorChart: echarts.ECharts;
const intervalId = ref();
onMounted(() => {
monitorContainer = document.getElementById('monitorContainer');
monitorChart = echarts.init(monitorContainer);
monitorChart.setOption(getSmoothLineDataSet({ ...chartColors.value }));
setInterval(() => {
intervalId.value = setInterval(() => {
monitorChart.setOption(getSmoothLineDataSet({ ...chartColors.value }));
}, 3000);
});
Expand All @@ -194,6 +195,9 @@ const updateContainer = () => {
};

onUnmounted(() => {
if (intervalId.value) {
clearInterval(intervalId.value);
}
window.removeEventListener('resize', updateContainer);
});

Expand Down