1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
| <script setup> import "boxicons/css/boxicons.min.css"; import router from "@/router"; import { Notyf } from "notyf"; import "notyf/notyf.min.css"; import { ref } from "vue";
let form = ref(null);
let notyf = new Notyf({ duration: 3000, className: "x-notification", position: { x: "right", y: "top" }, });
let userdata = ref({ username: "", password: "", });
const formrules = { username: [ { required: true, message: "请输入用户名", trigger: "change" }, { min: 2, max: 8, message: "用户名必须为2-8为字符", trigger: "change" }, ], password: [ { required: true, message: "请输入你的密码", trigger: "change" }, { min: 6, max: 15, message: "密码必须为6-15位字符", trigger: "change" }, ], };
const SubmitEvent = async () => { await form.validate(); await LoginApi.login(userdata.value) .then((resquest) => { if (resquest.data.code === 200) { notyf.success("登录成功!"); userstore.setuserinfor(resquest.data.data); userstore.settoken(resquest.data.token); setTimeout(() => { router.push("/"); }, 1000); } else { notyf.error("登录失败!"); } }) .catch((error) => { notyf.error(error.message || "登录失败,请重试!"); }); }; </script>
<template> <div class="content"> <div class="wrapper"> <el-form :model="userdata" :rules="formrules" ref="form"> <h1>Login</h1> <el-form-item class="input-box" prop="username"> <el-input class="custom-input" v-model="userdata.username" placeholder="Username" type="text" ></el-input> <i class="bx bxs-user"></i> </el-form-item> <el-form-item class="input-box" prop="password"> <el-input class="custom-input" v-model="userdata.password" placeholder="Password" type="password" ></el-input> <i class="bx bxs-lock"></i> </el-form-item>
<button @click="SubmitEvent()" type="submit" class="btn">Login</button> </el-form> </div> </div> </template>
<style scoped> * { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
html, body { overflow: hidden; }
.content { overflow: hidden; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: url("https://cdn.jsdelivr.net/gh/8023time/image-storage-address/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20241016221935.png") no-repeat; background-size: cover; background-position: center; }
.wrapper { overflow: hidden; width: 420px; background-color: transparent; border: 2px solid rgba(255, 255, 255, 0.2); backdrop-filter: blur(20px); color: #fff; border-radius: 10px; padding: 30px 40px; }
.wrapper h1 { font-size: 36px; text-align: center; }
.input-box { position: relative; width: 100%; height: 50px; margin: 30px 0; }
.custom-input { width: 100%; height: 100%; background: transparent; border: none; outline: none; border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 40px; font-size: 16px; color: #fff; padding: 20px 45px 20px 20px; }
.custom-input::placeholder { color: rgba(255, 255, 255, 0.7); }
.input-box i { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 20px; color: rgba(255, 255, 255, 0.6); }
.wrapper .btn { width: 100%; height: 45px; background: #fff; border: none; outline: none; border-radius: 40px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); color: #333; cursor: pointer; font-size: 16px; font-weight: 600; }
.wrapper .btn:hover { background: #5a9acf; color: #fff; }
:deep(.el-input__wrapper) { background: transparent !important; box-shadow: none !important; }
:deep(.el-input__inner) { background: transparent !important; color: #fff !important; }
:deep(.el-form-item__error) { color: #ff4d4f !important; font-size: 12px !important; margin-top: 5px !important; position: absolute !important; left: 0 !important; top: 100% !important; } </style>
|