消毒机设备
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.

115 lines
2.2 KiB

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