更新登录

This commit is contained in:
李志强 2026-04-02 17:53:52 +08:00
parent 76f90f50c0
commit 488b50c28c
3 changed files with 65 additions and 7 deletions

View File

@ -7,7 +7,7 @@ import request from "@/utils/request";
*/ */
export function getNormalInfos(tid) { export function getNormalInfos(tid) {
return request({ return request({
url: "/admin/normalInfos", url: "/backend/normalInfos",
method: "get", method: "get",
params: { tid } params: { tid }
}); });
@ -20,7 +20,7 @@ export function getNormalInfos(tid) {
*/ */
export function saveNormalInfos(data) { export function saveNormalInfos(data) {
return request({ return request({
url: "/admin/saveNormalInfos", url: "/backend/saveNormalInfos",
method: "post", method: "post",
data: data, data: data,
}); });

View File

@ -0,0 +1,11 @@
<script setup>
</script>
<template>
<router-view />
</template>
<style scoped>
</style>

View File

@ -31,7 +31,13 @@
<span class="input-icon"> <span class="input-icon">
<i class="fa-solid fa-user"></i> <i class="fa-solid fa-user"></i>
</span> </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>
<div class="form-group icon-input-group"> <div class="form-group icon-input-group">
<span class="input-icon"> <span class="input-icon">
@ -98,7 +104,8 @@ const authStore = useAuthStore();
// --- --- // --- ---
const tenant_name = ref(""); const tenant_name = ref("");
const openVerifyEnabled = ref(true); // getOpenVerify
const openVerifyEnabled = ref(false);
const verifyType = ref<"captcha" | "sms" | "geetest" | "email">("captcha"); const verifyType = ref<"captcha" | "sms" | "geetest" | "email">("captcha");
const account = ref(""); const account = ref("");
const password = ref(""); const password = ref("");
@ -118,6 +125,37 @@ const showCaptchaContainer = ref(false);
const captchaContainer = ref<HTMLElement | null>(null); const captchaContainer = ref<HTMLElement | null>(null);
const captchaInstance = ref<any>(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 --- // --- JS ---
const loadScript = (url: string): Promise<void> => { const loadScript = (url: string): Promise<void> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -145,11 +183,15 @@ const cleanCaptchaInstance = () => {
// --- --- // --- ---
const performLoginRequest = async () => { const performLoginRequest = async () => {
// code
const codeToSend =
openVerifyEnabled.value && verifyType.value === "captcha" ? captchaInput.value : smsCode.value;
const res = await login({ const res = await login({
tenant_name: tenant_name.value, tenant_name: tenant_name.value,
account: account.value, account: account.value,
password: password.value, password: password.value,
code: smsCode.value code: codeToSend
}); });
if (res && res.code === 200) { if (res && res.code === 200) {
@ -370,6 +412,9 @@ const handleLogin = async () => {
} }
openVerifyEnabled.value = openVerify === "1"; openVerifyEnabled.value = openVerify === "1";
verifyType.value = verifyTypeVal as any; verifyType.value = verifyTypeVal as any;
if (openVerifyEnabled.value && verifyType.value === "captcha" && !captchaText.value) {
generateCaptcha();
}
if (openVerifyEnabled.value && verifyType.value === "captcha") { if (openVerifyEnabled.value && verifyType.value === "captcha") {
if (!captchaInput.value.trim()) { if (!captchaInput.value.trim()) {
@ -420,7 +465,7 @@ const handleRememberMeChange = async () => {
}; };
// //
onMounted(() => { onMounted(async () => {
// //
const savedRemember = localStorage.getItem("loginRememberMe"); const savedRemember = localStorage.getItem("loginRememberMe");
if (savedRemember === "true") { if (savedRemember === "true") {
@ -429,7 +474,9 @@ onMounted(() => {
password.value = localStorage.getItem("loginPassword") || ""; password.value = localStorage.getItem("loginPassword") || "";
rememberMe.value = true; rememberMe.value = true;
} }
generateCaptcha();
//
await initVerifyConfig();
}); });
onUnmounted(() => { onUnmounted(() => {