Commit 5e688ed5 authored by 周宏民's avatar 周宏民

pref: 验证码添加失效状态 和 切换标签页自动更新

parent 17f4cec2
Pipeline #94323 waiting for manual action with stages
This diff was suppressed by a .gitattributes entry.
import 'kit_logger'; import 'kit_logger';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState, useRef } from 'react';
import { FieldNumberOutlined, ReloadOutlined } from '@ant-design/icons'; import { FieldNumberOutlined, ReloadOutlined } from '@ant-design/icons';
import { Button, Form, Input, message } from 'antd'; import { Button, Form, Input, message } from 'antd';
import omit from 'omit.js'; import omit from 'omit.js';
...@@ -9,10 +9,10 @@ import { useIntl } from '@wisdom-utils/components'; ...@@ -9,10 +9,10 @@ import { useIntl } from '@wisdom-utils/components';
import classNames from 'classnames'; import classNames from 'classnames';
import { appService } from '@/api'; import { appService } from '@/api';
import invalidIcon from '@/assets/images/login/已失效.png';
import styles from './index.less'; import styles from './index.less';
import LoginContext from './LoginContext'; import LoginContext from './LoginContext';
import ItemMap from './map'; import ItemMap from './map';
// import i18n from '../../../../../utils/share'; // import i18n from '../../../../../utils/share';
// const pages = i18n.getI18n('pages'); // const pages = i18n.getI18n('pages');
const FormItem = Form.Item; const FormItem = Form.Item;
...@@ -33,18 +33,15 @@ const getFormItemOptions = ({ onChange, defaultValue, customProps = {}, rules }) ...@@ -33,18 +33,15 @@ const getFormItemOptions = ({ onChange, defaultValue, customProps = {}, rules })
const ValidateCode = props => { const ValidateCode = props => {
const [count, setCount] = useState(0); const [count, setCount] = useState(0);
const [isOver, setIsOver] = useState(false);
const timer = useRef(null);
const codeUrl = window?.globalConfig?.hasGateWay const codeUrl = window?.globalConfig?.hasGateWay
? '/PandaCore/Identity/GetVerificationCode' ? '/PandaCore/Identity/GetVerificationCode'
: '/PandaCore/GCK/BussinessAuth/GetVerificationCode'; : '/PandaCore/GCK/BussinessAuth/GetVerificationCode';
const onTimeOver = () => {
useEffect(() => { console.log('超时了');
// eslint-disable-next-line no-use-before-define setIsOver(true);
window.share.event.on('loginError', handError);
return () => {
// eslint-disable-next-line no-use-before-define
window.share.event.removeListener('loginError', handError);
}; };
}, []);
const handError = () => { const handError = () => {
setCount(Date.now()); setCount(Date.now());
...@@ -52,12 +49,48 @@ const ValidateCode = props => { ...@@ -52,12 +49,48 @@ const ValidateCode = props => {
const handeRefresh = () => { const handeRefresh = () => {
setCount(Date.now()); setCount(Date.now());
setTimeout(() => {
setIsOver(false);
}, 100);
}; };
const handChange = value => { const handChange = value => {
props?.onChange?.(value); props?.onChange?.(value);
}; };
const visibilityChange = () => {
console.log('页面变化了');
handeRefresh();
};
useEffect(() => {
// eslint-disable-next-line no-use-before-define
window.share.event.on('loginError', handError);
document.onvisibilitychange = () => {
if (!document.hidden) visibilityChange();
};
return () => {
// eslint-disable-next-line no-use-before-define
window.share.event.removeListener('loginError', handError);
};
}, []);
useEffect(() => {
if (!isOver) {
console.log('开始计时');
if (timer.current) {
clearInterval(timer.current);
timer.current = null;
}
timer.current = setTimeout(() => {
onTimeOver();
}, 60 * 1000);
}
return () => {
if (timer.current) {
clearInterval(timer.current);
timer.current = null;
}
};
}, [isOver]);
return ( return (
<div className={styles.validate_view}> <div className={styles.validate_view}>
<Input <Input
...@@ -69,7 +102,14 @@ const ValidateCode = props => { ...@@ -69,7 +102,14 @@ const ValidateCode = props => {
onChange={handChange} onChange={handChange}
/> />
<div className={classNames(styles.validate_img, 'validate_img')}> <div className={classNames(styles.validate_img, 'validate_img')}>
{isOver ? (
<>
<img className={styles.validate_invalid} src={invalidIcon} height={35} alt="" />
</>
) : (
<img src={`${codeUrl}?time=${count}`} alt="" /> <img src={`${codeUrl}?time=${count}`} alt="" />
)}
<div className={styles.validate_refresh} onClick={handeRefresh}> <div className={styles.validate_refresh} onClick={handeRefresh}>
<ReloadOutlined /> <ReloadOutlined />
</div> </div>
......
@root-entry-name: 'variable'; @root-entry-name: 'variable';
@import (reference) '~antd/es/style/themes/index'; @import (reference) '~antd/es/style/themes/index';
.login { .login {
width: 250px; width: 250px;
:global { :global {
.ant-tabs .ant-tabs-bar { .ant-tabs .ant-tabs-bar {
margin-bottom: 24px; margin-bottom: 24px;
text-align: center; text-align: center;
border-bottom: 0; border-bottom: 0;
} }
.ant-form-item { .ant-form-item {
margin-bottom: 19px; margin-bottom: 19px;
// &-has-error { // &-has-error {
// margin-bottom: 0px!important; // margin-bottom: 0px!important;
// } // }
...@@ -21,11 +25,13 @@ ...@@ -21,11 +25,13 @@
min-height: 19px; min-height: 19px;
font-size: 13px; font-size: 13px;
} }
&-with-help { &-with-help {
margin-bottom: 0; margin-bottom: 0;
} }
} }
} }
.getCaptcha { .getCaptcha {
color: @primary-6; color: @primary-6;
font-weight: 400; font-weight: 400;
...@@ -36,6 +42,7 @@ ...@@ -36,6 +42,7 @@
height: auto !important; height: auto !important;
border: none !important; border: none !important;
} }
.desc { .desc {
width: 88px; width: 88px;
font-size: 20px; font-size: 20px;
...@@ -100,12 +107,24 @@ ...@@ -100,12 +107,24 @@
} }
} }
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: contain; object-fit: contain;
} }
.validate_invalid {
display: inline-block;
width: 100%;
text-align: center;
line-height: 40px;
// color: #d81e06;
height: 30px;
margin-top: 5px;
}
.validate_refresh { .validate_refresh {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
...@@ -24,6 +24,12 @@ import logo from './images/logo.png'; ...@@ -24,6 +24,12 @@ import logo from './images/logo.png';
import qrcodePng from './images/1.png'; import qrcodePng from './images/1.png';
import loginTitlePng from './images/text.png'; import loginTitlePng from './images/text.png';
import Krpano from '../../../components/Krpano'; import Krpano from '../../../components/Krpano';
// 背景图在这里引入一次,避免打包时丢失
import 背景 from './images/背景.png';
import left from './images/left.png';
import 标题 from './images/标题.png';
import 登录btn from './images/登录btn.png';
import 展开bg from './images/展开bg.png';
const PopOvercontent = () => { const PopOvercontent = () => {
const qrcodes = window.globalConfig && window.globalConfig.qrcode; const qrcodes = window.globalConfig && window.globalConfig.qrcode;
...@@ -43,7 +49,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -43,7 +49,7 @@ const Login = forwardRef((props, _ref) => {
const krpanoRef = useRef(null); const krpanoRef = useRef(null);
const krpanoSceneIdRef = useRef(localStorage.getItem('loginKrpanoSceneId')); const krpanoSceneIdRef = useRef(localStorage.getItem('loginKrpanoSceneId'));
const [status, setStatus] = useState('normal'); const [status, setStatus] = useState('normal');
const [showList, setShowList] = useState(true); const [showList, setShowList] = useState(false);
const [autoLogin, setAutoLogin] = useState(false); const [autoLogin, setAutoLogin] = useState(false);
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const [type, setType] = useState('Account'); const [type, setType] = useState('Account');
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
position: relative; position: relative;
width: 660px; width: 660px;
height: 454px; height: 454px;
background: url(./images/背景.png) no-repeat center center; background: url(./images/背景.png) no-repeat center center;
background-size: 100% 100%; background-size: 100% 100%;
...@@ -294,22 +293,23 @@ ...@@ -294,22 +293,23 @@
.suzhou_krpano { .suzhou_krpano {
.panda-krpano-es-preview-footer-footer-footerContainer .panda-krpano-es-preview-footer-footer-mask { .panda-krpano-es-preview-footer-footer-footerContainer .panda-krpano-es-preview-footer-footer-mask {
bottom: 0; bottom: 0;
background: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4) 70%, rgba(0, 99, 163, 0.6)) background: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4) 70%, rgba(0, 99, 163, 0.6));
// height: 0;
transition: all 0.3s;
} }
.panda-krpano-es-preview-menu-menu-itemIcon{
display: none!important; .panda-krpano-es-preview-menu-menu-itemIcon {
display: none !important;
} }
} }
.suzhou_hideList { .suzhou_hideList {
.panda-krpano-es-preview-footer-footer-footerContainer .panda-krpano-es-preview-footer-footer-mask { .panda-krpano-es-preview-footer-footer-footerContainer .panda-krpano-es-preview-footer-footer-mask {
bottom: -130px; bottom: -130px;
transition: all 0.3s;
} }
.krpano_btn { .krpano_btn {
bottom: 0px !important; bottom: 0px !important;
transition: all 0.3s;
} }
} }
} }
...@@ -330,6 +330,7 @@ ...@@ -330,6 +330,7 @@
background-size: 100% 100%; background-size: 100% 100%;
z-index: 1000; z-index: 1000;
cursor: pointer; cursor: pointer;
transition: all 0.3s;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment