Commit aebc19d3 authored by 周宏民's avatar 周宏民

fix: 演示功能 刷新跳登录页

parent 197c570d
Pipeline #89077 waiting for manual action with stages
......@@ -7,6 +7,12 @@ import React, { useEffect, useMemo, useState } from 'react';
import { Empty, Spin, notification } from 'antd';
import SecurityLayout from '@/layouts/SecurityLayout';
import { appService } from '@/api';
import Cookies from 'js-cookie';
import _ from 'lodash';
import { useHistory, useAliveController } from '@wisdom-utils/runtime';
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import { SERVICE_INTERFACE_SUCCESS_CODE } from '@/constants';
import PandaBootPage from './panda';
import IntegrationPage from './integration';
......@@ -24,6 +30,8 @@ const BootPage = props => {
loading: true,
error: false,
});
const { clear } = useAliveController();
const history = useHistory();
const [template, setTemplate] = useState('default');
const [pattern, setPattern] = useState(true); // 是否进入演示模式
const RenderComponent = useMemo(() => {
......@@ -38,6 +46,18 @@ const BootPage = props => {
return BootPageTemplate[template] || BootPageTemplate.default;
}, [template, pattern]);
useEffect(() => {
const tk = Cookies.get('token') || props.global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== void 0;
let client = props?.global?.client || sessionStorage.getItem('client') || null;
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
const generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null;
if (!isLogin) {
history.push(`/user/login?client=${client}${generateType || ''}`, { reload: true });
clear();
props.logout();
}
}, [clear, history, props]);
useEffect(() => {
if (window?.globalConfig?.isIntegration >= 1) {
setInfo({ first: false, loading: false, error: false });
......@@ -71,5 +91,16 @@ const BootPage = props => {
</SecurityLayout>
);
};
export default BootPage;
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
instance: state.getIn(['global', 'instance']),
});
const mapDispatchToProps = dispatch => ({
logout() {
dispatch(actionCreators.logout());
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(BootPage);
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