Commit a0f1a1bf authored by 徐乐's avatar 徐乐

feat: 修改集成网站

parent 0c65e1d6
......@@ -23,6 +23,9 @@ import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less';
import SecurityLayout from './SecurityLayout';
import Site from './Site';
import { defaultApp } from '@/micro';
import { appService } from '@/api';
import LoginAction from '@/pages/user/login/login';
const { params } = helpers;
......@@ -94,15 +97,16 @@ const OnlyFocusStations = props => {
</Spin>
);
};
const AllStations = props => {
const data = props.data.stations;
const [targetOffset, setTargetOffset] = useState(undefined);
const cityPane = useRef(null);
const cityContent = useRef(null);
const [defaultTab, setDefaultTab] = useState('site');
useEffect(() => {
setTargetOffset(cityPane.current.clientHeight / 2);
}, []);
const handleClick = (event, link) => {
......@@ -223,6 +227,73 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM
);
};
const checkIntegration = (val, loginAction, props) => {
if (val.subType == '外链') {
window.open(val.url, "_blank");
} else {
let cli = val.url?.indexOf('client=') >= 0 ? val.url.split('client=')[1] : '';
const config = props.global;
config.uiwidgets = [];
config.widgets = [];
config.allWidgets = [];
if (cli) {
config.client = cli;
}
props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, val.type, cli);
props.history.push(`/?client=${cli}`);
props.updateCurrentIndex(0);
defaultApp();
}
}
const renderIntegration = (inData, loginAction, props) => {
const [visible, setVisible] = useState(false);
if (inData.length <= 1) {
return <></>
}
let choiceOne = inData?.find(function (a) {
return a.url?.indexOf(window?.globalConfig?.client) >= 0
})
return (
<>
<Popover
placement="bottomLeft"
trigger="click"
visible={visible}
content={
<div className={layoutStyles.integrationList}>
{
inData && inData.map((val) => (
<p onClick={() => checkIntegration(val, loginAction, props)}>{val.name}</p>
))
}
</div>
}
arrowPointAtCenter
overlayClassName={classNames(layoutStyles.stationsWrapper, layoutStyles.stationsTop2)}
onVisibleChange={visible => setVisible(visible)}
>
{inData.length > 1 ? (
<div className={layoutStyles.toggleSite}>
<img src={require('../assets/basic/site.png')} className={layoutStyles.site} />
<span className={layoutStyles.name}>{choiceOne?.name ?? ''}</span>
<ArrowIcon
className={layoutStyles.arrow}
style={{
transform: !visible ? `rotate(0deg)` : `rotate(180deg)`,
}}
/>
</div>
) : null}
</Popover>
</>
)
}
// import defaultProps from '../defaultProps';
const pickRoutes = memoized((routes, pathname, locale) => {
const matches = matchRoutes(routes, { pathname });
......@@ -255,6 +326,8 @@ const Layout = props => {
const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true);
const [initWebContent, setInitWebContent] = useState(false);
const [integrationData, setIntegrationData] = useState([]);
const [loginAction, setAction] = useState(() => new LoginAction(props));
// const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState('');
......@@ -318,6 +391,9 @@ const Layout = props => {
}, [cityData, props.global, props.global.userInfo, siteAction]);
useEffect(() => {
if (window?.globalConfig?.isIntegration > 1) {
GetIntegrationConfig();
}
window.share.event.on('updateSite', res => {
setCityData(res);
});
......@@ -346,6 +422,22 @@ const Layout = props => {
};
}, [props.global.isHaveMark, props.global.userInfo]);
const GetIntegrationConfig = () => {
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
})
.then(res => {
const { code, data } = res;
if (code == '0') {
setIntegrationData(data);
} else {
setIntegrationData([]);
}
})
}
const onMenuHeaderClick = event => {
//集成网站
if (window.globalConfig.isIntegration >= 1) {
......@@ -471,15 +563,19 @@ const Layout = props => {
popupOffset: [0, 15],
}}
headerSiteRender={() =>
renderSite({
data: cityData,
config: props.global,
loading: siteLoading,
setLoading: setSiteLoading,
action: siteAction,
actionRef,
setMenuLoading,
})
window?.globalConfig?.isIntegration > 1
?
renderIntegration(integrationData, loginAction, props)
:
renderSite({
data: cityData,
config: props.global,
loading: siteLoading,
setLoading: setSiteLoading,
action: siteAction,
actionRef,
setMenuLoading,
})
}
menuItemRender={(item, dom) => (
<a
......@@ -529,6 +625,7 @@ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']),
flatMenu: state.getIn(['global', 'flatMenu']),
instance: state.getIn(['global', 'instance']),
currentMenuIndex: state.getIn(['global', 'currentMenuIndex']),
});
const mapDispatchToProps = dispatch => ({
......
......@@ -27,6 +27,7 @@
padding-left: 16px;
padding-right: 16px;
cursor: pointer;
margin-top: 3px;
// transition: all .3s;
.site {
width: 16px;
......@@ -347,6 +348,20 @@
}
}
.integrationList{
display: flex;
}
.integrationList p{
margin: 0 10px;
cursor: pointer;
color: #40a9ff;
}
.integrationList p:hover{
color: #096dd9;
}
.stationsTop2{
padding-top: 0!important;
}
.stationsWrapper {
padding: 20px 10px 0 10px;
max-width: 520px;
......@@ -359,6 +374,14 @@
}
}
}
&.stationsTop {
top: 34px!important;
:global {
.ant-popover-arrow {
display: none;
}
}
}
.focusStations {
display: block;
// padding: 5px 0px;
......
......@@ -23,7 +23,7 @@ const BootPage = props => {
const [template, setTemplate] = useState('default');
const RenderComponent = useMemo(() => {
if (window.globalConfig.isIntegration >= 1) {
if (window?.globalConfig?.isIntegration >= 1) {
//集成登录
return BootPageTemplate.integration
......
......@@ -55,7 +55,6 @@ const Integration = props => {
config.client = cli
}
props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, item.type, cli);
}
......
......@@ -866,6 +866,11 @@ class Login {
const self = this;
if (client) {
self.globalConfig.client = client;
Cookies.set('client', client, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', client);
}
/* eslint-disable */
......@@ -905,7 +910,6 @@ class Login {
};
self.updateConfig && self.updateConfig(self.globalConfig);
}
console.log('globalConfig', self.globalConfig)
if (self.isSignIn || !!industry) {
// eslint-disable-next-line no-undef
getUserInfo({
......@@ -932,6 +936,7 @@ class Login {
path: '/',
});
self.globalConfig.Industry = industry;
self.globalConfig.bannerLogo = 'ceshi';
self.updateConfig && self.updateConfig(self.globalConfig);
const loginSite = {};
loginSite[token] = response.site;
......
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