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.

152 lines
3.4 KiB

3 years ago
3 years ago
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { useRouter } from "vue-router";
  4. import { initRouter } from "/@/router/utils";
  5. import { storageSession } from "/@/utils/storage";
  6. import { addClass, removeClass } from "/@/utils/operate";
  7. import bg from "/@/assets/login/bg.png";
  8. import avatar from "/@/assets/login/avatar.svg?component";
  9. import illustration from "/@/assets/login/illustration.svg?component";
  10. const router = useRouter();
  11. let user = ref("admin");
  12. let pwd = ref("123456");
  13. const onLogin = (): void => {
  14. storageSession.setItem("info", {
  15. username: "admin",
  16. accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
  17. });
  18. initRouter("admin").then(() => {});
  19. router.push("/");
  20. };
  21. function onUserFocus() {
  22. addClass(document.querySelector(".user"), "focus");
  23. }
  24. function onUserBlur() {
  25. if (user.value.length === 0)
  26. removeClass(document.querySelector(".user"), "focus");
  27. }
  28. function onPwdFocus() {
  29. addClass(document.querySelector(".pwd"), "focus");
  30. }
  31. function onPwdBlur() {
  32. if (pwd.value.length === 0)
  33. removeClass(document.querySelector(".pwd"), "focus");
  34. }
  35. </script>
  36. <template>
  37. <img :src="bg" class="wave" />
  38. <div class="login-container">
  39. <div class="img">
  40. <illustration />
  41. </div>
  42. <div class="login-box">
  43. <div class="login-form">
  44. <avatar class="avatar" />
  45. <h2
  46. v-motion
  47. :initial="{
  48. opacity: 0,
  49. y: 100
  50. }"
  51. :enter="{
  52. opacity: 1,
  53. y: 0,
  54. transition: {
  55. delay: 100
  56. }
  57. }"
  58. >
  59. Pure Admin
  60. </h2>
  61. <div
  62. class="input-group user focus"
  63. v-motion
  64. :initial="{
  65. opacity: 0,
  66. y: 100
  67. }"
  68. :enter="{
  69. opacity: 1,
  70. y: 0,
  71. transition: {
  72. delay: 200
  73. }
  74. }"
  75. >
  76. <div class="icon">
  77. <IconifyIconOffline icon="user" width="14" height="14" />
  78. </div>
  79. <div>
  80. <h5>用户名</h5>
  81. <input
  82. type="text"
  83. class="input"
  84. v-model="user"
  85. @focus="onUserFocus"
  86. @blur="onUserBlur"
  87. />
  88. </div>
  89. </div>
  90. <div
  91. class="input-group pwd focus"
  92. v-motion
  93. :initial="{
  94. opacity: 0,
  95. y: 100
  96. }"
  97. :enter="{
  98. opacity: 1,
  99. y: 0,
  100. transition: {
  101. delay: 300
  102. }
  103. }"
  104. >
  105. <div class="icon">
  106. <IconifyIconOffline icon="lock" width="14" height="14" />
  107. </div>
  108. <div>
  109. <h5>密码</h5>
  110. <input
  111. type="password"
  112. class="input"
  113. v-model="pwd"
  114. @focus="onPwdFocus"
  115. @blur="onPwdBlur"
  116. />
  117. </div>
  118. </div>
  119. <button
  120. class="btn"
  121. v-motion
  122. :initial="{
  123. opacity: 0,
  124. y: 10
  125. }"
  126. :enter="{
  127. opacity: 1,
  128. y: 0,
  129. transition: {
  130. delay: 400
  131. }
  132. }"
  133. @click="onLogin"
  134. >
  135. 登录
  136. </button>
  137. </div>
  138. </div>
  139. </div>
  140. </template>
  141. <style scoped>
  142. @import url("/@/style/login.css");
  143. </style>