|
|
@@ -29,7 +29,12 @@
|
|
|
<Row class="enter-x" v-show="formState.showCaptcha">
|
|
|
<Col span="16">
|
|
|
<FormItem class="code-input" name="code" label="验证码">
|
|
|
- <Input size="large" visibilityToggle v-model:value="formData.code" placeholder="验证码" />
|
|
|
+ <Input
|
|
|
+ size="large"
|
|
|
+ visibilityToggle
|
|
|
+ v-model:value="formData.captchaCode"
|
|
|
+ placeholder="验证码"
|
|
|
+ />
|
|
|
</FormItem>
|
|
|
</Col>
|
|
|
<Col span="8">
|
|
|
@@ -87,20 +92,17 @@
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
import { reactive, ref, unref, computed, onMounted } from 'vue';
|
|
|
-
|
|
|
import { Checkbox, Form, Input, Row, Col, Button } from 'ant-design-vue';
|
|
|
import LoginFormTitle from './LoginFormTitle.vue';
|
|
|
-
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
-
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin';
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
import locales from '/@/utils/locales';
|
|
|
import { buildUUID } from '/@/utils/uuid';
|
|
|
import Cookies from 'js-cookie';
|
|
|
-
|
|
|
import { getCaptcha } from '/@/api/sys/oauthApi';
|
|
|
+ import { sysConfigCurrent } from '/@/api/sys/sysConfigApi';
|
|
|
import { encryptByBase64, decodeByBase64 } from '/@/utils/cipher';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
import { useGlobSetting } from '/@/hooks/setting';
|
|
|
@@ -110,6 +112,12 @@
|
|
|
if (Cookies.get('username') && Cookies.get('password')) {
|
|
|
formData.username = decodeByBase64(Cookies.get('username')) || '';
|
|
|
}
|
|
|
+ sysConfigCurrent().then(res => {
|
|
|
+ formState.showCaptcha = res.captchaOpen;
|
|
|
+ if (res.captchaOpen) {
|
|
|
+ formState.captchaSrc = getCaptcha(formData.captchaKey);
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
const FormItem = Form.Item;
|
|
|
@@ -127,11 +135,11 @@
|
|
|
const formData = reactive<any>({
|
|
|
username: 'admin',
|
|
|
password: '123456',
|
|
|
- codeKey: buildUUID(),
|
|
|
+ captchaKey: buildUUID(),
|
|
|
});
|
|
|
|
|
|
const formState = reactive({
|
|
|
- captchaSrc: getCaptcha(formData.codeKey),
|
|
|
+ captchaSrc: getCaptcha(formData.captchaKey),
|
|
|
showCaptcha: true,
|
|
|
rememberMe: true,
|
|
|
loading: false,
|
|
|
@@ -145,8 +153,8 @@
|
|
|
|
|
|
// 加载验证码
|
|
|
async function loadCaptcha() {
|
|
|
- formData.codeKey = buildUUID();
|
|
|
- formState.captchaSrc = getCaptcha(formData.codeKey);
|
|
|
+ formData.captchaKey = buildUUID();
|
|
|
+ formState.captchaSrc = getCaptcha(formData.captchaKey);
|
|
|
}
|
|
|
|
|
|
async function handleLogin() {
|
|
|
@@ -160,8 +168,8 @@
|
|
|
password: data.password,
|
|
|
loginType: 'login', //不要默认的错误提示
|
|
|
mode: 'none',
|
|
|
- codeKey: formData.codeKey,
|
|
|
- code: formData.code,
|
|
|
+ captchaKey: formData.captchaKey,
|
|
|
+ captchaCode: formData.captchaCode,
|
|
|
grant_type: '',
|
|
|
redirect,
|
|
|
client_id: clientId,
|
|
|
@@ -180,7 +188,9 @@
|
|
|
});
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- loadCaptcha();
|
|
|
+ if (formState.showCaptcha) {
|
|
|
+ loadCaptcha();
|
|
|
+ }
|
|
|
createErrorModal({
|
|
|
title: locales.api.errorTip,
|
|
|
content: (error as unknown as Error).message || locales.api.networkExceptionMsg,
|