1
0

Авто Обновление данных

сделал автоматическое обновление данных по таскам у других клиентов.
This commit is contained in:
2026-01-15 04:52:19 +07:00
parent 6014dd94fc
commit 8ac497df63
2 changed files with 29 additions and 2 deletions

View File

@@ -88,7 +88,7 @@
</template>
<script setup>
import { ref, watch, onMounted } from 'vue'
import { ref, watch, onMounted, onUnmounted } from 'vue'
import Sidebar from '../components/Sidebar.vue'
import Header from '../components/Header.vue'
import Board from '../components/Board.vue'
@@ -174,13 +174,37 @@ const handleArchiveTask = async (cardId) => {
closePanel()
}
// ==================== АВТООБНОВЛЕНИЕ (POLLING) ====================
const REFRESH_INTERVAL = (window.APP_CONFIG?.IDLE_REFRESH_SECONDS ?? 30) * 1000
let pollTimer = null
const startPolling = () => {
if (pollTimer) clearInterval(pollTimer)
pollTimer = setInterval(async () => {
console.log('[AutoRefresh] Обновление данных...')
await fetchCards()
}, REFRESH_INTERVAL)
}
const stopPolling = () => {
if (pollTimer) {
clearInterval(pollTimer)
pollTimer = null
}
}
// ==================== ИНИЦИАЛИЗАЦИЯ ====================
onMounted(async () => {
await store.init()
await fetchCards()
startPolling()
if (window.lucide) window.lucide.createIcons()
})
onUnmounted(() => {
stopPolling()
})
</script>
<style scoped>