feat: 完善请求日志过滤

This commit is contained in:
橙子
2024-10-21 23:07:44 +08:00
parent 998d97b669
commit 57ad7ae1a3
6 changed files with 164 additions and 21 deletions

View File

@@ -4,8 +4,8 @@
{ {
public string Phone { get; set; } public string Phone { get; set; }
public string? Uuid { get; set; } public string Uuid { get; set; }
public string? Code { get; set; } public string Code { get; set; }
} }
} }

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection; using Lazy.Captcha.Core.Generator;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.BackgroundWorkers; using Volo.Abp.BackgroundWorkers;
using Volo.Abp.BackgroundWorkers.Quartz; using Volo.Abp.BackgroundWorkers.Quartz;
@@ -24,7 +25,11 @@ namespace Yi.Framework.Rbac.Application
{ {
var service = context.Services; var service = context.Services;
service.AddCaptcha(); service.AddCaptcha(options =>
{
options.CaptchaType = CaptchaType.ARITHMETIC;
});
} }
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)

View File

@@ -67,9 +67,9 @@ namespace Yi.Abp.Web
Configure<AbpAuditingOptions>(optios => Configure<AbpAuditingOptions>(optios =>
{ {
//默认关闭,开启会有大量的审计日志 //默认关闭,开启会有大量的审计日志
optios.IsEnabled = false; optios.IsEnabled = true;
//审计日志过滤器 //审计日志过滤器
optios.AlwaysLogSelectors.Add(x => Task.FromResult(true)); optios.AlwaysLogSelectors.Add(x => Task.FromResult(!x.Url.StartsWith("/api/app/file/")));
}); });
//采用furion格式的规范化api默认不开启使用abp优雅的方式 //采用furion格式的规范化api默认不开启使用abp优雅的方式

View File

