|
|
@ -4,14 +4,16 @@ import { socket } from 'libs/socket' |
|
|
|
import { useSystemStore } from 'stores/systemStore' |
|
|
|
import { onBeforeUnmount, onMounted, ref } from 'vue' |
|
|
|
|
|
|
|
const systemStore = useSystemStore() |
|
|
|
onMounted(async () => { |
|
|
|
document.body.style.setProperty('--el-color-primary', '#1989fa') |
|
|
|
const res = await getStatus() |
|
|
|
useSystemStore().updateSystemStatus(res) |
|
|
|
console.log(res) |
|
|
|
// systemStore.updateSystemStatus(res) |
|
|
|
startProgress() |
|
|
|
}) |
|
|
|
|
|
|
|
socket.init((data: System.SystemStatus) => { |
|
|
|
useSystemStore().updateSystemStatus(data) |
|
|
|
systemStore.updateSystemStatus(data) |
|
|
|
}, 'status') |
|
|
|
|
|
|
|
const progress = ref(0) |
|
|
@ -19,19 +21,23 @@ let timer: any = null |
|
|
|
const version = __APP_VERSION__ |
|
|
|
|
|
|
|
const startProgress = () => { |
|
|
|
const max = Math.floor(Math.random() * (90 - 80 + 1)) + 80 |
|
|
|
timer = setInterval(() => { |
|
|
|
const randomStep = Math.floor(Math.random() * 9 + 1) |
|
|
|
|
|
|
|
if (systemStore.systemStatus.initComplete) { |
|
|
|
// 停止计时器 |
|
|
|
progress.value = Math.min(progress.value + randomStep, 100) |
|
|
|
} |
|
|
|
else { |
|
|
|
progress.value = Math.min(progress.value + randomStep, max) |
|
|
|
} |
|
|
|
|
|
|
|
if (progress.value >= 100) { |
|
|
|
clearInterval(timer) |
|
|
|
} |
|
|
|
}, 50) |
|
|
|
}, 100) |
|
|
|
} |
|
|
|
onMounted(() => { |
|
|
|
startProgress() |
|
|
|
}) |
|
|
|
|
|
|
|
// 组件卸载时清理定时器 |
|
|
|
onBeforeUnmount(() => { |
|
|
|