index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="login h-full flex justify-center items-center">
  3. <div class="login-base flex">
  4. <span class="close" @click="willClose">&times;</span>
  5. <div class="left-bg-box"></div>
  6. <div class="right-box h-full">
  7. <IpSet v-if="curStepIndex == 0" @next="toNext"></IpSet>
  8. <EnvCheck
  9. v-if="curStepIndex == 1"
  10. @mounted="checkEnvHandler"
  11. ></EnvCheck>
  12. <LoginWays v-if="curStepIndex == 2" @next="toNext"> </LoginWays>
  13. <AdminLogin v-if="curStepIndex == 3" @to-index="toIndex"> </AdminLogin>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script name="Login" lang="ts" setup>
  19. import { ref, onMounted } from "vue";
  20. import { closeApp } from "@/utils";
  21. import EnvCheck from "./EnvCheck.vue";
  22. import IpSet from "./IpSet.vue";
  23. import LoginWays from "./LoginWays.vue";
  24. import AdminLogin from "./AdminLogin.vue";
  25. import { local } from "@/utils/tool";
  26. const curStepIndex = ref(0);
  27. const toNext = () => {
  28. curStepIndex.value++;
  29. };
  30. const toIndex = (i: number) => {
  31. curStepIndex.value = i;
  32. };
  33. onMounted(() => {
  34. if (local.get("baseUrl")) {
  35. curStepIndex.value++;
  36. }
  37. });
  38. const envCheckLoading = ref(false);
  39. const checkEnvHandler = () => {
  40. //todo 环境检测,发起请求
  41. envCheckLoading.value = true;
  42. //先定时器模拟请求
  43. setTimeout(() => {
  44. envCheckLoading.value = false;
  45. curStepIndex.value++;
  46. //todo如果请求异常,则清除本地local里的baseUrl
  47. //...
  48. }, 2000);
  49. };
  50. const willClose = () => {
  51. if (curStepIndex.value == 1 && envCheckLoading.value) {
  52. window.$confirm({
  53. title: "系统提示",
  54. content: "需要重新设置服务器IP吗?",
  55. onCancel: () => {
  56. closeApp();
  57. },
  58. onOk: () => {
  59. curStepIndex.value = 0;
  60. local.remove("baseUrl");
  61. },
  62. });
  63. } else {
  64. closeApp();
  65. }
  66. };
  67. </script>
  68. <style lang="less" scoped>
  69. .login {
  70. height: 100%;
  71. .close {
  72. position: absolute;
  73. z-index: 10;
  74. right: 28px;
  75. top: 26px;
  76. color: #666;
  77. cursor: pointer;
  78. font-size: 24px;
  79. transition: all 0.3s;
  80. &:hover {
  81. font-weight: bold;
  82. color: #333;
  83. }
  84. }
  85. .login-base {
  86. width: 100%;
  87. height: 100%;
  88. border-radius: 12px;
  89. background: #fff;
  90. position: relative;
  91. .right-box {
  92. width: calc(100% - 360px);
  93. }
  94. .left-bg-box {
  95. width: 360px;
  96. height: 100%;
  97. background: url(../../assets//imgs/login_left_bg.png) 0 0 no-repeat;
  98. background-size: 100% 100%;
  99. }
  100. }
  101. }
  102. </style>