Skip to content

Commit 1a233b9

Browse files
authored
perf: 优化验证码计算结果为非负数 (#30)
1 parent 584c2ec commit 1a233b9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ruoyi-fastapi-backend/module_admin/service/captcha_service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ async def create_captcha_image_service(cls) -> list[str, int]:
3434
result = num1 + num2
3535
elif operational_character == '-':
3636
result = num1 - num2
37+
# 非负数结果的验证码更友好一些
38+
if result < 0:
39+
num1, num2 = num2, num1
40+
result = num1 - num2
3741
else:
3842
result = num1 * num2
3943
# 绘制文本

0 commit comments

Comments
 (0)