Commit 8b66ab74 authored by 李纪文's avatar 李纪文

fix: 直接token刷新

parent c4e62b55
......@@ -48,6 +48,7 @@ import {
isJson,
stationData,
getVideoUrl,
loginauthen,
} from './js/utils';
import './index.less';
......@@ -101,6 +102,7 @@ const ConfigurationView = (props) => {
const ConfigurationRef = useRef();
const DomRef = useRef();
const TwoRef = useRef();
const loginTimer = useRef();
const ConfigurationViewRef = useCallback((dom) => {
if (DomRef) DomRef.current = !!dom;
setDomFlag(!!dom);
......@@ -893,6 +895,17 @@ const ConfigurationView = (props) => {
}
}, [isAuModalVisible]);
useEffect(() => {
loginauthen();
loginTimer.current = setInterval(() => {
loginauthen();
}, 1000 * 28800 );
return () => {
clearInterval(loginTimer.current);
loginTimer.current = null;
};
}, []);
/** ************************************获取画板JSON******************************* */
const getDiagramJson = async (list, siteInfo) => {
const response = await getSketchPadContent({
......@@ -3144,7 +3157,7 @@ const ConfigurationView = (props) => {
// title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''}
wrapClassName={classNames(`${prefixCls}-historyInfoModal`)}
>
<HistoryView deviceParams={historyInfoParams} />
<HistoryView deviceParams={historyInfoParams} title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''} />
</Modal>
)}
{/* 统计历史曲线 */}
......
......@@ -85,3 +85,12 @@ export function getDictionaryInfo(params) {
params,
});
}
// 获取
export function authorizationToken(params) {
return request({
url: `${baseURI}/PandaCore/Identity/AuthorizationToken`,
method: REQUEST_METHOD_GET,
params,
});
}
\ No newline at end of file
import { authorizationToken } from '../apis';
// 判断是否是数字
export const isNumber = (val) => {
const regPos = /^\d+(\.\d+)?$/; // 非负浮点数
......@@ -159,3 +161,18 @@ export const getVideoUrl = () => {
return hasGateWay ? `${address}/` : `${defaultAddress}/`;
};
export const loginauthen = () => {
if (!window.globalConfig?.hasGateWay) return false;
authorizationToken({
loginName: window.globalConfig.userInfo?.loginName || '',
type: 'WorkNo',
})
.then((tokenRes) => {
if (tokenRes.code === 0) {
window.globalConfig.access_token = tokenRes.data?.access_token ?? '';
localStorage.setItem('access_token', tokenRes.data?.access_token ?? '');
}
})
.catch((err) => {});
};
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