From af0e0a110e7187bf008655f7510199a0c0b25ec4 Mon Sep 17 00:00:00 2001 From: Nymph2333 <498092988@qq.com> Date: 星期一, 10 四月 2023 14:27:40 +0800 Subject: [PATCH] newInstance() 已弃用,使用clazz.getDeclaredConstructor().newInstance() This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException. The call clazz.newInstance() can be replaced by clazz.getDeclaredConstructor().newInstance() The latter sequence of calls is inferred to be able to throw the additional exception types InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException. --- ruoyi-ui/src/views/login.vue | 54 +++++++++++++++++++++++++++++++++++------------------- 1 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index b63d046..cdae8dc 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -3,7 +3,12 @@ <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <h3 class="title">若依后台管理系统</h3> <el-form-item prop="username"> - <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号"> + <el-input + v-model="loginForm.username" + type="text" + auto-complete="off" + placeholder="账号" + > <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> </el-input> </el-form-item> @@ -18,7 +23,7 @@ <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> </el-input> </el-form-item> - <el-form-item prop="code"> + <el-form-item prop="code" v-if="captchaEnabled"> <el-input v-model="loginForm.code" auto-complete="off" @@ -29,7 +34,7 @@ <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> </el-input> <div class="login-code"> - <img :src="codeUrl" @click="getCode" /> + <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> @@ -44,11 +49,14 @@ <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> <!-- 底部 --> <div class="el-login-footer"> - <span>Copyright © 2018-2019 ruoyi.vip All Rights Reserved.</span> + <span>Copyright © 2018-2023 ruoyi.vip All Rights Reserved.</span> </div> </div> </template> @@ -63,7 +71,6 @@ data() { return { codeUrl: "", - cookiePassword: "", loginForm: { username: "admin", password: "admin123", @@ -73,14 +80,18 @@ }, loginRules: { username: [ - { required: true, trigger: "blur", message: "用户名不能为空" } + { required: true, trigger: "blur", message: "请输入您的账号" } ], password: [ - { required: true, trigger: "blur", message: "密码不能为空" } + { required: true, trigger: "blur", message: "请输入您的密码" } ], - code: [{ required: true, trigger: "change", message: "验证码不能为空" }] + code: [{ required: true, trigger: "change", message: "请输入验证码" }] }, loading: false, + // 验证码开关 + captchaEnabled: true, + // 注册开关 + register: false, redirect: undefined }; }, @@ -99,8 +110,11 @@ methods: { getCode() { getCodeImg().then(res => { - this.codeUrl = "data:image/gif;base64," + res.img; - this.loginForm.uuid = res.uuid; + this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled; + if (this.captchaEnabled) { + this.codeUrl = "data:image/gif;base64," + res.img; + this.loginForm.uuid = res.uuid; + } }); }, getCookie() { @@ -126,15 +140,14 @@ Cookies.remove("password"); Cookies.remove('rememberMe'); } - this.$store - .dispatch("Login", this.loginForm) - .then(() => { - this.$router.push({ path: this.redirect || "/" }); - }) - .catch(() => { - this.loading = false; + this.$store.dispatch("Login", this.loginForm).then(() => { + this.$router.push({ path: this.redirect || "/" }).catch(()=>{}); + }).catch(() => { + this.loading = false; + if (this.captchaEnabled) { this.getCode(); - }); + } + }); } }); } @@ -148,7 +161,7 @@ justify-content: center; align-items: center; height: 100%; - background-image: url("../assets/image/login-background.jpg"); + background-image: url("../assets/images/login-background.jpg"); background-size: cover; } .title { @@ -200,4 +213,7 @@ font-size: 12px; letter-spacing: 1px; } +.login-code-img { + height: 38px; +} </style> -- Gitblit v1.9.2