mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 00:57:13 +08:00 
			
		
		
		
	feat: 优化验证码超时显示效果,超时后显示已过期请刷新
This commit is contained in:
		| @@ -48,4 +48,7 @@ public class CaptchaResp implements Serializable { | |||||||
|      */ |      */ | ||||||
|     @Schema(description = "验证码图片(Base64编码,带图片格式:data:image/gif;base64)", example = "data:image/png;base64,iVBORw0KGgoAAAAN...") |     @Schema(description = "验证码图片(Base64编码,带图片格式:data:image/gif;base64)", example = "data:image/png;base64,iVBORw0KGgoAAAAN...") | ||||||
|     private String img; |     private String img; | ||||||
|  |  | ||||||
|  |     @Schema(description = "过期时间戳", example = "1714376969409") | ||||||
|  |     private Long expireTime; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,7 +26,6 @@ import org.hibernate.validator.constraints.Length; | |||||||
| import top.continew.admin.common.constant.RegexConstants; | import top.continew.admin.common.constant.RegexConstants; | ||||||
| import top.continew.admin.common.enums.DisEnableStatusEnum; | import top.continew.admin.common.enums.DisEnableStatusEnum; | ||||||
| import top.continew.starter.extension.crud.model.req.BaseReq; | import top.continew.starter.extension.crud.model.req.BaseReq; | ||||||
| import top.continew.starter.extension.crud.util.ValidateGroup; |  | ||||||
|  |  | ||||||
| import java.io.Serial; | import java.io.Serial; | ||||||
|  |  | ||||||
| @@ -47,7 +46,7 @@ public class DeptReq extends BaseReq { | |||||||
|      * 上级部门 ID |      * 上级部门 ID | ||||||
|      */ |      */ | ||||||
|     @Schema(description = "上级部门 ID", example = "2") |     @Schema(description = "上级部门 ID", example = "2") | ||||||
|     @NotNull(message = "上级部门不能为空", groups = ValidateGroup.Crud.Add.class) |     @NotNull(message = "上级部门不能为空") | ||||||
|     private Long parentId; |     private Long parentId; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ | |||||||
| package top.continew.admin.webapi.common; | package top.continew.admin.webapi.common; | ||||||
|  |  | ||||||
| import cn.dev33.satoken.annotation.SaIgnore; | import cn.dev33.satoken.annotation.SaIgnore; | ||||||
|  | import cn.hutool.core.date.LocalDateTimeUtil; | ||||||
| import cn.hutool.core.lang.Dict; | import cn.hutool.core.lang.Dict; | ||||||
| import cn.hutool.core.lang.RegexPool; | import cn.hutool.core.lang.RegexPool; | ||||||
| import cn.hutool.core.map.MapUtil; | import cn.hutool.core.map.MapUtil; | ||||||
| @@ -57,6 +58,7 @@ import top.continew.starter.messaging.mail.util.MailUtils; | |||||||
| import top.continew.starter.web.model.R; | import top.continew.starter.web.model.R; | ||||||
|  |  | ||||||
| import java.time.Duration; | import java.time.Duration; | ||||||
|  | import java.time.LocalDateTime; | ||||||
| import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| @@ -101,8 +103,10 @@ public class CaptchaController { | |||||||
|         String uuid = IdUtil.fastUUID(); |         String uuid = IdUtil.fastUUID(); | ||||||
|         String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + uuid; |         String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + uuid; | ||||||
|         Captcha captcha = graphicCaptchaService.getCaptcha(); |         Captcha captcha = graphicCaptchaService.getCaptcha(); | ||||||
|  |         long expireTime = LocalDateTimeUtil.toEpochMilli(LocalDateTime.now() | ||||||
|  |             .plusMinutes(captchaProperties.getExpirationInMinutes())); | ||||||
|         RedisUtils.set(captchaKey, captcha.text(), Duration.ofMinutes(captchaProperties.getExpirationInMinutes())); |         RedisUtils.set(captchaKey, captcha.text(), Duration.ofMinutes(captchaProperties.getExpirationInMinutes())); | ||||||
|         return R.ok(CaptchaResp.builder().uuid(uuid).img(captcha.toBase64()).build()); |         return R.ok(CaptchaResp.builder().uuid(uuid).img(captcha.toBase64()).expireTime(expireTime).build()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱") |     @Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 kils
					kils