增加登录验证

This commit is contained in:
李志强 2026-02-26 11:47:36 +08:00
parent 0b268c65d6
commit 6686cee4d9
4 changed files with 112 additions and 28 deletions

View File

@ -26,6 +26,30 @@ export function saveNormalInfos(data) {
});
}
/**
* 获取登录验证数据
* @returns {Promise}
*/
export function getVerifyInfos() {
return request({
url: "/admin/loginVerifyInfos",
method: "get",
});
}
/**
* 保存登录验证数据
* @param {Object} data 要保存的数据
* @returns {Promise}
*/
export function saveVerifyInfos(data) {
return request({
url: "/admin/saveloginVerifyInfos",
method: "post",
data: data,
});
}
/**
* 获取法律声明和隐私条款
* @returns {Promise}

View File

@ -1,34 +1,16 @@
<template>
<el-form
ref="contactFormRef"
:model="contactForm"
:rules="contactRules"
label-width="120px"
style="max-width: 600px"
>
<el-form ref="contactFormRef" :model="contactForm" :rules="contactRules" label-width="120px" style="max-width: 600px">
<el-form-item label="联系电话" prop="phone">
<el-input
v-model="contactForm.phone"
placeholder="请输入联系电话"
/>
<el-input v-model="contactForm.phone" placeholder="请输入联系电话" />
</el-form-item>
<el-form-item label="联系邮箱" prop="email">
<el-input
v-model="contactForm.email"
placeholder="请输入联系邮箱"
/>
<el-input v-model="contactForm.email" placeholder="请输入联系邮箱" />
</el-form-item>
<el-form-item label="公司地址" prop="address">
<el-input
v-model="contactForm.address"
placeholder="请输入公司地址"
/>
<el-input v-model="contactForm.address" placeholder="请输入公司地址" />
</el-form-item>
<el-form-item label="工作时间" prop="workTime">
<el-input
v-model="contactForm.workTime"
placeholder="如:周一至周五 9:00-18:00"
/>
<el-input v-model="contactForm.workTime" placeholder="如:周一至周五 9:00-18:00" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveContactSettings">保存设置</el-button>

View File

@ -0,0 +1,69 @@
<template>
<el-form ref="formRef" :model="form" label-width="120px">
<el-form-item label="开启验证" prop="openVerify">
<el-switch v-model="form.openVerify" />
</el-form-item>
<el-form-item label="验证模式" prop="verifyModel">
<el-radio-group v-model="form.verifyModel" :disabled="!form.openVerify">
<el-radio-button value="1">图形</el-radio-button>
<el-radio-button value="2">短信</el-radio-button>
<el-radio-button value="3">邮箱</el-radio-button>
<el-radio-button value="4">极验</el-radio-button>
</el-radio-group>
</el-form-item>
<template v-if="form.verifyModel === '4'">
<el-form-item label="极验ID" prop="geetestID">
<el-input v-model="form.geetestID" />
</el-form-item>
<el-form-item label="极验KEY" prop="geetestKEY">
<el-input v-model="form.geetestKEY" />
</el-form-item>
</template>
<el-form-item>
<el-button type="primary" @click="handleSave">保存</el-button>
<el-button @click="formRef?.resetFields()">重置</el-button>
</el-form-item>
</el-form>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
import { ElMessage } from "element-plus";
import { getVerifyInfos, saveVerifyInfos } from "@/api/sitesettings";
const formRef = ref();
const form = reactive({
openVerify: false,
verifyModel: "1",
geetestID: "",
geetestKEY: ""
});
const init = async () => {
const { code, data } = await getVerifyInfos();
if (code === 200 && Array.isArray(data)) {
const formData = {};
data.forEach(item => {
if (item.label === 'openVerify') {
formData[item.label] = item.value === '1';
} else {
formData[item.label] = item.value;
}
});
Object.assign(form, formData);
}
};
const handleSave = async () => {
const { code } = await saveVerifyInfos(form);
if (code === 200) ElMessage.success("保存成功");
};
init();
defineExpose({ form, init });
</script>

View File

@ -9,23 +9,27 @@
<div class="settings-container">
<el-tabs v-model="activeTab" class="settings-tabs">
<el-tab-pane label="基本信息" name="basic">
<normalSettings ref="normalSettingsRef" />
<normalSettings ref="normalSettingsRef" v-if="activeTab === 'basic'" />
</el-tab-pane>
<el-tab-pane label="SEO设置" name="seo">
<seoSettings ref="seoSettingsRef" />
<seoSettings ref="seoSettingsRef" v-if="activeTab === 'seo'" />
</el-tab-pane>
<el-tab-pane label="联系方式" name="contact">
<contactSettings ref="contactSettingsRef" />
<contactSettings ref="contactSettingsRef" v-if="activeTab === 'contact'" />
</el-tab-pane>
<el-tab-pane label="登录验证" name="loginVerification">
<loginVerificationSettings ref="loginVerificationSettingsRef" v-if="activeTab === 'loginVerification'" />
</el-tab-pane>
<el-tab-pane label="法律声明&隐私条款" name="legalNotice">
<legalNoticeSettings ref="legalNoticeSettingsRef" />
<legalNoticeSettings ref="legalNoticeSettingsRef" v-if="activeTab === 'legalNotice'" />
</el-tab-pane>
<el-tab-pane label="其他设置" name="other">
<otherSettings ref="otherSettingsRef" />
<otherSettings ref="otherSettingsRef" v-if="activeTab === 'other'" />
</el-tab-pane>
</el-tabs>
</div>
@ -40,6 +44,7 @@ import seoSettings from "./components/seoSettings.vue";
import contactSettings from "./components/contactSettings.vue";
import otherSettings from "./components/otherSettings.vue";
import legalNoticeSettings from "./components/legalNotice.vue";
import loginVerificationSettings from "./components/loginVerification.vue";
const activeTab = ref("basic");
@ -48,6 +53,7 @@ const seoSettingsRef = ref();
const contactSettingsRef = ref();
const otherSettingsRef = ref();
const legalNoticeSettingsRef = ref();
const loginVerificationSettingsRef = ref();
//
const initSettings = async () => {
@ -67,6 +73,9 @@ const initSettings = async () => {
if (legalNoticeSettingsRef.value) {
// legalNoticeSettingsRef.value.legalNoticeForm = ...
}
if (loginVerificationSettingsRef.value) {
// loginVerificationSettingsRef.value.loginVerificationForm = ...
}
};
onMounted(() => {