From be1cd9e5b30097ca427a9c2b7b054b28854e410a Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 11 三月 2026 13:21:36 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/login/login.js |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/src/main/webapp/static/js/login/login.js b/src/main/webapp/static/js/login/login.js
index b12ff13..6365e4c 100644
--- a/src/main/webapp/static/js/login/login.js
+++ b/src/main/webapp/static/js/login/login.js
@@ -11,15 +11,24 @@
                 localeOptions: [],
                 currentLocale: "zh-CN",
                 loginLoading: false,
+                mfaLoading: false,
                 toolsDialogVisible: false,
                 textDialogVisible: false,
                 uploadDialogVisible: false,
+                mfaDialogVisible: false,
                 licenseBase64: "",
                 titleClickCount: 0,
                 titleClickTimer: null,
                 loginForm: {
                     mobile: "",
                     password: ""
+                },
+                mfaForm: {
+                    code: ""
+                },
+                mfaPending: {
+                    ticket: "",
+                    username: ""
                 },
                 textDialog: {
                     title: "",
@@ -33,6 +42,21 @@
                     ],
                     password: [
                         { required: true, message: "璇疯緭鍏ュ瘑鐮�", trigger: "blur" }
+                    ]
+                },
+                mfaRules: {
+                    code: [
+                        { required: true, message: "璇疯緭鍏�6浣嶉獙璇佺爜", trigger: "blur" },
+                        {
+                            validator: function (rule, value, callback) {
+                                if (!/^\d{6}$/.test(String(value || "").trim())) {
+                                    callback(new Error("璇疯緭鍏�6浣嶆暟瀛楅獙璇佺爜"));
+                                    return;
+                                }
+                                callback();
+                            },
+                            trigger: "blur"
+                        }
                     ]
                 }
             };
@@ -108,10 +132,13 @@
                     },
                     method: "POST",
                     success: function (res) {
+                        var payload = res && res.data ? res.data : {};
                         if (Number(res.code) === 200) {
-                            localStorage.setItem("token", res.data.token);
-                            localStorage.setItem("username", res.data.username);
-                            window.location.href = "index.html";
+                            if (payload.mfaRequired) {
+                                vm.openMfaDialog(payload);
+                                return;
+                            }
+                            vm.finishLogin(payload);
                             return;
                         }
                         vm.$message.error(res.msg || "鐧诲綍澶辫触");
@@ -124,6 +151,80 @@
                     }
                 });
             },
+            openMfaDialog: function (payload) {
+                this.mfaPending = {
+                    ticket: payload.mfaTicket || "",
+                    username: payload.username || this.loginForm.mobile || ""
+                };
+                this.mfaForm.code = "";
+                this.mfaDialogVisible = true;
+                if (this.$refs.mfaForm) {
+                    this.$nextTick(function () {
+                        this.$refs.mfaForm.clearValidate();
+                    });
+                }
+            },
+            closeMfaDialog: function () {
+                this.mfaDialogVisible = false;
+                this.mfaLoading = false;
+                this.mfaPending = {
+                    ticket: "",
+                    username: ""
+                };
+                this.mfaForm.code = "";
+                if (this.$refs.mfaForm) {
+                    this.$refs.mfaForm.clearValidate();
+                }
+            },
+            handleMfaLogin: function () {
+                var vm = this;
+                if (!vm.$refs.mfaForm) {
+                    return;
+                }
+                vm.$refs.mfaForm.validate(function (valid) {
+                    if (!valid) {
+                        return false;
+                    }
+                    vm.submitMfaLogin();
+                    return true;
+                });
+            },
+            submitMfaLogin: function () {
+                var vm = this;
+                if (!vm.mfaPending.ticket) {
+                    vm.$message.error("鐧诲綍绁ㄦ嵁宸插け鏁堬紝璇烽噸鏂扮櫥褰�");
+                    vm.closeMfaDialog();
+                    return;
+                }
+                vm.mfaLoading = true;
+                ajaxJson({
+                    url: baseUrl + "/login/mfa.action",
+                    data: {
+                        ticket: vm.mfaPending.ticket,
+                        code: vm.mfaForm.code
+                    },
+                    method: "POST",
+                    success: function (res) {
+                        if (Number(res.code) === 200) {
+                            vm.finishLogin(res.data || {});
+                            return;
+                        }
+                        vm.$message.error(res.msg || "楠岃瘉澶辫触");
+                    },
+                    error: function () {
+                        vm.$message.error("楠岃瘉澶辫触");
+                    },
+                    complete: function () {
+                        vm.mfaLoading = false;
+                    }
+                });
+            },
+            finishLogin: function (payload) {
+                localStorage.setItem("token", payload.token || "");
+                localStorage.setItem("username", payload.username || this.loginForm.mobile || "");
+                this.closeMfaDialog();
+                window.location.href = "index.html";
+            },
             openTextDialog: function (title, label, text, tip) {
                 var pretty = "";
                 try {

--
Gitblit v1.9.1