mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-25 16:07:19 +08:00
feat: 使用getConfig接口来获取系统配置
This commit is contained in:
parent
4d41bccfbf
commit
8f46526cc0
@ -1,14 +1,17 @@
|
|||||||
import { http } from "@/utils/http";
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
export type CaptchaDTO = {
|
export type CaptchaDTO = {
|
||||||
/** 验证码开关 */
|
|
||||||
isCaptchaOn: boolean;
|
|
||||||
/** 验证码的base64图片 */
|
/** 验证码的base64图片 */
|
||||||
captchaCodeImg: string;
|
captchaCodeImg: string;
|
||||||
/** 验证码对应的缓存key */
|
/** 验证码对应的缓存key */
|
||||||
captchaCodeKey: string;
|
captchaCodeKey: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ConfigDTO = {
|
||||||
|
/** 验证码开关 */
|
||||||
|
isCaptchaOn: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type LoginByPasswordDTO = {
|
export type LoginByPasswordDTO = {
|
||||||
/** 用户名 */
|
/** 用户名 */
|
||||||
username: string;
|
username: string;
|
||||||
@ -32,6 +35,11 @@ export type RefreshTokenResult = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 获取系统配置接口 */
|
||||||
|
export const getConfig = () => {
|
||||||
|
return http.request<ResponseData<ConfigDTO>>("get", "/getConfig");
|
||||||
|
};
|
||||||
|
|
||||||
/** 验证码接口 */
|
/** 验证码接口 */
|
||||||
export const getCaptchaCode = () => {
|
export const getCaptchaCode = () => {
|
||||||
return http.request<ResponseData<CaptchaDTO>>("get", "/captchaImage");
|
return http.request<ResponseData<CaptchaDTO>>("get", "/captchaImage");
|
||||||
|
@ -48,6 +48,7 @@ defineOptions({
|
|||||||
|
|
||||||
// TODO 当请求验证码过于频繁的话 服务器会报错 但是前端没有反应 这块需要处理一下, 通过axios处理一下
|
// TODO 当请求验证码过于频繁的话 服务器会报错 但是前端没有反应 这块需要处理一下, 通过axios处理一下
|
||||||
const captchaCodeBase64 = ref("");
|
const captchaCodeBase64 = ref("");
|
||||||
|
|
||||||
const isCaptchaOn = ref(false);
|
const isCaptchaOn = ref(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -116,10 +117,8 @@ function onkeypress({ code }: KeyboardEvent) {
|
|||||||
|
|
||||||
async function getCaptchaCode() {
|
async function getCaptchaCode() {
|
||||||
await CommonAPI.getCaptchaCode().then(res => {
|
await CommonAPI.getCaptchaCode().then(res => {
|
||||||
isCaptchaOn.value = res.data.isCaptchaOn;
|
|
||||||
captchaCodeBase64.value = `data:image/gif;base64,${res.data.captchaCodeImg}`;
|
captchaCodeBase64.value = `data:image/gif;base64,${res.data.captchaCodeImg}`;
|
||||||
ruleForm.captchaCodeKey = res.data.captchaCodeKey;
|
ruleForm.captchaCodeKey = res.data.captchaCodeKey;
|
||||||
console.log(ruleForm);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +129,15 @@ watch(isRememberMe, newVal => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(async () => {
|
||||||
getCaptchaCode();
|
await CommonAPI.getConfig().then(res => {
|
||||||
|
isCaptchaOn.value = res.data.isCaptchaOn;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isCaptchaOn.value) {
|
||||||
|
getCaptchaCode();
|
||||||
|
}
|
||||||
|
|
||||||
isRememberMe.value = getIsRememberMe();
|
isRememberMe.value = getIsRememberMe();
|
||||||
if (isRememberMe.value) {
|
if (isRememberMe.value) {
|
||||||
ruleForm.password = getPassword();
|
ruleForm.password = getPassword();
|
||||||
@ -140,7 +146,6 @@ onBeforeMount(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.document.addEventListener("keypress", onkeypress);
|
window.document.addEventListener("keypress", onkeypress);
|
||||||
getCaptchaCode();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user