feat: 完成登录页面接入pure
This commit is contained in:
@@ -68,8 +68,8 @@ const ruleForm = reactive({
|
||||
//获取验证码
|
||||
const getCode = () => {
|
||||
getCodeImg().then(res => {
|
||||
codeUrl.value = "data:image/gif;base64," + res.img;
|
||||
ruleForm.uuid = res.uuid;
|
||||
codeUrl.value = "data:image/gif;base64," + res.data.img;
|
||||
ruleForm.uuid = res.data.uuid;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -81,10 +81,12 @@ const onLogin = async (formEl: FormInstance | undefined) => {
|
||||
useUserStoreHook()
|
||||
.loginByUsername({
|
||||
username: ruleForm.username,
|
||||
password: ruleForm.password
|
||||
password: ruleForm.password,
|
||||
uuid: ruleForm.uuid,
|
||||
code: ruleForm.verifyCode
|
||||
})
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
if (res.status == 200) {
|
||||
// 获取后端路由
|
||||
return initRouter().then(() => {
|
||||
disabled.value = true;
|
||||
@@ -239,10 +241,10 @@ getCode();
|
||||
:prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
|
||||
>
|
||||
<template v-slot:append>
|
||||
11 {{codeUrl}}
|
||||
<img
|
||||
:src="codeUrl"
|
||||
class="login-code-img"
|
||||
alt=""
|
||||
@click="getCode"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { reactive } from "vue";
|
||||
import { isPhone } from "@pureadmin/utils";
|
||||
import type { FormRules } from "element-plus";
|
||||
import { $t, transformI18n } from "@/plugins/i18n";
|
||||
import { useUserStoreHook } from "@/store/modules/user";
|
||||
|
||||
/** 6位数字验证码正则 */
|
||||
export const REGEXP_SIX = /^\d{6}$/;
|
||||
@@ -32,10 +31,6 @@ const loginRules = reactive<FormRules>({
|
||||
validator: (rule, value, callback) => {
|
||||
if (value === "") {
|
||||
callback(new Error(transformI18n($t("login.pureVerifyCodeReg"))));
|
||||
} else if (useUserStoreHook().verifyCode !== value) {
|
||||
callback(
|
||||
new Error(transformI18n($t("login.pureVerifyCodeCorrectReg")))
|
||||
);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ function onChange() {
|
||||
useUserStoreHook()
|
||||
.loginByUsername({ username: username.value, password: "admin123" })
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
if (res.status == 200) {
|
||||
storageLocal().removeItem("async-routes");
|
||||
usePermissionStoreHook().clearAllCachePage();
|
||||
initRouter();
|
||||
|
||||
Reference in New Issue
Block a user