diff --git a/src/api/sitesettings.js b/src/api/sitesettings.js index 2544ac3..ef14bf9 100644 --- a/src/api/sitesettings.js +++ b/src/api/sitesettings.js @@ -7,7 +7,7 @@ import request from "@/utils/request"; */ export function getNormalInfos(tid) { return request({ - url: "/admin/normalInfos", + url: "/backend/normalInfos", method: "get", params: { tid } }); @@ -20,7 +20,7 @@ export function getNormalInfos(tid) { */ export function saveNormalInfos(data) { return request({ - url: "/admin/saveNormalInfos", + url: "/backend/saveNormalInfos", method: "post", data: data, }); diff --git a/src/views/basicSettings/index.vue b/src/views/basicSettings/index.vue new file mode 100644 index 0000000..2fa6465 --- /dev/null +++ b/src/views/basicSettings/index.vue @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/views/login/index.vue b/src/views/login/index.vue index a351a0b..d4fee27 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -31,7 +31,13 @@ - +
@@ -98,7 +104,8 @@ const authStore = useAuthStore(); // --- 表单数据 --- const tenant_name = ref(""); -const openVerifyEnabled = ref(true); +// 页面加载阶段先不展示验证码,等 getOpenVerify 拉取真实配置后再决定渲染 +const openVerifyEnabled = ref(false); const verifyType = ref<"captcha" | "sms" | "geetest" | "email">("captcha"); const account = ref(""); const password = ref(""); @@ -118,6 +125,37 @@ const showCaptchaContainer = ref(false); const captchaContainer = ref(null); const captchaInstance = ref(null); +// --- 初始化登录验证配置 --- +const initVerifyConfig = async () => { + try { + const verifyRes = await getOpenVerify(); + let openVerify = "0"; + let verifyTypeVal: any = "captcha"; + + if (verifyRes && verifyRes.code === 200 && Array.isArray(verifyRes.data)) { + verifyRes.data.forEach((item: any) => { + if (item.label === "openVerify") { + openVerify = item.value || "0"; + } + if (item.label === "verifyType") { + verifyTypeVal = item.value || "captcha"; + } + }); + } + + openVerifyEnabled.value = openVerify === "1"; + verifyType.value = verifyTypeVal as any; + + // 仅 captcha 模式需要生成本地验证码文案 + if (openVerifyEnabled.value && verifyType.value === "captcha") { + generateCaptcha(); + } + } catch (err) { + // 配置拉取失败时:默认关闭验证码模块,避免误展示 + openVerifyEnabled.value = false; + } +}; + // --- 加载JS脚本 --- const loadScript = (url: string): Promise => { return new Promise((resolve, reject) => { @@ -145,11 +183,15 @@ const cleanCaptchaInstance = () => { // --- 执行登录请求 --- const performLoginRequest = async () => { + // 根据不同验证方式,把正确的 code 传给后端 + const codeToSend = + openVerifyEnabled.value && verifyType.value === "captcha" ? captchaInput.value : smsCode.value; + const res = await login({ tenant_name: tenant_name.value, account: account.value, password: password.value, - code: smsCode.value + code: codeToSend }); if (res && res.code === 200) { @@ -370,6 +412,9 @@ const handleLogin = async () => { } openVerifyEnabled.value = openVerify === "1"; verifyType.value = verifyTypeVal as any; + if (openVerifyEnabled.value && verifyType.value === "captcha" && !captchaText.value) { + generateCaptcha(); + } if (openVerifyEnabled.value && verifyType.value === "captcha") { if (!captchaInput.value.trim()) { @@ -420,7 +465,7 @@ const handleRememberMeChange = async () => { }; // 页面加载处理 -onMounted(() => { +onMounted(async () => { // 从本地存储恢复表单 const savedRemember = localStorage.getItem("loginRememberMe"); if (savedRemember === "true") { @@ -429,7 +474,9 @@ onMounted(() => { password.value = localStorage.getItem("loginPassword") || ""; rememberMe.value = true; } - generateCaptcha(); + + // 拉取登录验证配置,决定是否展示验证码模块 + await initVerifyConfig(); }); onUnmounted(() => {