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