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.

84 lines
2.0 KiB

  1. <template>
  2. <div class="success-popup">
  3. <div class="popup-content">
  4. <div class="icon">
  5. <el-icon :size="48" color="#67c23a">
  6. <SuccessFilled />
  7. </el-icon>
  8. </div>
  9. <div class="title">修改密码成功</div>
  10. <div class="desc">系统将在 {{ countdown }} 秒后自动跳转至登录页</div>
  11. <el-button type="primary" @click="immediateJump">立即跳转</el-button>
  12. </div>
  13. </div>
  14. </template>
  15. <script setup>
  16. import {ref, onMounted} from 'vue';
  17. import {ElIcon, ElButton} from 'element-plus';
  18. import {SuccessFilled} from '@element-plus/icons-vue';
  19. import {useRouter} from 'vue-router';
  20. const machineId = localStorage.getItem("machineId");
  21. const countdown = ref(3);
  22. const router = useRouter();
  23. // 倒计时逻辑,自动跳转
  24. const startCountdown = () => {
  25. const timer = setInterval(() => {
  26. countdown.value--;
  27. if (countdown.value === 0) {
  28. clearInterval(timer);
  29. // 这里可根据实际需求选择刷新跳转还是路由跳转
  30. // 若需要刷新页面跳转,使用 window.location.href
  31. // window.location.href = '/login';
  32. router.replace(`/login?machineId=${machineId || ''}`);
  33. // 若用路由跳转(路由配置好登录页路径前提下):router.push('/login');
  34. }
  35. }, 1000);
  36. };
  37. const immediateJump = () => {
  38. // window.location.href = '/login';
  39. // 路由跳转方式:
  40. router.replace(`/login?machineId=${machineId || ''}`);
  41. };
  42. onMounted(() => {
  43. startCountdown();
  44. });
  45. </script>
  46. <style scoped>
  47. .success-popup {
  48. position: fixed;
  49. top: 0;
  50. left: 0;
  51. background-color: rgba(255, 255, 255, 0.8);
  52. display: flex;
  53. justify-content: center;
  54. align-items: center;
  55. z-index: 9999;
  56. width: 100%;
  57. height: 100%;
  58. }
  59. .popup-content {
  60. background: #fff;
  61. padding: 30px;
  62. border-radius: 8px;
  63. text-align: center;
  64. }
  65. .icon {
  66. margin-bottom: 16px;
  67. }
  68. .title {
  69. font-size: 18px;
  70. font-weight: bold;
  71. margin-bottom: 8px;
  72. }
  73. .desc {
  74. margin-bottom: 24px;
  75. color: #999;
  76. }
  77. </style>