remove instance activity from keep-alive

This commit is contained in:
pa
2025-11-12 15:16:23 +09:00
committed by Natsumi
parent 09bdf355a4
commit dcd06ff6dd
3 changed files with 34 additions and 20 deletions

View File

@@ -3,9 +3,7 @@
<div class="options-container" style="margin-top: 0">
<span class="header">{{ t('view.charts.header') }}</span>
</div>
<keep-alive>
<InstanceActivity />
</keep-alive>
<InstanceActivity />
<el-backtop target="#chart" :right="30" :bottom="30"></el-backtop>
</div>
</template>

View File

@@ -124,7 +124,7 @@
</template>
<script setup>
import { nextTick, onActivated, onBeforeMount, onDeactivated, onMounted, ref, watch } from 'vue';
import { nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue';
import { ArrowLeft, ArrowRight, InfoFilled, Refresh, Setting, WarningFilled } from '@element-plus/icons-vue';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
@@ -221,19 +221,19 @@
}
);
onActivated(() => {
// first time also call activated
if (echartsInstance.value) {
reloadData();
}
});
// onActivated(() => {
// // first time also call activated
// if (echartsInstance.value) {
// reloadData();
// }
// });
onDeactivated(() => {
// prevent resize animation when switch tab
if (resizeObserver.value) {
resizeObserver.value.disconnect();
}
});
// onDeactivated(() => {
// // prevent resize animation when switch tab
// if (resizeObserver.value) {
// resizeObserver.value.disconnect();
// }
// });
onBeforeMount(() => {
initializeSettings();
@@ -253,6 +253,13 @@
}
});
onBeforeUnmount(() => {
if (resizeObserver.value) {
resizeObserver.value.disconnect();
resizeObserver.value = null;
}
});
reloadData = async function () {
isLoading.value = true;
try {

View File

@@ -15,7 +15,7 @@
</template>
<script setup>
import { computed, nextTick, onDeactivated, onMounted, ref, watch } from 'vue';
import { computed, nextTick, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import dayjs from 'dayjs';
@@ -83,9 +83,18 @@
initEcharts();
});
onDeactivated(() => {
// prevent switch tab play resize animation
resizeObserver.value.disconnect();
// onDeactivated(() => {
// // prevent switch tab play resize animation
// if (resizeObserver.value) {
// resizeObserver.value.disconnect();
// }
// });
onBeforeUnmount(() => {
if (resizeObserver.value) {
resizeObserver.value.disconnect();
resizeObserver.value = null;
}
});
function initResizeObserver() {