feat: 添加定时获取挂起会话列表的功能

This commit is contained in:
Baobhan Sith
2025-05-10 10:14:38 +08:00
parent 8fb665a69d
commit 3605ce0aee
2 changed files with 25 additions and 4 deletions
@@ -107,7 +107,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed, nextTick, watch } from 'vue'; // +++ 导入 nextTick watch +++
import { ref, onMounted, onUnmounted, computed, nextTick, watch } from 'vue'; // +++ 导入 nextTick, watch 和 onUnmounted +++
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { useSessionStore } from '../stores/session.store';
@@ -243,8 +243,23 @@ const removeSession = (session: SuspendedSshSession) => { // 参数类型改为
}
};
let fetchIntervalId: number | undefined;
onMounted(async () => {
// 立即获取一次数据 (显示加载指示器)
await sessionStore.fetchSuspendedSshSessions();
// 设置定时器,每3秒获取一次数据 (不显示加载指示器)
fetchIntervalId = window.setInterval(async () => {
await sessionStore.fetchSuspendedSshSessions({ showLoadingIndicator: false });
}, 3000);
});
onUnmounted(() => {
// 组件卸载时清除定时器
if (fetchIntervalId) {
clearInterval(fetchIntervalId);
}
});
</script>