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.

277 lines
5.0 KiB

  1. <template>
  2. <div class="total">
  3. <div
  4. class="box"
  5. :class="{ 'box-animaToR': isAnimating, 'box-animaToL': !isAnimating }"
  6. @click="startAnimation1"
  7. >
  8. <div v-if="!isTextAnimating">
  9. <span class="title" :class="{ 'title-animaT': isAnimating }"
  10. >管理员登录</span
  11. >
  12. <el-icon
  13. class="right"
  14. :class="{ 'arrow-anima': !isAnimating, 'title-animaT': isAnimating }"
  15. >
  16. <Right />
  17. </el-icon>
  18. </div>
  19. <div v-else>
  20. <span class="title" :class="{ 'title-animaT': !isAnimating }"
  21. >用户登录</span
  22. >
  23. <el-icon
  24. class="left"
  25. :class="{ 'arrow-anima': isAnimating, 'title-animaT': !isAnimating }"
  26. >
  27. <Back />
  28. </el-icon>
  29. </div>
  30. </div>
  31. <div class="login admin">
  32. <div class="loginTitle">管理员登录</div>
  33. <el-form :model="userInfo" label-width="auto" style="max-width: 600px">
  34. <el-form-item label="账号">
  35. <el-input v-model="userInfo.username" />
  36. </el-form-item>
  37. <el-form-item label="密码">
  38. <el-input v-model="userInfo.password" />
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="success" style="width: 100%" @click="login()"
  42. >登录</el-button
  43. >
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup>
  50. import { ref, onMounted } from "vue";
  51. import axios from "axios";
  52. import API from "@/util/http";
  53. import { useRouter } from "vue-router";
  54. import { ElMessage, ElMessageBox } from "element-plus";
  55. const router = useRouter();
  56. const firstAnimating = ref(false);
  57. const isAnimating = ref(false);
  58. const isTextAnimating = ref(false);
  59. const startAnimation = () => {
  60. isAnimating.value = !isAnimating.value;
  61. setTimeout(() => {
  62. isTextAnimating.value = !isTextAnimating.value;
  63. }, 400);
  64. };
  65. const userInfo = ref({
  66. username: "12345678",
  67. password: "123456",
  68. });
  69. const getQueryVariable = (variable) => {
  70. const href = window.location.href;
  71. const query = href.split("?")[1];
  72. console.log("query", query);
  73. const vars = query.split("&");
  74. for (let i = 0; i < vars.length; i++) {
  75. const pair = vars[i].split("=");
  76. if (pair[0] === variable) {
  77. return pair[1];
  78. }
  79. }
  80. return "";
  81. };
  82. const login = async function () {
  83. const machineId = getQueryVariable("machineId");
  84. console.log(machineId);
  85. try {
  86. const result = await axios.post(`http://18.143.76.3:10704/admin/login`, {
  87. account: userInfo.value.username,
  88. password: userInfo.value.password,
  89. machineId: machineId,
  90. });
  91. // const result = await API({
  92. // url: "/admin/login",
  93. // data: {
  94. // account: userInfo.username,
  95. // password: userInfo.password,
  96. // machineId: "",
  97. // },
  98. // });
  99. console.log("请求成功", result);
  100. if (result.data.code == 200) {
  101. ElMessage.success('登录成功');
  102. router.push({
  103. name: "workspace",
  104. });
  105. } else {
  106. ElMessage.error(result.data.msg);
  107. }
  108. } catch (error) {
  109. console.log("请求失败", error);
  110. }
  111. };
  112. </script>
  113. <style scoped>
  114. .login {
  115. position: absolute;
  116. z-index: 1;
  117. width: 30%;
  118. }
  119. .loginTitle {
  120. font-size: 48px;
  121. font-weight: bold;
  122. margin-bottom: 20px;
  123. text-align: center;
  124. }
  125. .user {
  126. top: 30%;
  127. left: 10%;
  128. }
  129. .admin {
  130. top: 30%;
  131. left: 55%;
  132. }
  133. .total {
  134. width: 100%;
  135. height: 100%;
  136. display: flex;
  137. }
  138. .title {
  139. position: absolute;
  140. font-size: 48px;
  141. font-weight: bold;
  142. top: 40%;
  143. left: 30%;
  144. z-index: 2;
  145. }
  146. .title-animaT {
  147. animation: textAnimaT 0.7s forwards;
  148. }
  149. .title-animaF {
  150. animation: textAnimaF 0.7s forwards;
  151. }
  152. @keyframes textAnimaF {
  153. 0% {
  154. opacity: 1;
  155. }
  156. 50% {
  157. opacity: 0;
  158. }
  159. 100% {
  160. opacity: 0;
  161. }
  162. }
  163. @keyframes textAnimaT {
  164. 0% {
  165. opacity: 1;
  166. }
  167. 50% {
  168. opacity: 0;
  169. }
  170. 100% {
  171. opacity: 0;
  172. }
  173. }
  174. .box {
  175. width: 50%;
  176. height: 100%;
  177. margin: 0;
  178. background: linear-gradient(90deg, #ffae00, #ffffff);
  179. border-radius: 5%;
  180. z-index: 99;
  181. }
  182. .box-animaToR {
  183. animation: animaToR 1s forwards;
  184. }
  185. .box-animaToL {
  186. animation: animaToL 1s forwards;
  187. }
  188. @keyframes animaToR {
  189. 0% {
  190. transform: translateX(0) scaleX(1);
  191. background: linear-gradient(90deg, #ffffff, #29e6ff);
  192. }
  193. /* 50% {
  194. transform: translateX(50%) scaleX(2);
  195. } */
  196. 100% {
  197. transform: translateX(100%) scaleX(1);
  198. background: linear-gradient(90deg, #ffffff, #29e6ff);
  199. }
  200. }
  201. @keyframes animaToL {
  202. 0% {
  203. transform: translateX(100%) scaleX(1);
  204. }
  205. /* 50% {
  206. transform: translateX(50%) scaleX(2);
  207. } */
  208. 100% {
  209. transform: translateX(0%) scaleX(1);
  210. background: linear-gradient(90deg, #ffae00, #ffffff);
  211. }
  212. }
  213. .right {
  214. position: absolute;
  215. right: 10%;
  216. top: 40%;
  217. font-size: 72px;
  218. }
  219. .left {
  220. position: absolute;
  221. left: 10%;
  222. top: 40%;
  223. font-size: 72px;
  224. z-index: 2;
  225. }
  226. .arrow-anima {
  227. animation: arrowAnima 1s infinite;
  228. }
  229. @keyframes arrowAnima {
  230. 0% {
  231. transform: translateX(0);
  232. }
  233. 50% {
  234. transform: translateX(10px);
  235. }
  236. 100% {
  237. transform: translateX(0);
  238. }
  239. }
  240. </style>