更新登录
This commit is contained in:
parent
76f90f50c0
commit
488b50c28c
@ -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,
|
||||
});
|
||||
|
||||
11
src/views/basicSettings/index.vue
Normal file
11
src/views/basicSettings/index.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -31,7 +31,13 @@
|
||||
<span class="input-icon">
|
||||
<i class="fa-solid fa-user"></i>
|
||||
</span>
|
||||
<input v-model="account" type="text" placeholder="用户名" autocomplete="account" class="input input-with-icon" />
|
||||
<input
|
||||
v-model="account"
|
||||
type="text"
|
||||
:placeholder="verifyType === 'sms' ? '手机号' : verifyType === 'email' ? '邮箱' : '用户名'"
|
||||
:autocomplete="verifyType === 'sms' ? 'tel' : 'account'"
|
||||
class="input input-with-icon"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group icon-input-group">
|
||||
<span class="input-icon">
|
||||
@ -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<HTMLElement | null>(null);
|
||||
const captchaInstance = ref<any>(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<void> => {
|
||||
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(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user