|
|
@@ -48,7 +48,13 @@
|
|
|
<el-button class="login-form__button" @click="handleLogin">登录</el-button>
|
|
|
</footer>
|
|
|
</div>
|
|
|
- <SliderCaptcha captchaType="blockPuzzle" mode="pop" @success="handleCaptchaPassed" ref="sliderCaptchaRef" />
|
|
|
+ <SliderCaptcha
|
|
|
+ v-if="showCaptcha"
|
|
|
+ captchaType="blockPuzzle"
|
|
|
+ mode="pop"
|
|
|
+ @success="handleCaptchaPassed"
|
|
|
+ ref="sliderCaptchaRef"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -61,16 +67,17 @@
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
import { PWD_KEY } from '@/utils/pwd';
|
|
|
import SliderCaptcha from '@/components/Login/components/slider-captcha/Verify.vue';
|
|
|
+ import { useGlobSetting } from '@/hooks/setting';
|
|
|
|
|
|
const props = defineProps<{ title: string }>();
|
|
|
+ const { showCaptcha } = useGlobSetting();
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
const formValue = reactive({
|
|
|
username: userStore.info.username,
|
|
|
password: '',
|
|
|
- captchaVerification:'',
|
|
|
-
|
|
|
+ captchaVerification: '',
|
|
|
});
|
|
|
const sliderCaptchaRef = ref<InstanceType<typeof SliderCaptcha>>();
|
|
|
|
|
|
@@ -100,7 +107,11 @@
|
|
|
if (!formRef.value) return;
|
|
|
formRef.value.validate((valid: boolean) => {
|
|
|
if (valid) {
|
|
|
+ if (showCaptcha) {
|
|
|
sliderCaptchaRef.value?.show();
|
|
|
+ } else {
|
|
|
+ onLogin();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
@@ -109,14 +120,15 @@
|
|
|
onLogin(captchaVerification);
|
|
|
};
|
|
|
|
|
|
- const onLogin = (vification: string) => {
|
|
|
+ const onLogin = (vification?: string) => {
|
|
|
console.log('valid', formValue);
|
|
|
- formValue.captchaVerification=vification
|
|
|
+
|
|
|
const encryptedPwd = md5(PWD_KEY + formValue.password);
|
|
|
const loginParams = {
|
|
|
...formValue,
|
|
|
+ captchaVerification: vification || undefined,
|
|
|
password: encryptedPwd, // 替换为加密后的密码
|
|
|
- };
|
|
|
+ };
|
|
|
userStore
|
|
|
.login(loginParams)
|
|
|
.then(() => {
|