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

View File

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

View File

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