|
@@ -1,66 +1,52 @@
|
|
|
<template>
|
|
|
<div class="login">
|
|
|
- <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
|
|
|
- <h3 class="title">若依后台管理系统</h3>
|
|
|
- <el-form-item prop="username">
|
|
|
- <el-input
|
|
|
- v-model="loginForm.username"
|
|
|
- type="text"
|
|
|
- size="large"
|
|
|
- auto-complete="off"
|
|
|
- placeholder="账号"
|
|
|
- >
|
|
|
- <template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="password">
|
|
|
- <el-input
|
|
|
- v-model="loginForm.password"
|
|
|
- type="password"
|
|
|
- size="large"
|
|
|
- auto-complete="off"
|
|
|
- placeholder="密码"
|
|
|
- @keyup.enter="handleLogin"
|
|
|
- >
|
|
|
- <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item prop="code" v-if="captchaEnabled">
|
|
|
- <el-input
|
|
|
- v-model="loginForm.code"
|
|
|
- size="large"
|
|
|
- auto-complete="off"
|
|
|
- placeholder="验证码"
|
|
|
- style="width: 63%"
|
|
|
- @keyup.enter="handleLogin"
|
|
|
- >
|
|
|
- <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
|
|
|
- </el-input>
|
|
|
- <div class="login-code">
|
|
|
- <img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
|
|
- <el-form-item style="width:100%;">
|
|
|
- <el-button
|
|
|
- :loading="loading"
|
|
|
- size="large"
|
|
|
- type="primary"
|
|
|
- style="width:100%;"
|
|
|
- @click.prevent="handleLogin"
|
|
|
- >
|
|
|
- <span v-if="!loading">登 录</span>
|
|
|
- <span v-else>登 录 中...</span>
|
|
|
- </el-button>
|
|
|
- <div style="float: right;" v-if="register">
|
|
|
- <router-link class="link-type" :to="'/register'">立即注册</router-link>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
+ <el-form ref="loginRef" :model="loginForm" class="login-form">
|
|
|
+ <h3 class="title">账号登录</h3>
|
|
|
+ <div class="main">
|
|
|
+ <el-form-item prop="username">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.username"
|
|
|
+ type="text"
|
|
|
+ size="large"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="请输入登录账号"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="password">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.password"
|
|
|
+ type="password"
|
|
|
+ size="large"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="请输入登录密码"
|
|
|
+ @keyup.enter="handleLogin"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item style="width:100%;">
|
|
|
+ <div class="w-full h-[116px]">
|
|
|
+ <div class="error-tips space-x-[4px]" v-show="errorMsg">
|
|
|
+ <el-icon><Warning /></el-icon>
|
|
|
+ <span>{{ errorMsg }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-button
|
|
|
+ :loading="loading"
|
|
|
+ size="large"
|
|
|
+ type="primary"
|
|
|
+ style="width:100%;"
|
|
|
+ @click.prevent="handleLogin"
|
|
|
+ >
|
|
|
+ <span v-if="!loading">登 录</span>
|
|
|
+ <span v-else>登 录 中...</span>
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
- <!-- 底部 -->
|
|
|
+ <!-- 底部
|
|
|
<div class="el-login-footer">
|
|
|
<span>Copyright © 2018-2024 ruoyi.vip All Rights Reserved.</span>
|
|
|
</div>
|
|
|
+ -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -89,6 +75,8 @@ const loginRules = {
|
|
|
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
|
|
};
|
|
|
|
|
|
+const errorMsg = ref("");
|
|
|
+
|
|
|
const codeUrl = ref("");
|
|
|
const loading = ref(false);
|
|
|
// 验证码开关
|
|
@@ -102,39 +90,35 @@ watch(route, (newRoute) => {
|
|
|
}, { immediate: true });
|
|
|
|
|
|
function handleLogin() {
|
|
|
- proxy.$refs.loginRef.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- loading.value = true;
|
|
|
- // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
|
|
- if (loginForm.value.rememberMe) {
|
|
|
- Cookies.set("username", loginForm.value.username, { expires: 30 });
|
|
|
- Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 });
|
|
|
- Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 });
|
|
|
- } else {
|
|
|
- // 否则移除
|
|
|
- Cookies.remove("username");
|
|
|
- Cookies.remove("password");
|
|
|
- Cookies.remove("rememberMe");
|
|
|
+
|
|
|
+ const { username, password } = unref(loginForm);
|
|
|
+
|
|
|
+ if (!username) {
|
|
|
+ return errorMsg.value = '请输入用户名称'
|
|
|
+ }
|
|
|
+ if (!password) {
|
|
|
+ return errorMsg.value = '请输入登录密码'
|
|
|
+ }
|
|
|
+
|
|
|
+ errorMsg.value = '';
|
|
|
+
|
|
|
+ loading.value = true;
|
|
|
+
|
|
|
+ // 调用action的登录方法
|
|
|
+ userStore.login(loginForm.value).then(() => {
|
|
|
+ const query = route.query;
|
|
|
+ const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
|
|
|
+ if (cur !== "redirect") {
|
|
|
+ acc[cur] = query[cur];
|
|
|
}
|
|
|
- // 调用action的登录方法
|
|
|
- userStore.login(loginForm.value).then(() => {
|
|
|
- const query = route.query;
|
|
|
- const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
|
|
|
- if (cur !== "redirect") {
|
|
|
- acc[cur] = query[cur];
|
|
|
- }
|
|
|
- return acc;
|
|
|
- }, {});
|
|
|
- router.push({ path: redirect.value || "/", query: otherQueryParams });
|
|
|
- }).catch(() => {
|
|
|
- loading.value = false;
|
|
|
- // 重新获取验证码
|
|
|
- if (captchaEnabled.value) {
|
|
|
- getCode();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+ // redirect.value
|
|
|
+ router.push({ path: "/workbench", query: otherQueryParams });
|
|
|
+ }).catch(() => {
|
|
|
+ loading.value = false;
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function getCode() {
|
|
@@ -165,27 +149,63 @@ getCookie();
|
|
|
<style lang='scss' scoped>
|
|
|
.login {
|
|
|
display: flex;
|
|
|
- justify-content: center;
|
|
|
+ justify-content: flex-end;
|
|
|
align-items: center;
|
|
|
height: 100%;
|
|
|
- background-image: url("../assets/images/login-background.jpg");
|
|
|
+ background-image: url("../assets/images/login/bg-login-text.png");
|
|
|
background-size: cover;
|
|
|
}
|
|
|
-.title {
|
|
|
- margin: 0px auto 30px auto;
|
|
|
- text-align: center;
|
|
|
- color: #707070;
|
|
|
-}
|
|
|
|
|
|
.login-form {
|
|
|
- border-radius: 6px;
|
|
|
- background: #ffffff;
|
|
|
- width: 400px;
|
|
|
- padding: 25px 25px 5px 25px;
|
|
|
+ width: 440px;
|
|
|
+ margin-right: 100px;
|
|
|
+ border-radius: 12px;
|
|
|
+ border: 2px solid #FFF;
|
|
|
+ background: rgba(255, 255, 255, 0.8);
|
|
|
+ box-shadow: 0px 2px 80px 5px rgba(19, 29, 107, 0.06);
|
|
|
+
|
|
|
+ .title {
|
|
|
+ padding: 20px 0 20px 60px;
|
|
|
+ border-bottom: 1px solid #EDEFF2;
|
|
|
+ text-align: left;
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #1D2129;
|
|
|
+ }
|
|
|
+
|
|
|
+ .main {
|
|
|
+ padding: 60px 60px 66px 60px;
|
|
|
+
|
|
|
+ :deep(.el-input__wrapper) {
|
|
|
+ border: 1px solid #F2F4F9;
|
|
|
+ border-radius: 8px;
|
|
|
+ box-shadow: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .error-tips {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ height: 32px;
|
|
|
+ border-radius: 8px;
|
|
|
+ background: #FFF1F0;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #FF7152;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-button {
|
|
|
+ height: 54px;
|
|
|
+ border-radius: 8px;
|
|
|
+ background: linear-gradient(91deg, #165DFF 0.41%, #00A6FF 97.92%);
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.el-input {
|
|
|
- height: 40px;
|
|
|
+ height: 54px;
|
|
|
input {
|
|
|
- height: 40px;
|
|
|
+ height: 54px;
|
|
|
}
|
|
|
}
|
|
|
.input-icon {
|