消毒机设备
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.2 KiB

  1. <script setup lang="ts">
  2. import { useSystemStore } from '@/stores/systemStore'
  3. import { startTimer, stopTimer } from 'libs/countdownTimer'
  4. import { ref, watchEffect } from 'vue'
  5. import { useRouter } from 'vue-router'
  6. const systemStore = useSystemStore()
  7. const router = useRouter()
  8. const timer = ref()
  9. const websocketConnected = ref(true)
  10. const countdownToReconnection = () => {
  11. startTimer(30 * 1000, (times: string) => {
  12. if (times === '0') {
  13. router.push('/login')
  14. return
  15. }
  16. timer.value = times
  17. })
  18. }
  19. watchEffect(() => {
  20. websocketConnected.value = systemStore.websocketConnected
  21. if (!systemStore.websocketConnected) {
  22. countdownToReconnection()
  23. }
  24. else {
  25. stopTimer()
  26. }
  27. })
  28. </script>
  29. <template>
  30. <div v-if="!websocketConnected" class="reconnect-modal-overlay">
  31. <div class="reconnect-modal-container">
  32. <div class="reconnect-spinner" />
  33. <h2 class="reconnect-title">
  34. 正在重连中 {{ timer }}
  35. </h2>
  36. <p class="reconnect-message">
  37. 请稍候系统正在尝试重新连接网络...
  38. </p>
  39. </div>
  40. </div>
  41. </template>
  42. <style scoped>
  43. .reconnect-modal-overlay {
  44. position: fixed;
  45. top: 0;
  46. left: 0;
  47. width: 100%;
  48. height: 100%;
  49. background-color: rgba(0, 0, 0, 0.5);
  50. backdrop-filter: blur(4px);
  51. display: flex;
  52. justify-content: center;
  53. align-items: center;
  54. z-index: 9999;
  55. }
  56. .reconnect-modal-container {
  57. background-color: white;
  58. border-radius: 12px;
  59. padding: 40px;
  60. box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  61. text-align: center;
  62. animation: fadeIn 0.3s ease-out;
  63. }
  64. .reconnect-spinner {
  65. width: 64px;
  66. height: 64px;
  67. border: 6px solid #f3f3f3;
  68. border-radius: 50%;
  69. border-top: 6px solid #3b82f6;
  70. margin: 0 auto 24px;
  71. animation: spin 1s linear infinite;
  72. }
  73. .reconnect-title {
  74. font-size: 1.12rem;
  75. font-weight: bold;
  76. color: #1f2937;
  77. margin-bottom: 12px;
  78. }
  79. .reconnect-message {
  80. font-size: 16px;
  81. color: #4b5563;
  82. }
  83. @keyframes spin {
  84. 0% { transform: rotate(0deg); }
  85. 100% { transform: rotate(360deg); }
  86. }
  87. @keyframes fadeIn {
  88. from { opacity: 0; transform: scale(0.95); }
  89. to { opacity: 1; transform: scale(1); }
  90. }
  91. </style>