Commit a0f1a1bf authored by 徐乐's avatar 徐乐

feat: 修改集成网站

parent 0c65e1d6
...@@ -23,6 +23,9 @@ import { waterMark } from '../utils/mark'; ...@@ -23,6 +23,9 @@ import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less'; import layoutStyles from './BasicLayout.less';
import SecurityLayout from './SecurityLayout'; import SecurityLayout from './SecurityLayout';
import Site from './Site'; import Site from './Site';
import { defaultApp } from '@/micro';
import { appService } from '@/api';
import LoginAction from '@/pages/user/login/login';
const { params } = helpers; const { params } = helpers;
...@@ -94,15 +97,16 @@ const OnlyFocusStations = props => { ...@@ -94,15 +97,16 @@ const OnlyFocusStations = props => {
</Spin> </Spin>
); );
}; };
const AllStations = props => { const AllStations = props => {
const data = props.data.stations; const data = props.data.stations;
const [targetOffset, setTargetOffset] = useState(undefined); const [targetOffset, setTargetOffset] = useState(undefined);
const cityPane = useRef(null); const cityPane = useRef(null);
const cityContent = useRef(null); const cityContent = useRef(null);
const [defaultTab, setDefaultTab] = useState('site'); const [defaultTab, setDefaultTab] = useState('site');
useEffect(() => { useEffect(() => {
setTargetOffset(cityPane.current.clientHeight / 2); setTargetOffset(cityPane.current.clientHeight / 2);
}, []); }, []);
const handleClick = (event, link) => { const handleClick = (event, link) => {
...@@ -223,6 +227,73 @@ const renderSite = ({ data, config, loading, setLoading, action, actionRef, setM ...@@ -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'; // import defaultProps from '../defaultProps';
const pickRoutes = memoized((routes, pathname, locale) => { const pickRoutes = memoized((routes, pathname, locale) => {
const matches = matchRoutes(routes, { pathname }); const matches = matchRoutes(routes, { pathname });
...@@ -255,6 +326,8 @@ const Layout = props => { ...@@ -255,6 +326,8 @@ const Layout = props => {
const [menuLoading, setMenuLoading] = useState(true); const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true); const [subLoading, setSubLoading] = useState(true);
const [initWebContent, setInitWebContent] = useState(false); const [initWebContent, setInitWebContent] = useState(false);
const [integrationData, setIntegrationData] = useState([]);
const [loginAction, setAction] = useState(() => new LoginAction(props));
// const [settings, setSetting] = useState({}); // const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null); // const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState(''); // const [matchPath, setMatchPath] = useState('');
...@@ -318,6 +391,9 @@ const Layout = props => { ...@@ -318,6 +391,9 @@ const Layout = props => {
}, [cityData, props.global, props.global.userInfo, siteAction]); }, [cityData, props.global, props.global.userInfo, siteAction]);
useEffect(() => { useEffect(() => {
if (window?.globalConfig?.isIntegration > 1) {
GetIntegrationConfig();
}
window.share.event.on('updateSite', res => { window.share.event.on('updateSite', res => {
setCityData(res); setCityData(res);
}); });
...@@ -346,6 +422,22 @@ const Layout = props => { ...@@ -346,6 +422,22 @@ const Layout = props => {
}; };
}, [props.global.isHaveMark, props.global.userInfo]); }, [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 => { const onMenuHeaderClick = event => {
//集成网站 //集成网站
if (window.globalConfig.isIntegration >= 1) { if (window.globalConfig.isIntegration >= 1) {
...@@ -471,15 +563,19 @@ const Layout = props => { ...@@ -471,15 +563,19 @@ const Layout = props => {
popupOffset: [0, 15], popupOffset: [0, 15],
}} }}
headerSiteRender={() => headerSiteRender={() =>
renderSite({ window?.globalConfig?.isIntegration > 1
data: cityData, ?
config: props.global, renderIntegration(integrationData, loginAction, props)
loading: siteLoading, :
setLoading: setSiteLoading, renderSite({
action: siteAction, data: cityData,
actionRef, config: props.global,
setMenuLoading, loading: siteLoading,
}) setLoading: setSiteLoading,
action: siteAction,
actionRef,
setMenuLoading,
})
} }
menuItemRender={(item, dom) => ( menuItemRender={(item, dom) => (
<a <a
...@@ -529,6 +625,7 @@ const mapStateToProps = state => ({ ...@@ -529,6 +625,7 @@ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']), menu: state.getIn(['global', 'menu']),
flatMenu: state.getIn(['global', 'flatMenu']), flatMenu: state.getIn(['global', 'flatMenu']),
instance: state.getIn(['global', 'instance']),
currentMenuIndex: state.getIn(['global', 'currentMenuIndex']), currentMenuIndex: state.getIn(['global', 'currentMenuIndex']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
padding-left: 16px; padding-left: 16px;
padding-right: 16px; padding-right: 16px;
cursor: pointer; cursor: pointer;
margin-top: 3px;
// transition: all .3s; // transition: all .3s;
.site { .site {
width: 16px; width: 16px;
...@@ -347,6 +348,20 @@ ...@@ -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 { .stationsWrapper {
padding: 20px 10px 0 10px; padding: 20px 10px 0 10px;
max-width: 520px; max-width: 520px;
...@@ -359,6 +374,14 @@ ...@@ -359,6 +374,14 @@
} }
} }
} }
&.stationsTop {
top: 34px!important;
:global {
.ant-popover-arrow {
display: none;
}
}
}
.focusStations { .focusStations {
display: block; display: block;
// padding: 5px 0px; // padding: 5px 0px;
......
...@@ -23,7 +23,7 @@ const BootPage = props => { ...@@ -23,7 +23,7 @@ const BootPage = props => {
const [template, setTemplate] = useState('default'); const [template, setTemplate] = useState('default');
const RenderComponent = useMemo(() => { const RenderComponent = useMemo(() => {
if (window.globalConfig.isIntegration >= 1) { if (window?.globalConfig?.isIntegration >= 1) {
//集成登录 //集成登录
return BootPageTemplate.integration return BootPageTemplate.integration
......
...@@ -55,7 +55,6 @@ const Integration = props => { ...@@ -55,7 +55,6 @@ const Integration = props => {
config.client = cli config.client = cli
} }
props.instance && props.instance.updateConfig(config); props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, item.type, cli); loginAction && loginAction.getUserInfoAndConfig('', true, item.type, cli);
} }
......
...@@ -866,6 +866,11 @@ class Login { ...@@ -866,6 +866,11 @@ class Login {
const self = this; const self = this;
if (client) { if (client) {
self.globalConfig.client = client; self.globalConfig.client = client;
Cookies.set('client', client, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', client);
} }
/* eslint-disable */ /* eslint-disable */
...@@ -905,7 +910,6 @@ class Login { ...@@ -905,7 +910,6 @@ class Login {
}; };
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
} }
console.log('globalConfig', self.globalConfig)
if (self.isSignIn || !!industry) { if (self.isSignIn || !!industry) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
getUserInfo({ getUserInfo({
...@@ -932,6 +936,7 @@ class Login { ...@@ -932,6 +936,7 @@ class Login {
path: '/', path: '/',
}); });
self.globalConfig.Industry = industry; self.globalConfig.Industry = industry;
self.globalConfig.bannerLogo = 'ceshi';
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
const loginSite = {}; const loginSite = {};
loginSite[token] = response.site; 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