@@ -83,7 +83,7 @@ export function getCodeImg() {
}); });
} }
// 获取短信验证码 // 获取短信验证码
export function getCodePhone(phone) { export function getCodePhone(phoneForm) {
return request({ return request({
url: "/account/captcha-phone", url: "/account/captcha-phone",
headers: { headers: {
@@ -91,11 +91,11 @@ export function getCodePhone(phone) {
}, },
method: "post", method: "post",
timeout: 20000, timeout: 20000,
data: { phone }, data: phoneForm,
}); });
} }
// 获取短信验证码-为了重置密码 // 获取短信验证码-为了重置密码
export function getCodePhoneForRetrievePassword(phone) { export function getCodePhoneForRetrievePassword(form) {
return request({ return request({
url: "/account/captcha-phone/repassword", url: "/account/captcha-phone/repassword",
headers: { headers: {
@@ -103,6 +103,6 @@ export function getCodePhoneForRetrievePassword(phone) {
}, },
method: "post", method: "post",
timeout: 20000, timeout: 20000,
data: { phone }, data: form,
}); });
} }

View File

@@ -1,15 +1,20 @@
<script setup> <script setup>
// 注册逻辑 // 注册逻辑
import {reactive, ref} from "vue"; import {computed, reactive, ref} from "vue";
import {getCodePhoneForRetrievePassword} from "@/apis/accountApi"; import {getCodePhoneForRetrievePassword} from "@/apis/accountApi";
import useAuths from "@/hooks/useAuths"; import useAuths from "@/hooks/useAuths";
import { useRouter} from "vue-router"; import { useRouter} from "vue-router";
const { retrievePasswordFun } = useAuths(); const { retrievePasswordFun } = useAuths();
const router = useRouter(); const router = useRouter();
import useUserStore from "@/stores/user";
const retrievePasswordFormRef = ref(); const retrievePasswordFormRef = ref();
//验证码弹窗
const codeDialogVisible=ref(false);
// 获取图片验证码
const codeImageURL = computed(() => useUserStore().codeImageURL);
const codeUUid = computed(() => useUserStore().codeUUid);
// 确认密码 // 确认密码
const passwordConfirm = ref(""); const passwordConfirm = ref("");
const registerForm = reactive({ const registerForm = reactive({
@@ -18,6 +23,11 @@ const registerForm = reactive({
uuid: "", uuid: "",
code: "" code: ""
}); });
const phoneForm=reactive({
code:"",
phone:"",
uuid:codeUUid
});
const registerRules = reactive({ const registerRules = reactive({
phone: [{ required: true, message: "请输入手机号", trigger: "blur" }], phone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
code: [{ required: true, message: "请输入验证码", trigger: "blur" }], code: [{ required: true, message: "请输入验证码", trigger: "blur" }],
@@ -56,14 +66,38 @@ const retrievePassword = async (formEl) => {
const codeInfo = ref("发送短信"); const codeInfo = ref("发送短信");
const isDisabledCode = ref(false); const isDisabledCode = ref(false);
//点击验证码
const handleGetCodeImage=()=>{
useUserStore().updateCodeImage();
}
//点击手机发送短信
const clickPhoneCaptcha=()=>{
if (registerForm.phone !== "")
{
handleGetCodeImage();
codeDialogVisible.value=true;
}
else {
ElMessage({
message: `请先输入手机号`,
type: "warning",
});
}
}
//前往登录 //前往登录
const handleSignInNow=()=>{ const handleSignInNow=()=>{
router.push("/login"); router.push("/login");
} }
const captcha = async () => { const captcha = async () => {
if (registerForm.phone !== "") { if (registerForm.phone!==""&&phoneForm.code!=="")
const { data } = await getCodePhoneForRetrievePassword(registerForm.phone); {
phoneForm.phone=registerForm.phone;
const { data } = await getCodePhoneForRetrievePassword(phoneForm);
registerForm.uuid = data.uuid; registerForm.uuid = data.uuid;
codeDialogVisible.value=false;
ElMessage({ ElMessage({
message: `已向${registerForm.phone}发送验证码,请注意查收`, message: `已向${registerForm.phone}发送验证码,请注意查收`,
type: "success", type: "success",
@@ -113,7 +147,7 @@ const captcha = async () => {
<el-form-item prop="phone"> <el-form-item prop="phone">
<div class="phone-code"> <div class="phone-code">
<input class="phone-code-input" type="text" v-model.trim="registerForm.phone"> <input class="phone-code-input" type="text" v-model.trim="registerForm.phone">
<button type="button" class="phone-code-btn" @click="captcha()">{{codeInfo}}</button> <button type="button" class="phone-code-btn" @click="clickPhoneCaptcha()">{{codeInfo}}</button>
</div> </div>
</el-form-item> </el-form-item>
</div> </div>
@@ -146,8 +180,41 @@ const captcha = async () => {
</div> </div>
</div> </div>
<el-dialog
v-model="codeDialogVisible"
title="发送短信"
width="500"
center
>
<div class="dialog-body">
<img class="code-img" alt="加载中" @click="handleGetCodeImage" :src="codeImageURL">
<div class="input">
<p>*图片验证码</p>
<el-form-item prop="code" >
<input type="text" v-model.trim="phoneForm.code">
</el-form-item>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<button @click="captcha" style="width:80% " type="button" class="phone-code-btn">确认发送</button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
<style src="@/assets/styles/login.css" scoped> <style src="@/assets/styles/login.css" scoped>
</style>
<style scoped>
.dialog-body
{
display: flex !important;
justify-content: center !important;
padding: 0 !important;
}
.code-img{
margin: 25px !important;
}
</style> </style>

View File

@@ -1,16 +1,21 @@
<script setup> <script setup>
// 注册逻辑 // 注册逻辑
import {reactive, ref} from "vue"; import {computed, reactive, ref} from "vue";
import {getCodePhone} from "@/apis/accountApi"; import {getCodePhone} from "@/apis/accountApi";
import useAuths from "@/hooks/useAuths"; import useAuths from "@/hooks/useAuths";
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
import useUserStore from "@/stores/user";
const { registerFun } = useAuths(); const { registerFun } = useAuths();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const registerFormRef = ref(); const registerFormRef = ref();
//验证码弹窗
const codeDialogVisible=ref(false);
// 获取图片验证码
const codeImageURL = computed(() => useUserStore().codeImageURL);
const codeUUid = computed(() => useUserStore().codeUUid);
// 确认密码 // 确认密码
const passwordConfirm = ref(""); const passwordConfirm = ref("");
const registerForm = reactive({ const registerForm = reactive({
@@ -21,6 +26,11 @@ const registerForm = reactive({
code: "", code: "",
nick:"" nick:""
}); });
const phoneForm=reactive({
code:"",
phone:"",
uuid:codeUUid
});
const registerRules = reactive({ const registerRules = reactive({
nick: [ nick: [
{ min: 2, message: "昵称需大于两位", trigger: "blur" }, { min: 2, message: "昵称需大于两位", trigger: "blur" },
@@ -65,14 +75,37 @@ const register = async (formEl) => {
const codeInfo = ref("发送短信"); const codeInfo = ref("发送短信");
const isDisabledCode = ref(false); const isDisabledCode = ref(false);
//点击验证码
const handleGetCodeImage=()=>{
useUserStore().updateCodeImage();
}
//点击手机发送短信
const clickPhoneCaptcha=()=>{
if (registerForm.phone !== "")
{
handleGetCodeImage();
codeDialogVisible.value=true;
}
else {
ElMessage({
message: `请先输入手机号`,
type: "warning",
});
}
}
//前往登录 //前往登录
const handleSignInNow=()=>{ const handleSignInNow=()=>{
router.push("/login"); router.push("/login");
} }
const captcha = async () => { const captcha = async () => {
if (registerForm.phone !== "") { if (registerForm.phone!==""&&phoneForm.code!=="")
const { data } = await getCodePhone(registerForm.phone); {
phoneForm.phone=registerForm.phone;
const { data } = await getCodePhone(phoneForm);
registerForm.uuid = data.uuid; registerForm.uuid = data.uuid;
codeDialogVisible.value=false;
ElMessage({ ElMessage({
message: `已向${registerForm.phone}发送验证码,请注意查收`, message: `已向${registerForm.phone}发送验证码,请注意查收`,
type: "success", type: "success",
@@ -90,12 +123,15 @@ const captcha = async () => {
time--; time--;
} }
}, 1000); }, 1000);
} else { }
else
{
ElMessage({ ElMessage({
message: `请先输入手机号`, message: `请先输入手机号`,
type: "warning", type: "warning",
}); });
} }
}; };
</script> </script>
@@ -138,7 +174,7 @@ const captcha = async () => {
<el-form-item prop="phone"> <el-form-item prop="phone">
<div class="phone-code"> <div class="phone-code">
<input class="phone-code-input" type="text" v-model.trim="registerForm.phone"> <input class="phone-code-input" type="text" v-model.trim="registerForm.phone">
<button type="button" class="phone-code-btn" @click="captcha()">{{codeInfo}}</button> <button type="button" class="phone-code-btn" @click="clickPhoneCaptcha()">{{codeInfo}}</button>
</div> </div>
</el-form-item> </el-form-item>
</div> </div>
@@ -171,8 +207,43 @@ const captcha = async () => {
</div> </div>
</div> </div>
<el-dialog
v-model="codeDialogVisible"
title="发送短信"
width="500"
center
>
<div class="dialog-body">
<img class="code-img" alt="加载中" @click="handleGetCodeImage" :src="codeImageURL">
<div class="input">
<p>*图片验证码</p>
<el-form-item prop="code" >
<input type="text" v-model.trim="phoneForm.code">
</el-form-item>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<button @click="captcha" style="width:80% " type="button" class="phone-code-btn">确认发送</button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
<style src="@/assets/styles/login.css" scoped> <style src="@/assets/styles/login.css" scoped>
</style>
<style scoped>
.dialog-body
{
display: flex !important;
justify-content: center !important;
padding: 0 !important;
}
.code-img{
margin: 25px !important;
}
</style> </style>