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

fix: 直接token刷新

parent c4e62b55
...@@ -48,6 +48,7 @@ import { ...@@ -48,6 +48,7 @@ import {
isJson, isJson,
stationData, stationData,
getVideoUrl, getVideoUrl,
loginauthen,
} from './js/utils'; } from './js/utils';
import './index.less'; import './index.less';
...@@ -101,6 +102,7 @@ const ConfigurationView = (props) => { ...@@ -101,6 +102,7 @@ const ConfigurationView = (props) => {
const ConfigurationRef = useRef(); const ConfigurationRef = useRef();
const DomRef = useRef(); const DomRef = useRef();
const TwoRef = useRef(); const TwoRef = useRef();
const loginTimer = useRef();
const ConfigurationViewRef = useCallback((dom) => { const ConfigurationViewRef = useCallback((dom) => {
if (DomRef) DomRef.current = !!dom; if (DomRef) DomRef.current = !!dom;
setDomFlag(!!dom); setDomFlag(!!dom);
...@@ -893,6 +895,17 @@ const ConfigurationView = (props) => { ...@@ -893,6 +895,17 @@ const ConfigurationView = (props) => {
} }
}, [isAuModalVisible]); }, [isAuModalVisible]);
useEffect(() => {
loginauthen();
loginTimer.current = setInterval(() => {
loginauthen();
}, 1000 * 28800 );
return () => {
clearInterval(loginTimer.current);
loginTimer.current = null;
};
}, []);
/** ************************************获取画板JSON******************************* */ /** ************************************获取画板JSON******************************* */
const getDiagramJson = async (list, siteInfo) => { const getDiagramJson = async (list, siteInfo) => {
const response = await getSketchPadContent({ const response = await getSketchPadContent({
...@@ -3144,7 +3157,7 @@ const ConfigurationView = (props) => { ...@@ -3144,7 +3157,7 @@ const ConfigurationView = (props) => {
// title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''} // title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''}
wrapClassName={classNames(`${prefixCls}-historyInfoModal`)} wrapClassName={classNames(`${prefixCls}-historyInfoModal`)}
> >
<HistoryView deviceParams={historyInfoParams} /> <HistoryView deviceParams={historyInfoParams} title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''} />
</Modal> </Modal>
)} )}
{/* 统计历史曲线 */} {/* 统计历史曲线 */}
......
...@@ -85,3 +85,12 @@ export function getDictionaryInfo(params) { ...@@ -85,3 +85,12 @@ export function getDictionaryInfo(params) {
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) => { export const isNumber = (val) => {
const regPos = /^\d+(\.\d+)?$/; // 非负浮点数 const regPos = /^\d+(\.\d+)?$/; // 非负浮点数
...@@ -159,3 +161,18 @@ export const getVideoUrl = () => { ...@@ -159,3 +161,18 @@ export const getVideoUrl = () => {
return hasGateWay ? `${address}/` : `${defaultAddress}/`; 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