Commit 3d11bbd9 authored by 周宏民's avatar 周宏民

feat: 修改集成登录配全局引用

parent 50759b3b
Pipeline #93749 waiting for manual action with stages
...@@ -17,8 +17,17 @@ import LoadPage from '@/components/LoadPage'; ...@@ -17,8 +17,17 @@ import LoadPage from '@/components/LoadPage';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'; import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { goToPath, searchUrl } from '@/utils/utils'; import { goToPath, searchUrl } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
const tipStyleMap = {
左下: {
justifyContent: 'flex-start',
},
// 中下:{},
右下: {
justifyContent: 'flex-end',
},
};
const IntegratedSwitch = props => { const IntegratedSwitch = props => {
const integratedConfig = props.integratedConfig?.toObject ? props.integratedConfig.toObject() : props.integratedConfig || {}
const timer = useRef(null); const timer = useRef(null);
const timer3 = useRef(null); const timer3 = useRef(null);
const progressRef = useRef(0); const progressRef = useRef(0);
...@@ -255,8 +264,13 @@ const IntegratedSwitch = props => { ...@@ -255,8 +264,13 @@ const IntegratedSwitch = props => {
}; };
}, [loginAction.events, props]); }, [loginAction.events, props]);
return dataList.length > 1 ? ( return dataList.length > 1 && integratedConfig?.isShowTip !== '不显示' ? (
<div className={styles.switchPage}> <div
className={styles.switchPage}
style={{
...tipStyleMap[(integratedConfig?.tipAlign)],
}}
>
{jumpLoading ? ( {jumpLoading ? (
<div className={styles.integrationJumpLoad} key="jumpLoading"> <div className={styles.integrationJumpLoad} key="jumpLoading">
<div style={{ width: '285px' }}> <div style={{ width: '285px' }}>
...@@ -301,6 +315,7 @@ const mapStateToProps = state => ({ ...@@ -301,6 +315,7 @@ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
instance: state.getIn(['global', 'instance']), instance: state.getIn(['global', 'instance']),
client: state.getIn(['global', 'client']), client: state.getIn(['global', 'client']),
integratedConfig: state.getIn(['global', 'integratedConfig']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updateConfig(config) { updateConfig(config) {
......
.switchPage { .switchPage {
position: fixed; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
z-index: 1200; z-index: 1200;
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
justify-content: center; justify-content: center;
width: 100%; width: 100%;
height: 0px; height: 0px;
padding: 0 10px;
.integrationJumpLoad { .integrationJumpLoad {
width: 100vw; width: 100vw;
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
border-radius: 14px; border-radius: 14px;
overflow: hidden; overflow: hidden;
height: 8px; height: 8px;
min-width: 80px;
// width: 80px; // width: 80px;
width: auto; width: auto;
background: rgba(94, 121, 143, .65); background: rgba(94, 121, 143, .65);
...@@ -52,7 +54,7 @@ ...@@ -52,7 +54,7 @@
} }
.switchPageLi { .switchPageLi {
padding: 10px; padding: 10px 5px;
// display: none; // display: none;
display: flex; display: flex;
height: 100%; height: 100%;
......
...@@ -25,6 +25,7 @@ import { ...@@ -25,6 +25,7 @@ import {
MAP_VIEW, MAP_VIEW,
AMAP_VIEW, AMAP_VIEW,
PD_VIEW, PD_VIEW,
CONFIG_INTEGRATED,
} from './constants'; } from './constants';
export function getConfig(data) { export function getConfig(data) {
return { return {
...@@ -185,6 +186,13 @@ export function updatePdCesiumView(data) { ...@@ -185,6 +186,13 @@ export function updatePdCesiumView(data) {
}; };
} }
export function updateIntegratedConfig(data) {
return {
type: CONFIG_INTEGRATED,
data,
};
}
export function logout(data) { export function logout(data) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
createStoreage.remove('PANDA_STORE'); createStoreage.remove('PANDA_STORE');
...@@ -230,6 +238,7 @@ export function logout(data) { ...@@ -230,6 +238,7 @@ export function logout(data) {
} }
localStorage.removeItem('integrationClient'); localStorage.removeItem('integrationClient');
localStorage.removeItem('integrationData'); localStorage.removeItem('integrationData');
localStorage.removeItem('integrationConfig');
localStorage.removeItem('access_token'); localStorage.removeItem('access_token');
localStorage.removeItem('password_token'); localStorage.removeItem('password_token');
localStorage.removeItem('password_pwdRegex'); localStorage.removeItem('password_pwdRegex');
......
...@@ -22,3 +22,4 @@ export const LOGINOUT = 'App/LOGINOUT'; ...@@ -22,3 +22,4 @@ export const LOGINOUT = 'App/LOGINOUT';
export const MAP_VIEW = 'App/MAP_VIEW'; export const MAP_VIEW = 'App/MAP_VIEW';
export const AMAP_VIEW = 'App/AMAP_VIEW'; export const AMAP_VIEW = 'App/AMAP_VIEW';
export const PD_VIEW = 'App/PD_VIEW'; export const PD_VIEW = 'App/PD_VIEW';
export const CONFIG_INTEGRATED = 'App/CONFIG_INTEGRATED';
...@@ -33,6 +33,7 @@ import { ...@@ -33,6 +33,7 @@ import {
MAP_VIEW, MAP_VIEW,
AMAP_VIEW, AMAP_VIEW,
PD_VIEW, PD_VIEW,
CONFIG_INTEGRATED,
} from './constants'; } from './constants';
const { generMainRoutes, generFlatRoutes, transformWidgets } = helpers; const { generMainRoutes, generFlatRoutes, transformWidgets } = helpers;
...@@ -73,6 +74,7 @@ export const initialState = fromJS({ ...@@ -73,6 +74,7 @@ export const initialState = fromJS({
microMounted: true, microMounted: true,
mapView: null, mapView: null,
amapView: {}, amapView: {},
integratedConfig: JSON.parse(localStorage.getItem('integrationConfig') || '{}'),
}); });
/* eslint-disable default-case, no-param-reassign */ /* eslint-disable default-case, no-param-reassign */
...@@ -80,24 +82,19 @@ const appReducer = (state = initialState, action) => { ...@@ -80,24 +82,19 @@ const appReducer = (state = initialState, action) => {
switch (action.type) { switch (action.type) {
case GET_CONFIG: case GET_CONFIG:
/* eslint-disable */ /* eslint-disable */
window.__INITIAL_STATE__ = Object.assign( window.__INITIAL_STATE__ = Object.assign({}, action.data, {
{}, assetsRoot: proxy.assetsRoot,
action.data, allWidgets: action.data.widgets || [],
{ env: process.env.NODE_ENV === 'development' ? 'daily' : 'prod',
assetsRoot: proxy.assetsRoot, });
allWidgets: action.data.widgets || [],
env: process.env.NODE_ENV === 'development' ? 'daily' : 'prod',
},
);
window.arcgisAssetsPath = `${window.location.origin}/${pkg.name.toLocaleLowerCase()}/assets`; window.arcgisAssetsPath = `${window.location.origin}/${pkg.name.toLocaleLowerCase()}/assets`;
window.__INITIAL_STATE__.mdi = 'SDI'; window.__INITIAL_STATE__.mdi = 'SDI';
window.__INITIAL_STATE__.menu = 'banner-left'; window.__INITIAL_STATE__.menu = 'banner-left';
const temp = AppConfig(window.__INITIAL_STATE__) const temp = AppConfig(window.__INITIAL_STATE__);
temp.displayMode = window.__INITIAL_STATE__?.displayMode||'' temp.displayMode = window.__INITIAL_STATE__?.displayMode || '';
temp.isVerification = action.data.isVerification || ''; temp.isVerification = action.data.isVerification || '';
window.globalConfig = temp; window.globalConfig = temp;
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
createStoreage.set('globalConfig', window.globalConfig); createStoreage.set('globalConfig', window.globalConfig);
// eslint-disable-next-line no-undef,no-case-declarations // eslint-disable-next-line no-undef,no-case-declarations
...@@ -106,9 +103,12 @@ const appReducer = (state = initialState, action) => { ...@@ -106,9 +103,12 @@ const appReducer = (state = initialState, action) => {
// eslint-disable-next-line no-case-declarations // eslint-disable-next-line no-case-declarations
const { homepage, isOpenTransitionPage } = window.globalConfig; const { homepage, isOpenTransitionPage } = window.globalConfig;
const modulePkg = {}; const modulePkg = {};
window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => { window.globalConfig &&
modulePkg[item.PackageName] = item; window.globalConfig.products &&
}); Array.isArray(window.globalConfig.products) &&
window.globalConfig.products.map(item => {
modulePkg[item.PackageName] = item;
});
config.widgets = transformWidgets(config.widgets); config.widgets = transformWidgets(config.widgets);
// const pickMenus = memoized(() => ) // const pickMenus = memoized(() => )
const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg);
...@@ -116,14 +116,16 @@ const appReducer = (state = initialState, action) => { ...@@ -116,14 +116,16 @@ const appReducer = (state = initialState, action) => {
if (generMenu) { if (generMenu) {
const flat = state.toJS(); const flat = state.toJS();
const data = _.uniqBy(generFlatRoutes(generMenu || [], null, null, modulePkg), 'path'); const data = _.uniqBy(generFlatRoutes(generMenu || [], null, null, modulePkg), 'path');
if (_.isEqualWith(flat.flatMenu, data, (value, other) => { if (
if (value.path === other.path) { _.isEqualWith(flat.flatMenu, data, (value, other) => {
return true if (value.path === other.path) {
} return true;
})) { }
flatMenu = data })
) {
flatMenu = data;
} else { } else {
flatMenu = flat.flatMenu flatMenu = flat.flatMenu;
} }
const index = flatMenu.findIndex(item => item.name === '首页'); const index = flatMenu.findIndex(item => item.name === '首页');
if (!isOpenTransitionPage && index === -1) { if (!isOpenTransitionPage && index === -1) {
...@@ -131,8 +133,8 @@ const appReducer = (state = initialState, action) => { ...@@ -131,8 +133,8 @@ const appReducer = (state = initialState, action) => {
path: `/${homepage}`, path: `/${homepage}`,
href: `/${homepage}`, href: `/${homepage}`,
key: 'PANDA_HOME', key: 'PANDA_HOME',
name: '首页' name: '首页',
}) });
} }
} }
...@@ -145,14 +147,12 @@ const appReducer = (state = initialState, action) => { ...@@ -145,14 +147,12 @@ const appReducer = (state = initialState, action) => {
return currentPath === decodeURI(homepage); return currentPath === decodeURI(homepage);
}); });
let currentMenuIndex = 0; let currentMenuIndex = 0;
if (home) { if (home) {
const parent = home.level >= 2 ? home.parent.parent : home.level >= 3 ? home.parent.parent.parent : home.parent; const parent = home.level >= 2 ? home.parent.parent : home.level >= 3 ? home.parent.parent.parent : home.parent;
if (parent) { if (parent) {
currentMenuIndex = generMenu.findIndex(item => item.name === parent.label) || 0; currentMenuIndex = generMenu.findIndex(item => item.name === parent.label) || 0;
sessionStorage.setItem(currentProduct, currentMenuIndex) sessionStorage.setItem(currentProduct, currentMenuIndex);
store.set('updateMenuIndex', currentMenuIndex); store.set('updateMenuIndex', currentMenuIndex);
} }
} }
...@@ -208,8 +208,10 @@ const appReducer = (state = initialState, action) => { ...@@ -208,8 +208,10 @@ const appReducer = (state = initialState, action) => {
recentVisited: [], recentVisited: [],
}); });
case GET_CURRENT_INDEX: case GET_CURRENT_INDEX:
const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${sessionStorage.getItem('client') || window.globalConfig?.client || 'city'}`; const currentProductNew = `__global__recent_productIndex__micro_${
sessionStorage.setItem(currentProductNew, action.data) window.location.hostname
}_${sessionStorage.getItem('client') || window.globalConfig?.client || 'city'}`;
sessionStorage.setItem(currentProductNew, action.data);
return state.merge({ return state.merge({
currentMenuIndex: Number(sessionStorage.getItem(currentProductNew)) || 0, currentMenuIndex: Number(sessionStorage.getItem(currentProductNew)) || 0,
}); });
...@@ -271,7 +273,11 @@ const appReducer = (state = initialState, action) => { ...@@ -271,7 +273,11 @@ const appReducer = (state = initialState, action) => {
return state.merge({ return state.merge({
pdView: action.data, pdView: action.data,
}); });
case CONFIG_INTEGRATED:
localStorage.setItem('integrationConfig',action.data ? JSON.stringify(action.data) : '');
return state.merge({
integratedConfig: fromJS(action.data || {})
});
default: default:
return state; return state;
} }
......
...@@ -266,6 +266,7 @@ const Layout = props => { ...@@ -266,6 +266,7 @@ const Layout = props => {
) || ) ||
sessionStorage.getItem('client') || sessionStorage.getItem('client') ||
'city'}`; 'city'}`;
const integratedConfig = props.integratedConfig?.toObject ? props.integratedConfig.toObject() : props.integratedConfig || {}
const menuState = sessionStorage.getItem('menuState') || 'open'; const menuState = sessionStorage.getItem('menuState') || 'open';
const [cityData, setCityData] = useState({}); const [cityData, setCityData] = useState({});
const [siteLoading, setSiteLoading] = useState(false); const [siteLoading, setSiteLoading] = useState(false);
...@@ -822,6 +823,7 @@ const mapStateToProps = state => ({ ...@@ -822,6 +823,7 @@ const mapStateToProps = state => ({
flatMenu: state.getIn(['global', 'flatMenu']), flatMenu: state.getIn(['global', 'flatMenu']),
instance: state.getIn(['global', 'instance']), instance: state.getIn(['global', 'instance']),
currentMenuIndex: state.getIn(['global', 'currentMenuIndex']), currentMenuIndex: state.getIn(['global', 'currentMenuIndex']),
integratedConfig: state.getIn(['global', 'integratedConfig'])
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updageSetting(setting) { updageSetting(setting) {
......
...@@ -22,7 +22,6 @@ const BootPage = props => { ...@@ -22,7 +22,6 @@ const BootPage = props => {
loading: true, loading: true,
error: false, error: false,
}); });
const integratedConfig = useRef({});
const { clear } = useAliveController(); const { clear } = useAliveController();
const history = useHistory(); const history = useHistory();
const [template, setTemplate] = useState(window?.globalConfig?.displayMode || 'default'); const [template, setTemplate] = useState(window?.globalConfig?.displayMode || 'default');
...@@ -57,28 +56,23 @@ const BootPage = props => { ...@@ -57,28 +56,23 @@ const BootPage = props => {
setInfo({ first: false, loading: false, error: true }); setInfo({ first: false, loading: false, error: true });
return; return;
} }
integratedConfig.current = data;
let displayMode = data?.displayMode || 'default'; let displayMode = data?.displayMode || 'default';
if (displayMode === '卡片' || displayMode === '地图') { if (displayMode === '卡片' || displayMode === '地图') {
displayMode = 'default'; displayMode = 'default';
} }
props.updateIntegratedConfig(data || '');
setTemplate(displayMode); setTemplate(displayMode);
setInfo({ first: false, loading: false, error: false }); setInfo({ first: false, loading: false, error: false });
}) })
.catch(err => { .catch(err => {
setInfo({ first: false, loading: false, error: true }); setInfo({ first: false, loading: false, error: true });
props.updateIntegratedConfig('');
}); });
}, []); }, []);
return ( return (
<SecurityLayout> <SecurityLayout>
{info.loading ? ( {info.loading ? <Spin /> : info.error ? <Empty /> : <RenderComponent {...{ ...props }} />}
<Spin />
) : info.error ? (
<Empty />
) : (
<RenderComponent {...{ ...props, ...{ integratedConfig: integratedConfig.current } }} />
)}
</SecurityLayout> </SecurityLayout>
); );
}; };
...@@ -90,6 +84,9 @@ const mapDispatchToProps = dispatch => ({ ...@@ -90,6 +84,9 @@ const mapDispatchToProps = dispatch => ({
logout() { logout() {
dispatch(actionCreators.logout()); dispatch(actionCreators.logout());
}, },
updateIntegratedConfig(data) {
dispatch(actionCreators.updateIntegratedConfig(data));
},
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -33,7 +33,10 @@ const boxWidth = 1920; ...@@ -33,7 +33,10 @@ const boxWidth = 1920;
const boxHeight = 930; const boxHeight = 930;
const IntegrationNew = props => { const IntegrationNew = props => {
const { integratedConfig } = props; const integratedConfig = props.integratedConfig?.toObject
? props.integratedConfig.toObject()
: props.integratedConfig || {};
const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false); const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false);
const history = useHistory(); const history = useHistory();
const integrationClient = integratedConfig?.client || window?.globalConfig?.client || 'city'; // 集成登录client const integrationClient = integratedConfig?.client || window?.globalConfig?.client || 'city'; // 集成登录client
...@@ -450,6 +453,7 @@ const IntegrationNew = props => { ...@@ -450,6 +453,7 @@ const IntegrationNew = props => {
}; };
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
integratedConfig: state.getIn(['global', 'integratedConfig']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updateConfig(config) { updateConfig(config) {
......
...@@ -27,7 +27,9 @@ import Iframe from '../../demonstration/components/Iframe'; ...@@ -27,7 +27,9 @@ import Iframe from '../../demonstration/components/Iframe';
const boxWidth = 1920; const boxWidth = 1920;
const boxHeight = 930; const boxHeight = 930;
const IntegrationQinzhou = props => { const IntegrationQinzhou = props => {
const { integratedConfig } = props; const integratedConfig = props.integratedConfig?.toObject
? props.integratedConfig.toObject()
: props.integratedConfig || {};
const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false); const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false);
const clientRef = useRef(props.global.client); const clientRef = useRef(props.global.client);
...@@ -508,6 +510,7 @@ const IntegrationQinzhou = props => { ...@@ -508,6 +510,7 @@ const IntegrationQinzhou = props => {
}; };
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
integratedConfig: state.getIn(['global', 'integratedConfig']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updateConfig(config) { updateConfig(config) {
......
...@@ -614,36 +614,6 @@ const AddModal = props => { ...@@ -614,36 +614,6 @@ const AddModal = props => {
</Item> </Item>
</Col> </Col>
</Row> </Row>
{/* <Item
label="AppKey"
name="appKey"
className={styles.disabledInput}
// rules={[{ required: true, message: '请输入参数' }]}
>
<Input placeholder="请输入自定义的AppKey," />
</Item> */}
{/* <Item
label="AppSecret"
name="appSecret"
className={styles.disabledInput}
// rules={[{ required: true, message: '请输入AppKey,或点击刷新按钮重新获取AppSecret' }]}
>
<Input
disabled
placeholder="请点击按钮生成AppSecret"
suffix={
<Tooltip title="点击按钮重新生成AppSecret">
<RedoOutlined
style={{ fontSize: 'bold', color: 'rgba(25,128,255,0.74)' }}
onClick={refreshAppSecret}
/>
</Tooltip>
}
/>
</Item> */}
{/* <Item label="白名单" name="whiteList">
<TextArea rows={3} />
</Item> */}
</> </>
) : ( ) : (
<> <>
...@@ -651,37 +621,15 @@ const AddModal = props => { ...@@ -651,37 +621,15 @@ const AddModal = props => {
<Input placeholder="请输入网站client" /> <Input placeholder="请输入网站client" />
</Item> </Item>
<Item <Item
label="地址" label="功能路径"
name="url" name="url"
tooltip={{ tooltip={{
title: '默认访问功能地址,不填则默认跳转当前网站首页', title: '默认访问功能地址,地址为运维配置的功能路径,不填则默认跳转当前网站首页',
icon: <InfoCircleOutlined />, icon: <InfoCircleOutlined />,
}} }}
> >
<AutoComplete placeholder="请输入默认访问功能地址" allowClear /> <AutoComplete placeholder="请输入默认访问功能路径" allowClear />
</Item> </Item>
{/* <Item
label="client"
name="appKey"
className={styles.disabledInput}
tooltip={{
title: '对应网站client',
icon: <InfoCircleOutlined />,
}}
rules={[{ required: true, message: '请输入参数' }]}
>
<Input placeholder="请输入网站client" />
</Item> */}
{/* <Item
label="地址"
name="url"
tooltip={{
title: '默认访问功能地址,不填则默认跳转当前网站首页',
icon: <InfoCircleOutlined />,
}}
>
<AutoComplete placeholder="请输入默认访问功能地址" allowClear />
</Item> */}
</> </>
)} )}
<Item <Item
......
...@@ -88,7 +88,7 @@ const Master = props => { ...@@ -88,7 +88,7 @@ const Master = props => {
tipAlign: obj.tipAlign, tipAlign: obj.tipAlign,
}, },
}; };
if (isShowTip !== '直排' || isShowTip !== '转盘') { if (isShowTip !== '直排' && isShowTip !== '转盘') {
params.tipAlign = settingRef.current.tipAlign || '中下'; params.tipAlign = settingRef.current.tipAlign || '中下';
} }
appService appService
......
...@@ -397,7 +397,10 @@ const IntegratedLogin = props => { ...@@ -397,7 +397,10 @@ const IntegratedLogin = props => {
add(e.key); add(e.key);
}; };
const onMasterBack = data => { const onMasterBack = data => {
if (data) configSetting.current = data; if (data) {
configSetting.current = data;
props.updateIntegratedConfig(data);
}
}; };
const getConfigData = () => { const getConfigData = () => {
appService appService
...@@ -425,6 +428,7 @@ const IntegratedLogin = props => { ...@@ -425,6 +428,7 @@ const IntegratedLogin = props => {
.GetIntegratedloginSetting() .GetIntegratedloginSetting()
.then(res => { .then(res => {
configSetting.current = res.data || {}; configSetting.current = res.data || {};
getData(); getData();
getConfigData(); getConfigData();
}) })
...@@ -529,6 +533,9 @@ const mapDispatchToProps = dispatch => ({ ...@@ -529,6 +533,9 @@ const mapDispatchToProps = dispatch => ({
updateConfig(config) { updateConfig(config) {
dispatch(actionCreators.getConfig(config)); dispatch(actionCreators.getConfig(config));
}, },
updateIntegratedConfig(data) {
dispatch(actionCreators.updateIntegratedConfig(data));
},
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
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