Commit 4471faf0 authored by 邓晓峰's avatar 邓晓峰

fix: 菜单框架调整

parents f305ca62 0e7ab93d
...@@ -13,3 +13,4 @@ src/umi ...@@ -13,3 +13,4 @@ src/umi
.vscode .vscode
civbase civbase
package-lock.json package-lock.json
yarn.lock
\ No newline at end of file
...@@ -29,7 +29,7 @@ module.exports = { ...@@ -29,7 +29,7 @@ module.exports = {
baseNavigator: true, baseNavigator: true,
}, },
dynamicImport: { dynamicImport: {
loading: '@ant-design/pro-layout/es/PageLoading', loading: '@wisdom-utils/components/lib/AppLayout/components/PageLoading',
}, },
// theme: { // theme: {
// '@primary-color': '#ff9600', // '@primary-color': '#ff9600',
...@@ -40,13 +40,16 @@ module.exports = { ...@@ -40,13 +40,16 @@ module.exports = {
exclude: ['@wisdom-map/arcgismap', '@wisdom-map/amap', '@wisdom-map/basemap', 'swagger-ui-react', 'Cesium'], exclude: ['@wisdom-map/arcgismap', '@wisdom-map/amap', '@wisdom-map/basemap', 'swagger-ui-react', 'Cesium'],
}, },
proxy: proxy[NODE_ENV], proxy: proxy[NODE_ENV],
theme: {
'root-entry-name': 'variable',
},
// openAPI: { // openAPI: {
// requestLibPath: "import { request } from '@wisdom-utils/utils'", // requestLibPath: "import { request } from '@wisdom-utils/utils'",
// schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json', // schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
// mock: false, // mock: false,
// }, // },
postcssLoader: {}, postcssLoader: {},
styleLoader: {}, // styleLoader: {},
cssLoader: { cssLoader: {
modules: { modules: {
getLocalIdent: (context, _, localName) => { getLocalIdent: (context, _, localName) => {
...@@ -77,7 +80,7 @@ module.exports = { ...@@ -77,7 +80,7 @@ module.exports = {
modifyVars: { modifyVars: {
// hack: `true; @import "~@/global.less";`, // hack: `true; @import "~@/global.less";`,
'@ant-prefix': 'panda-console-base', '@ant-prefix': 'panda-console-base',
'@iconPrefixCls': 'panda-console-base-icon', // '@iconPrefixCls': 'panda-console-base-icon',
}, },
javascriptEnabled: true, javascriptEnabled: true,
}, },
......
...@@ -21,10 +21,10 @@ export default { ...@@ -21,10 +21,10 @@ export default {
// activeRule: '/civbase/dosing-web', // activeRule: '/civbase/dosing-web',
// }, // },
{ {
name: 'civ_water', name: 'civ_pandawork',
entry: `//${window.location.hostname}:8081/civ_water`, entry: `//${window.location.hostname}:3000/civ_pandawork`,
container: '#micro-container', container: '#micro-container',
activeRule: '/civbase/civ_water', activeRule: '/civbase/civ_pandawork',
}, },
// { // {
// name: 'civ_configuration', // name: 'civ_configuration',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin; // const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
// const proxyURL = 'https://work.panda-water.cn'; // const proxyURL = 'https://work.panda-water.cn';
// const proxyURL = 'http://192.168.12.3:8082'; // const proxyURL = 'http://192.168.12.3:8082';
const proxyURL = 'https://panda-water.cn' const proxyURL = 'http://192.168.10.156:8666/'
module.exports = { module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './', assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
......
...@@ -173,7 +173,7 @@ module.exports = options => { ...@@ -173,7 +173,7 @@ module.exports = options => {
reactRemovePropTypes: isProd, reactRemovePropTypes: isProd,
reactRequire: true, reactRequire: true,
lockCoreJS3: {}, lockCoreJS3: {},
import: (presetOpts.import || []).concat([{ libraryName: 'antd', libraryDirectory: 'es', style: true }]), // import: (presetOpts.import || []).concat([{ libraryName: 'antd', libraryDirectory: 'es', style: true }]),
}); });
const babelOpts = { const babelOpts = {
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
"author": "dengxiaofeng", "author": "dengxiaofeng",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"init": "npm install --registry=https://g.civnet.cn:4873", "init": "yarn install --registry=https://g.civnet.cn:4873",
"analyze:clean": "rimraf stats.json", "analyze:clean": "rimraf stats.json",
"preanalyze": "npm run analyze:clean", "preanalyze": "npm run analyze:clean",
"analyze": "cross-env ANALYZE=1 npm run build", "analyze": "cross-env ANALYZE=1 npm run build",
"npmcheckversion": "node ./internals/scripts/npmcheckversion.js", "npmcheckversion": "node ./internals/scripts/npmcheckversion.js",
"preinstall": "npm run npmcheckversion", "preinstall": "npm run npmcheckversion && npx only-allow yarn",
"build": "cross-env NODE_ENV=production node --max_old_space_size=4096 internals/webpack/build.js", "build": "cross-env NODE_ENV=production node --max_old_space_size=4096 internals/webpack/build.js",
"build:clean": "rimraf ./build", "build:clean": "rimraf ./build",
"openapi": "cross-env NODE_ENV=development node server/openapi/run.js", "openapi": "cross-env NODE_ENV=development node server/openapi/run.js",
...@@ -110,11 +110,11 @@ ...@@ -110,11 +110,11 @@
"@wisdom-map/arcgismap": "^1.1.0", "@wisdom-map/arcgismap": "^1.1.0",
"@wisdom-map/basemap": "^1.0.12-50", "@wisdom-map/basemap": "^1.0.12-50",
"@wisdom-map/util": "^1.0.27-0", "@wisdom-map/util": "^1.0.27-0",
"@wisdom-utils/components": "0.1.84", "@wisdom-utils/components": "0.1.214",
"@wisdom-utils/runtime": "0.0.15", "@wisdom-utils/runtime": "0.0.32",
"@wisdom-utils/utils": "0.1.124", "@wisdom-utils/utils": "0.1.254",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"antd": "^4.17.4", "antd": "^4.20.7",
"compression": "1.7.4", "compression": "1.7.4",
"connected-react-router": "6.4.0", "connected-react-router": "6.4.0",
"echarts": "^5.3.0", "echarts": "^5.3.0",
...@@ -138,9 +138,9 @@ ...@@ -138,9 +138,9 @@
"qiankun": "^2.4.6", "qiankun": "^2.4.6",
"qrcode.react": "^1.0.0", "qrcode.react": "^1.0.0",
"rc-cascader": "^2.3.2", "rc-cascader": "^2.3.2",
"react": "16.12.0", "react": "17.0.2",
"react-activation": "^0.9.9", "react-activation": "^0.9.9",
"react-dom": "16.12.0", "react-dom": "17.0.2",
"react-draggable": "^4.4.3", "react-draggable": "^4.4.3",
"react-helmet": "6.0.0-beta", "react-helmet": "6.0.0-beta",
"react-helmet-async": "^1.0.4", "react-helmet-async": "^1.0.4",
...@@ -148,8 +148,7 @@ ...@@ -148,8 +148,7 @@
"react-intl": "^3.12.1", "react-intl": "^3.12.1",
"react-redux": "7.0.2", "react-redux": "7.0.2",
"react-router-config": "^5.1.1", "react-router-config": "^5.1.1",
"react-router-dom": "5.3.0", "react-router-dom": "6.3.0",
"react-svg": "^14.0.11",
"react-use": "^15.3.4", "react-use": "^15.3.4",
"redux": "4.0.1", "redux": "4.0.1",
"redux-immutable": "^4.0.0", "redux-immutable": "^4.0.0",
...@@ -237,7 +236,7 @@ ...@@ -237,7 +236,7 @@
"jest-dom": "3.1.3", "jest-dom": "3.1.3",
"jest-styled-components": "6.3.1", "jest-styled-components": "6.3.1",
"jsonp": "^0.2.1", "jsonp": "^0.2.1",
"less": "3.12.0", "less": "4.1.2",
"less-loader": "5.0.0", "less-loader": "5.0.0",
"lint-staged": "8.1.5", "lint-staged": "8.1.5",
"memoizee": "^0.4.15", "memoizee": "^0.4.15",
......
...@@ -3,41 +3,16 @@ import './public-path'; ...@@ -3,41 +3,16 @@ import './public-path';
import '!file-loader?name=[name].[ext]!./images/favicon.ico'; import '!file-loader?name=[name].[ext]!./images/favicon.ico';
import './global.less'; import './global.less';
import 'animate.css/animate.css'; import 'animate.css/animate.css';
// import 'antd/dist/antd.less';
import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions
import '@wisdom-utils/utils/lib/helpers/format'; import '@wisdom-utils/utils/lib/helpers/format';
import 'sanitize.css/sanitize.css'; import 'sanitize.css/sanitize.css';
import { Storeage, params } from '@wisdom-utils/utils/lib/helpers'; // import { Storeage, params } from '@wisdom-utils/utils/lib/helpers';
import { initGlobalConfig } from './initConfig';
import './utils/event';
import { render } from './render'; import { render } from './render';
import './utils/event';
// import store from './stores';
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
const namespace = `__PANDA_STORE__${location.hostname}`; // const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace); // window.createStoreage = new Storeage(namespace);
;(() => {
const initLocale = () => { render();
localStorage.setItem('umi_locale', 'zh-CN'); })();
}; \ No newline at end of file
// 语音播报全局拦截
const setMessageVoice = () => {
const rawSpeak = window.speechSynthesis.speak;
window.speechSynthesis.speak = function(...args) {
if (
window.globalConfig &&
window.globalConfig.hasOwnProperty('messageVoice') &&
window.globalConfig.messageVoice === false
)
return;
rawSpeak.apply(window.speechSynthesis, args);
};
};
initGlobalConfig();
// 参数用户名密码登录,需要在配置获取完之后进行
if(!params.getParams('loginName') || !params.getParams('password')) {
render({ appContent: '', loading: true });
}
initLocale();
setMessageVoice();
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -234,6 +234,7 @@ class NoticeIconView extends Component { ...@@ -234,6 +234,7 @@ class NoticeIconView extends Component {
count={this.state.count} count={this.state.count}
confirmRead={this.notifier.confirmRead} confirmRead={this.notifier.confirmRead}
config={this.props.global} config={this.props.global}
bell={this.props.bell}
> >
<NoticeIcon.Tab <NoticeIcon.Tab
list={this.state.noticeData} list={this.state.noticeData}
......
import React, { useState, useRef } from 'react';
import { message, Popover } from 'antd';
import _ from 'lodash';
import { connect } from 'react-redux';
import Icon from '@ant-design/icons';
import classNames from 'classnames';
import { useHistory } from '@wisdom-utils/runtime';
import { useIntl, AvatarDropdown as Avatar } from '@wisdom-utils/components';
import HeaderSearch from '@wisdom-utils/components/lib/layout/components/HeaderSearch'
import { actionCreators } from '../../containers/App/store';
import search from '../../assets/basic/search.png';
import order from '../../assets/basic/message.png';
import notice from '../../assets/basic/notice.png';
import styles from './index.less';
import NoticeIconView from './NoticeIconView';
/* eslint-disable */
const favitorSvg = () => (<svg t="1631171489722" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16457" width="24" height="24"><path d="M512 87.806c-234.721 0-424.194 189.474-424.194 424.194s189.474 424.194 424.194 424.194 424.194-189.474 424.194-424.194-189.474-424.194-424.194-424.194zM783.484 442.715l-137.155 100.393c-7.069 5.655-9.899 14.141-7.069 22.624l52.317 161.194c5.655 18.382-15.553 33.935-31.108 22.624l-137.155-100.393c-7.069-5.655-16.967-5.655-24.037 0l-137.155 100.393c-15.553 11.312-36.763-4.242-31.108-22.624l53.731-162.608c2.829-8.484 0-16.967-7.069-22.624l-137.155-100.393c-15.553-11.312-7.069-35.349 11.312-35.349h169.678c8.484 0 16.967-5.655 18.382-14.141l52.317-161.194c5.655-18.382 32.522-18.382 38.177 0l52.317 161.194c2.829 8.484 9.899 14.141 18.382 14.141h169.678c21.21 0 28.278 25.452 12.725 36.763z" p-id="16458" fill="hsla(221, 100%, 95%, 0.7)"></path></svg>);
const themeSvg = () => (<svg t="1631362986014" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M552.75 563.239c44.4 26.348 99.1 26.348 143.5 0C740.65 536.89 768 488.197 768 435.5c0-81.462-64.247-147.5-143.5-147.5S481 354.038 481 435.5c0 52.697 27.35 101.39 71.75 127.739z" fill="hsla(221, 100%, 95%, 0.7)" p-id="2351"></path>
<path d="M471.264 952c-18.842 0-38.581-1.796-60.115-4.49l-5.384-0.899c-152.533-23.352-256.614-171.55-261.1-177.837-147.149-224.541-73.574-451.777 65.5-577.52C348.34 65.511 578.934 11.621 780.814 174.19c130.102 105.085 169.58 250.588 171.375 256.875v1.797c18.843 102.39 3.59 177.836-45.76 226.337-75.368 72.752-200.086 49.4-217.134 45.807-23.328-2.695-40.376 4.49-52.938 19.76-13.458 17.064-16.15 39.518-11.664 52.991 12.562 37.723 14.356 66.464 5.384 88.02C604.058 922.361 551.12 952 471.264 952z m-51.973-80.488l5.083 0.849c82.179 12.72 132.164-3.393 152.497-49.188 0-0.849 4.236-11.873-6.778-45.796-11.013-30.53-2.541-70.39 19.486-97.528 22.875-28.834 56.763-41.556 96.581-37.315l2.542 0.848c0.847 0 105.9 22.898 160.122-29.683 33.04-32.226 43.207-88.199 28.805-166.221-3.39-11.025-39.819-130.603-144.872-214.562-166.053-135.69-356.674-90.743-471.894 13.57-105.9 96.68-183.843 280.71-53.374 480.007 0.848 0 89.804 127.21 211.802 145.02z" fill="hsla(221, 100%, 95%, 0.7)" p-id="2352"></path>
<path d="M203 529c0-29.823 24.177-54 54-54s54 24.177 54 54-24.177 54-54 54-54-24.177-54-54z m90-115.235A54 54 0 0 1 266 367c0-29.823 24.177-54 54-54s54 24.177 54 54a54 54 0 0 1-81 46.765zM427 278c0-29.823 24.177-54 54-54s54 24.177 54 54-24.177 54-54 54-54-24.177-54-54z m180 44c0-29.823 24.177-54 54-54s54 24.177 54 54-24.177 54-54 54-54-24.177-54-54z m90 144c0-29.823 24.177-54 54-54s54 24.177 54 54-24.177 54-54 54-54-24.177-54-54z" fill="hsla(221, 100%, 95%, 0.7)"></path></svg>)
const FavitorIcon = props => <Icon component={favitorSvg} {...props}/>
const MESSAGE_BOX_URL =
'product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=1';
export const getConfig = (widgets, url, key) => {
let widgetconfig = {};
if (widgets) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < widgets.length; i++) {
const widget = widgets[i];
if (widget && widget[key])
widget[key] = widget[key].replace(/\\/g, '/').trim();
// eslint-disable-next-line eqeqeq
if (widget[key] && url.toLowerCase() === widget[key].toLowerCase()) {
widgetconfig = widget;
break;
} else {
const children = widget.widgets ? widget.widgets : widget.routes;
if (children) {
widgetconfig = getConfig(children, url, key);
if (widgetconfig) {
break;
}
}
}
}
}
return widgetconfig;
};
const GlobalHeaderRight = props => {
const [options, setOptions] = useState([]);
const homeRef = useRef(null);
const favitorRef = useRef(null);
const history = useHistory();
const { theme, layout } = props;
let className = styles.right;
if (theme === 'dark' && layout === 'top') {
className = `${styles.right} ${styles.dark}`;
}
const intl = useIntl();
const goHome = event => {
event.stopPropagation();
let url = _.isString(props.global.get('homepage'))
? props.global.get('homepage')
: props.global.get('homepage.url');
if(!props.global.get('home')) {
url = `civweb4/${url.replace(/^\//, '').replace(/^civweb4\//, '')}`
}
window.share.event.emit('goHome', `/${url}`);
// url ? (
// window.share.event.emit('listenerMointer', {
// label: '首页',
// url: url.replace(/^civweb4\//, ''),
// })
// ) : null;
};
const handleOrder = event => {
event.stopPropagation();
const widgetConfig = getConfig(
props.global.get('widgets').concat(props.global.get('uiwidgets')),
MESSAGE_BOX_URL,
'url',
);
if (Object.keys(widgetConfig).length > 0) {
props.history.push(`/civweb4/${MESSAGE_BOX_URL}`);
setCurrentIndex(2);
} else {
message.warning('对不起,您没有菜单权限!');
}
};
const handleFeedback = event => {
event.stopPropagation();
window.open(`https://mis.panda-water.cn/feedback/?site_code="${props.global.get('userInfo.site')}`);
}
const handlerFavitor = event => {
// setCurrentIndex(1);
history.push('/commonmenu');
window.share && window.share.event && window.share.event.emit('event:favitor', {
name: "常用",
path: '/commonmenu',
icon: <FavitorIcon/>
});
}
const handlerTheme = () => {
window.share.event.emit('event:theme');
}
const handleSelect = (value, data) => {
window.share.event.emit('addTips', options, data);
};
const handleSearch = value => {
// eslint-disable-next-line no-undef
const search = new AMap.Autocomplete();
const areaName =
// eslint-disable-next-line no-undef
createStoreage.get('globalConfig').mapsettings.areasettings &&
// eslint-disable-next-line no-undef
createStoreage.get('globalConfig').mapsettings.areasettings.areaName;
const area = (areaName || '') + value;
setOptions([]);
// eslint-disable-next-line no-unused-expressions
value
? search.search(area, (status, res) => {
if (res && res.tips) {
const result = res.tips.map(item => {
item.value = item.name;
item.label = (
<>
<span>{item.name}</span>
<span style={{ color: '#c1c1c1' }}>
{item.district + item.address}
</span>
</>
);
return item;
});
setOptions(result);
}
})
: setOptions([]);
};
const renderHeaderSearch = () => {
return (
<HeaderSearch
className={`${styles.action} ${styles.search} ${styles.extendsearch}`}
placeholder={intl.formatMessage({id:'component.search.menu.placeholder'})}
offset="46px"
defaultValue=""
mode="tiled"
options={options}
{...props}
onSelect={handleSelect}
onChange={handleSearch}
onSearch={handleSearch}
/>
)
}
return (
<div className={className} style={{marginLeft: 'inherit'}}>
{/* */}
<div className={styles.opteration}>
<Popover placement="bottomRight" content={renderHeaderSearch()} trigger="click" overlayClassName={styles.searchPopupWrapper}>
<Icon component={() => <img src={search} alt="icon" className={styles.active}/>}/>
</Popover>
</div>
<div className={styles.opteration}>
<Icon component={() => <img src={order} alt="icon"/>} onClick={handleFeedback}/>
</div>
<NoticeIconView bell={ <Icon component={() => <img src={notice} alt="icon"/>}/>}/>
<Avatar menu config={props.global} updateCurrentIndex={props.updateCurrentIndex} updateConfig={props.updateConfig} logout={props.logout}/>
</div>
);
};
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
flatMenu: state.getIn(['global', 'flatMenu']),
menu: state.getIn(['global', 'menu']),
recentKeywords: state.getIn(['global', 'recentKeywords']),
recentVisited: state.getIn(['global', 'recentVisited']),
recentProducts: state.getIn(['global', 'recentProducts']),
});
const mapDispatchToProps = dispatch => ({
updateRecentKeywords(keyword) {
dispatch(actionCreators.updateRecentKeywords(keyword));
},
updateRecentVisited(history) {
dispatch(actionCreators.updateRecentVisited(history));
},
updateRecentProduct(history) {
dispatch(actionCreators.updateRecentProduct(history));
},
clearRecentProduct() {
dispatch(actionCreators.clearRecentProduct());
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index))
},
updateConfig(config) {
dispatch(actionCreators.getConfig(config))
},
updateComplexConfig(config) {
dispatch(actionCreators.updateComplexConfig(config))
},
logout() {
dispatch(actionCreators.logout())
}
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(GlobalHeaderRight);
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@pro-header-hover-bg: rgba(0, 0, 0, 0.025); @pro-header-hover-bg: rgba(0, 0, 0, 0.025);
.menu { .menu {
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
height: 46px; height: 46px;
margin-left: auto; margin-left: auto;
overflow: hidden; overflow: hidden;
align-items: center;
.action { .action {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -46,6 +47,26 @@ ...@@ -46,6 +47,26 @@
background: #fff; background: #fff;
} }
} }
:global(.anticon) {
width: 32px;
height: 32px;
display: flex;
align-items: center;
text-align: center;
justify-content: center;
// margin-right: 21px;
cursor: pointer;
&.active, &:hover {
background: rgba(0, 0, 0, 0.15);
border-radius: 8px;
transition: all cubic-bezier(0.075, 0.82, 0.165, 1);
}
img {
width: 18px;
height: 18px;
display: block;
}
}
//.account { //.account {
// .avatar { // .avatar {
// margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0; // margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0;
...@@ -62,6 +83,7 @@ ...@@ -62,6 +83,7 @@
// overflow: hidden; // overflow: hidden;
// } // }
//} //}
} }
.dark { .dark {
...@@ -634,3 +656,18 @@ ...@@ -634,3 +656,18 @@
} }
} }
} }
.opteration {
display: flex;
align-items: center;
height: 100%;
padding: 0 9px;
cursor: pointer;
transition: all 0.3s;
}
.searchPopupWrapper {
:global(.@{ant-prefix}-popover-inner-content) {
padding: 12px 16px 0 16px!important;
}
}
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
.view { .view {
position: absolute; position: absolute;
......
...@@ -32,6 +32,7 @@ function App(props) { ...@@ -32,6 +32,7 @@ function App(props) {
(props.global && props.global.theme) || 'dark', (props.global && props.global.theme) || 'dark',
).routes, ).routes,
)} )}
</Switch> </Switch>
</Router> </Router>
</> </>
...@@ -40,7 +41,7 @@ function App(props) { ...@@ -40,7 +41,7 @@ function App(props) {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']), menu: state.getIn(['global', 'menu'])
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -4,6 +4,8 @@ import { AppConfig, store, event, Storage, helpers } from '@wisdom-utils/utils'; ...@@ -4,6 +4,8 @@ import { AppConfig, store, event, Storage, helpers } from '@wisdom-utils/utils';
import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers'; import { Storeage as Store } from '@wisdom-utils/utils/lib/helpers';
import pkg from '../../../../package.json'; import pkg from '../../../../package.json';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
import _ from 'lodash';
import memoized from 'nano-memoize';
// import { transformWidgets } from '../../../utils/routes'; // import { transformWidgets } from '../../../utils/routes';
// eslint-disable-next-line import/no-duplicates // eslint-disable-next-line import/no-duplicates
import { import {
...@@ -101,11 +103,32 @@ const appReducer = (state = initialState, action) => { ...@@ -101,11 +103,32 @@ const appReducer = (state = initialState, action) => {
window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => { window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => {
modulePkg[item.PackageName] = item; modulePkg[item.PackageName] = item;
}); });
config.widgets = transformWidgets(config.widgets); config.widgets =transformWidgets(config.widgets);
// const pickMenus = memoized(() => )
const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg);
let flatMenu = []; let flatMenu = [];
if (generMenu) { if (generMenu) {
flatMenu = generFlatRoutes(generMenu || [], null, null, modulePkg); 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
} else {
flatMenu = flat.flatMenu
}
const index = flatMenu.findIndex(item => item.name === '首页');
if(index === -1) {
flatMenu.push({
path: `/${homepage}`,
href: `/${homepage}`,
key: 'home',
name: '首页'
})
}
} }
const home = flatMenu.find(item => { const home = flatMenu.find(item => {
...@@ -117,6 +140,8 @@ const appReducer = (state = initialState, action) => { ...@@ -117,6 +140,8 @@ 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;
...@@ -130,7 +155,7 @@ const appReducer = (state = initialState, action) => { ...@@ -130,7 +155,7 @@ const appReducer = (state = initialState, action) => {
Cookies.set('client', Cookies.get('client') || window.globalConfig.client); Cookies.set('client', Cookies.get('client') || window.globalConfig.client);
window.globalConfig = config; window.globalConfig = config;
return state.merge({ return state.merge({
globalConfig: config, globalConfig: config || {},
menu: generMenu || [], menu: generMenu || [],
flatMenu, flatMenu,
currentMenu: generMenu && generMenu[state.currentMenuIndex], currentMenu: generMenu && generMenu[state.currentMenuIndex],
......
@import '~antd/es/style/themes/default.less'; @root-entry-name: 'default';
@import (reference) '~antd/es/style/themes/index.less';
html, html,
body, body,
...@@ -202,11 +203,11 @@ select:-webkit-autofill { ...@@ -202,11 +203,11 @@ select:-webkit-autofill {
} }
} }
} }
.@{ant-prefix}-pro-global-header-layout-side { // .@{ant-prefix}-pro-global-header-layout-side {
> div { // > div {
display: flex; // display: flex;
} // }
} // }
.@{ant-prefix}-pro-basicLayout-side { .@{ant-prefix}-pro-basicLayout-side {
.@{ant-prefix}-pro-sider-extra { .@{ant-prefix}-pro-sider-extra {
padding: 0 14px !important; padding: 0 14px !important;
......
import Cookies from 'js-cookie';
import { params, Storeage } from '@wisdom-utils/utils/lib/helpers';
import { appService } from './api';
import { initMicroApps } from './micro';
import { actionCreators } from './containers/App/store';
import { getToken } from './utils/utils';
import loader, { render } from './render';
import store from './stores';
import Login from './pages/user/login/login';
// eslint-disable-next-line no-restricted-globals
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
export const initGlobalConfig = () => {
/* eslint-disable */
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
window.globalConfig = {};
window.__INITIAL_STATE__ = {};
let config = window.globalConfig || {};
// createStoreage.get('globalConfig') || {};
store.dispatch(actionCreators.updateComplexConfig({}));
if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
config = {};
}
if (!params.getParams('client', window.location.search) && config) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
}
// eslint-disable-next-line no-undef
if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace);
}
if (!getToken()) {
localStorage.removeItem('loginSite');
}
/* eslint-disable */
// if (window.globalConfig.token !== null && Object.keys(window.globalConfig).length > 0) {
// store.dispatch(actionCreators.getConfig(window.globalConfig));
// // render({ appContent: '', loading: true });
// initMicroApps(loader, store);
// if (config.isNewYear) {
// updateTheme('#ff9600');
// }
// } else {
// // eslint-disable-next-line react-hooks/rules-of-hooks
// }
let client = params.getParams('client') || Cookies.get('client');
client = client && client !== 'undefined' ? client : 'city';
const queryConfig = (gateWayConfig = {}) => {
appService
.queryConfig({
client: client || 'city',
ignoreSite: true,
})
.then(res => {
if (res) {
const { data } = res;
if (!data.client) {
data.client = client;
}
// Cookies.set('client', data.client);
store.dispatch(
actionCreators.getConfig(
Object.assign(
{},
data,
{
token: '',
access_token: '',
userInfo: null,
},
gateWayConfig,
),
),
);
// Cookies.set('client', params.getParams('client'))
// if (data.loginTemplate === '新春 - 智联.html') {
// updateTheme('#ff9600');
// }
const products = (data.products || []).map(item => {
if (item.PackageName === 'civweb4') {
return 'web4_console'
}
return `${item.PackageName}-main`;
});
if(products && products.length > 0) {
Object.keys(products).forEach(item => {
window[products[item]] && window[products[item]] && window[products[item]].unmount && window[products[item]].unmount({ store: store });
});
initMicroApps();
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data,
{
token: getToken(),
},
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) &&
initMicroApps(loader, store);
})();
},
true,
);
}
}
return res;
})
.then(res => {
render({ appContent: '', loading: true });
})
.catch(error => {
store.dispatch(actionCreators.getConfigError(error));
});
}
appService
.getWateWayConfig({
ignoreSite: true,
})
.then(res => {
/* eslint-disable */
const hasGateWay = !res || !res.data ? false : _.isString(res.data) ? JSON.parse(res.data) : typeof res.data === 'boolean' ? res.data : false;
return {
hasGateWay,
apiGatewayDomain: `${window.location.origin}${hasGateWay ? '/PandaCore/GateWay' : ''}`,
};
})
.then(gateWayConfig => {
queryConfig(gateWayConfig);
})
.catch(err => {
queryConfig();
});
};
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@pro-header-hover-bg: rgba(0, 0, 0, 0.025); @pro-header-hover-bg: rgba(0, 0, 0, 0.025);
@panda-prefix-cls: ~'@{ant-prefix}'; @panda-prefix-cls: ~'@{ant-prefix}';
.@{panda-prefix-cls}-action { .@{panda-prefix-cls}-action {
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@panda-prefix-cls: ~'@{ant-prefix}-layout-slider'; @panda-prefix-cls: ~'@{ant-prefix}-layout-slider';
@primary-color: #1685ff; @primary-color: #1685ff;
@primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%) @primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@dark-menu-catatories-color: rgba(255, 255, 255, 0.65); @dark-menu-catatories-color: rgba(255, 255, 255, 0.65);
.mainPane { .mainPane {
position: absolute; position: absolute;
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@dark-menu-catatories-color: rgba(255, 255, 255, 0.65); @dark-menu-catatories-color: rgba(255, 255, 255, 0.65);
@primary-color: #1685ff; @primary-color: #1685ff;
@panda-prefix-cls: ~'@{ant-prefix}-panel-min'; @panda-prefix-cls: ~'@{ant-prefix}-panel-min';
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@primary-color: #1685ff; @primary-color: #1685ff;
@primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%) @primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%) @primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%)
......
@import '~antd/es/style/themes/default.less'; @import '~~antd/es/style/variable.less';
@primary-color: #1685ff; @primary-color: #1685ff;
@primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%) @primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%) @primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%)
......
@import '~antd/es/style/themes/default.less'; @import '~~antd/es/style/variable.less';
@primary-color: #1685FF; @primary-color: #1685FF;
@primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%) @primary-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%) @primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%)
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
color: #FFFFFF; color: #FFFFFF;
font-size: 14px; font-size: 14px;
margin-left: 9px; margin-left: 9px;
word-spacing: normal;
text-overflow: ellipsis;
overflow: hidden;
word-break: keep-all;
} }
.arrow { .arrow {
margin-left: 9px; margin-left: 9px;
...@@ -221,16 +225,16 @@ ...@@ -221,16 +225,16 @@
padding: 0 14px; padding: 0 14px;
// margin-bottom: 0px; // margin-bottom: 0px;
} }
:global(.@{ant-prefix}-layout-sider-collapsed .@{ant-prefix}-menu-item.@{ant-prefix}-menu-item-only-child) { // :global(.@{ant-prefix}-layout-sider-collapsed .@{ant-prefix}-menu-item.@{ant-prefix}-menu-item-only-child) {
padding-left: 0px!important; // padding-left: 0px!important;
} // }
:global(.@{ant-prefix}-layout-sider-collapsed // :global(.@{ant-prefix}-layout-sider-collapsed
.@{ant-prefix}-menu-inline-collapsed // .@{ant-prefix}-menu-inline-collapsed
.@{ant-prefix}-menu-item-only-child.@{ant-prefix}-menu-item-selected) { // .@{ant-prefix}-menu-item-only-child.@{ant-prefix}-menu-item-selected) {
border-left: 2px solid @primary-color; // border-left: 2px solid @primary-color;
background-color: @menu-dark-inline-submenu-bg!important; // background-color: @menu-dark-inline-submenu-bg!important;
transition: cubic-bezier(0.175, 0.885, 0.32, 1.275); // transition: cubic-bezier(0.175, 0.885, 0.32, 1.275);
} // }
:global(.@{ant-prefix}-menu-submenu-popup :global(.@{ant-prefix}-menu-submenu-popup
li.@{ant-prefix}-menu-item-only-child li.@{ant-prefix}-menu-item-only-child
.panda-pro-layouts-user-layout-minixName) { .panda-pro-layouts-user-layout-minixName) {
...@@ -372,7 +376,7 @@ ...@@ -372,7 +376,7 @@
li { li {
// margin-top: 10px; // margin-top: 10px;
a { a {
color: #3f70b5; color: @primary-color;
&.city_select { &.city_select {
cursor: pointer; cursor: pointer;
} }
...@@ -380,7 +384,7 @@ ...@@ -380,7 +384,7 @@
position: relative; position: relative;
} }
&:hover { &:hover {
color: #23527c !important; color: @primary-7 !important;
transition: color 0.3s; transition: color 0.3s;
} }
div[title] { div[title] {
...@@ -476,7 +480,7 @@ ...@@ -476,7 +480,7 @@
display: flex; display: flex;
margin-top: 2px; margin-top: 2px;
.proviceName { .proviceName {
color: #3d6dcc; color: @primary-color;
font-weight: bolder; font-weight: bolder;
min-width: 36px; min-width: 36px;
} }
...@@ -506,6 +510,9 @@ ...@@ -506,6 +510,9 @@
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
:global(.@{ant-prefix}-popover-arrow) {
display: none;
}
} }
:global(.@{ant-prefix}-pro-basicLayout .@{ant-prefix}-pro-sider-logo h1) { :global(.@{ant-prefix}-pro-basicLayout .@{ant-prefix}-pro-sider-logo h1) {
display: none; display: none;
......
import React, { useState, useEffect, useRef, Suspense } from 'react';
import { useHistory, useLocation } from '@wisdom-utils/runtime';
import { matchRoutes } from 'react-router-dom'
import BasicLayout from '@wisdom-utils/components/lib/layout/BasicLayout';
import memoized from 'nano-memoize';
import SecurityLayout from './SecurityLayout';
import { connect } from 'react-redux';
import _ from 'lodash'
import RightContent from '@/components/GlobalHeader/SimpleRiightContent';
// import SettingDrawer from '@wisdom-utils/components/lib/layout/components/SettingDrawer';
import { actionCreators } from '@/containers/App/store';
import Icon, { LoadingOutlined } from '@ant-design/icons';
import { Anchor, Popover, Radio, Spin } from 'antd';
import classNames from 'classnames';
import Cookies from 'js-cookie';
import { helpers, store } from '@wisdom-utils/utils';
import Site from './Site';
import layoutStyles from './BasicLayout.less';
import { getToken } from '../utils/utils';
const { params } = helpers;
const { getParamsV1 } = params;
const ArcgisMap = React.lazy(() => import('../pages/map/arcgis'));
const AMap = React.lazy(() => import('../pages/map/amap'));
const CesiumMap = React.lazy(() => import('../pages/map/cesiumMap'));
const waitTime = (time= 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const antIcon = <LoadingOutlined style={{ fontSize: 12 }} spin />;
const arrowSvg = ({ fillColor = '#fff' }) => (
<svg
t="1543324489942"
className="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
>
<path
d="M511.700683 639.423111 191.917496 319.596945 319.830771 319.596945 511.700683 511.715521 703.570595 319.596945 831.48387 319.596945Z"
p-id="8626"
// fill={fillColor}
/>
</svg>
);
const ArrowIcon = props => <Icon component={arrowSvg} {...props} />;
const optionsWith = [{ label: '按站点', value: 'site' }, { label: '按城市', value: 'city' }];
const HOT = ['HOT', '县', '市', 'New'];
const StationsItem = (item, action, onChangeVisible, actionRef, setMenuLoading) => {
const changeGroup = (event, data) => {
action.changeGroup && action.changeGroup(event, data, onChangeVisible, actionRef);
setMenuLoading && setMenuLoading(true);
};
return (
<li key={item.groupID} style={{ marginRight: `${item.style.marginRight}px` }}>
<a
className={classNames(layoutStyles.city_select, layoutStyles.showTip)}
title={item.city}
index={item.promoteIndex}
style={{ fontSize: '13px' }}
onClick={event => changeGroup(event, item)}
>
{item.groupName}
{item.promoteTip && HOT.includes(item.promoteTip) && <div title={`${item.promoteTip}`}>{item.promoteTip}</div>}
</a>
</li>
);
};
const Stations = 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) => {
event.preventDefault();
};
const handleTabChange = event => {
setDefaultTab(event.target.value);
};
return (
<>
<div className={layoutStyles.focusStations}>
<ul>{Array.isArray(data) ? data.map(item => StationsItem(item, props.action, props.setVisible, props.actionRef, props.setMenuLoading)) : null}</ul>
</div>
<Radio.Group
options={optionsWith}
optionType="button"
buttonStyle="solid"
size="small"
value={defaultTab}
onChange={handleTabChange}
style={{ marginTop: '6px' }}
/>
<div style={{ maxWidth: '520px', position: 'relative' }}>
{defaultTab === 'site' ? (
<div className={classNames(layoutStyles.city_pane, layoutStyles.station_container)} ref={cityPane}>
<Anchor
affix={false}
onClick={handleClick}
targetOffset={targetOffset}
getContainer={() => cityContent.current}
>
<ul className={layoutStyles.py}>
{props.data && props.data.siteCityList && props.data.siteCityList.letters}
</ul>
<div className={layoutStyles.cityContent} style={{ height: '335px' }} ref={cityContent}>
{props.data && props.data.siteCityList && props.data.siteCityList.content}
</div>
</Anchor>
</div>
) : (
<div className="city_pane city_container">{props.data.citySelector}</div>
)}
<Spin spinning={props.loading} tip="加载中" />
</div>
</>
);
};
const renderSite = ({ data, config, loading, setLoading, action, actionRef, setMenuLoading }) => {
const [visible, setVisible] = useState(false);
let loaded = !!((data && !data.stations) || (Array.isArray(data.weathers) && data.weathers.length === 0));
if (config && config.userInfo && config.userInfo.site === '') {
loaded = false;
}
return (
<>
<Spin
indicator={antIcon}
spinning={loaded}
size="small"
style={{ marginLeft: '10px' }}
tip=""
wrapperClassName={layoutStyles.spinLoadding}
>
<>
<Popover
placement="bottomLeft"
trigger="click"
visible={visible}
content={
<Stations data={data} loading={loading} setLoading={setLoading} setVisible={setVisible} action={action} actionRef={actionRef} setMenuLoading={setMenuLoading} />
}
arrowPointAtCenter
overlayClassName={classNames(layoutStyles.stationsWrapper, layoutStyles.stationsTop)}
onVisibleChange={visible => setVisible(visible)}
>
{Array.isArray(data.stations) ? (
<div className={layoutStyles.toggleSite}>
<img src={require('../assets/basic/site.png')} className={layoutStyles.site} />
<span className={layoutStyles.name}>{data.currentStationName}</span>
<ArrowIcon
className={layoutStyles.arrow}
// fillColor="#fff"
style={{
transform: !visible ? `rotate(0deg)` : `rotate(180deg)`,
}}
/>
</div>
) : null}
</Popover>
</>
</Spin>
</>
);
};
// import defaultProps from '../defaultProps';
const pickRoutes = memoized((routes, pathname, locale) => {
const matches = matchRoutes(routes, { pathname });
const routeConfig = matches ? matches[matches.length - 1].route : null;
return {
locale, // just for cache
routeConfig,
// matchPath: matches ? matches.map(match => _.replace(match.route.path,'/*','')).join('/') : null // 解决下微端/*路径的问题
matchPath: routeConfig ? _.replace(routeConfig.key, "/*", "") : '',
};
});
const transformFloatMenu = (routes, homepage) => {
const route = routes.find(route => route.path === `/${homepage}`);
console.log("route", route);
return routes.concat(route);
}
const Layout = (props) => {
const [cityData, setCityData] = useState({});
const [siteLoading, setSiteLoading] = useState(false);
const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading));
const [menuLoading, setMenuLoading] = useState(true);
// const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState('');
const actionRef = useRef();
const history = useHistory();
const location = useLocation();
const { routeConfig = {}, matchPath } = pickRoutes(props.flatMenu, location.pathname);
// useEffect(() => {
// setRouteConfig(routeConfig);
// setMatchPath(match)
// }, [location.pathname])
useEffect(() => {
siteAction.setGlobalConfig(props.global);
const tk = Cookies.get('token') || props.global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0);
if (!isLogin) {
let client = props.global && props.global.hasOwnProperty('client') ? props.global.get('client') : null;
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
let generateType = props.global && props.global.hasOwnProperty('get') ? props.global.get('generateType') : null;
generateType =
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}`
: '';
history.replace(`/user/login?client=${client}${generateType}`);
props.logout();
}
}, [history, props, props.global, siteAction]);
useEffect(() => {
if (
props.global &&
props.global.userInfo &&
props.global.userInfo.token !== null &&
props.global.userInfo.loginName &&
Object.keys(cityData).length === 0
) {
siteAction.getCityStationsForUser().then(res => {
setCityData(res);
});
}
}, [cityData, props.global, props.global.userInfo, siteAction]);
useEffect(() => {
window.share.event.on('updateSite', res => {
setCityData(res);
});
return () => {
window.share.event.removeAllListeners('updateSite');
};
}, []);
const onMenuHeaderClick = event => {
props.global.get('userInfo.site') ? history.push(`/industry`) : void 0;
};
// useEffect(async () => {
// setMenuLoading(false);
// }, [props.menu]);
const onTopMenuHeaderClick = index => {
props.updateCurrentIndex(index);
window.share && window.share.event.emit('trigger:updateMenuIndex', index);
store.set('updateMenuIndex', index);
};
console.log("routeConfig", routeConfig)
return (
<SecurityLayout {...props}>
<BasicLayout
title="智慧水务GCK平台"
route={props.route}
location={location}
navTheme="dark"
mode="MDI"
fixedHeader
headerHeight={52}
routeConfig={routeConfig}
matchPath={matchPath}
actionRef={actionRef}
menu={{
loading: menuLoading
// onLoadingChange: (loading) => setMenuLoading(loading)
}}
topMenuActiveKey={props.currentMenuIndex}
rightContentRender={() => <RightContent/>}
onPageChange={() => {
// if(!props.global.token) {
// history.push('/user/login')
// }
}}
onMenuHeaderClick={onMenuHeaderClick}
onTopMenuHeaderClick={onTopMenuHeaderClick}
menuProps = {{
popupClassName: 'testpop',
popupOffset: [0, 15]
}}
headerSiteRender={() =>
renderSite({
data: cityData,
config: props.global,
loading: siteLoading,
setLoading: setSiteLoading,
action: siteAction,
actionRef,
setMenuLoading,
})
}
menuItemRender={(item, dom) => (
<a
onClick={(event) => {
event.preventDefault()
window.history.pushState(null, '', '/civbase' + item.path);
}}
>
{dom}
</a>
)}
>
{/* <SettingDrawer prefixCls='panda-console-base' settings={settings} disableUrlParams enableDarkTheme getContainer={() => document.getElementById('micro-container')} onSettingChange={(changeSetting) => {
setSetting(changeSetting);
}}/> */}
<div id="micro-container" className="subapp-container">
{props.children}
</div>
</BasicLayout>
</SecurityLayout>
);
};
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']),
flatMenu: state.getIn(['global', 'flatMenu']),
currentMenuIndex: state.getIn(['global', 'currentMenuIndex']),
});
const mapDispatchToProps = dispatch => ({
updageSetting(setting) {
dispatch(actionCreators.updageSetting(setting));
},
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
logout() {
dispatch(actionCreators.logout());
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Layout);
\ No newline at end of file
@import '~~antd/es/style/variable.less';
@hn-greenColor: #00b278; @hn-greenColor: #00b278;
:global{ :global{
.@{ant-prefix}-drawer-left.@{ant-prefix}-drawer-open{ .@{ant-prefix}-drawer-left.@{ant-prefix}-drawer-open{
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Redirect, history } from '@wisdom-utils/runtime'; import { Redirect, history } from '@wisdom-utils/runtime';
import { PageLoading } from '@ant-design/pro-layout'; import PageLoading from '@wisdom-utils/components/lib/AppLayout/components/PageLoading';
import _ from 'lodash'; import _ from 'lodash';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import { store, helpers } from '@wisdom-utils/utils'; import { store, helpers } from '@wisdom-utils/utils';
...@@ -48,6 +48,7 @@ class SecurityLayout extends React.Component { ...@@ -48,6 +48,7 @@ class SecurityLayout extends React.Component {
const { children, global, loading } = this.props; const { children, global, loading } = this.props;
const tk = Cookies.get('token') || global.token; const tk = Cookies.get('token') || global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0); const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0);
if (!isLogin && window.location.pathname !== '/civbase/user/login' || (global.hasOwnProperty('size') && global.size === 0)) { if (!isLogin && window.location.pathname !== '/civbase/user/login' || (global.hasOwnProperty('size') && global.size === 0)) {
const { query = {}, search, pathname } = history.location; const { query = {}, search, pathname } = history.location;
const { redirect } = query; const { redirect } = query;
...@@ -61,7 +62,7 @@ class SecurityLayout extends React.Component { ...@@ -61,7 +62,7 @@ class SecurityLayout extends React.Component {
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : ''; generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
return ( return (
<Redirect <Redirect
to={`/user/login?client=${client}${generateType}`} to={{pathname: `/user/login?client=${client}${generateType}`, state:{reload: true}}}
/> />
); );
}; };
......
...@@ -319,7 +319,7 @@ class Site { ...@@ -319,7 +319,7 @@ class Site {
return arr; return arr;
} }
writeCookie(token, site, onChangeVisible) { writeCookie(token, site, onChangeVisible, actionRef) {
const date = new Date(); const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000); date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString(); // date = date.toGMTString();
...@@ -349,6 +349,7 @@ class Site { ...@@ -349,6 +349,7 @@ class Site {
// debugger // debugger
// initMicroApps(); // initMicroApps();
// 切换站点后,重置掉三级菜单 // 切换站点后,重置掉三级菜单
const homeType = self.globalConfig.homeType || 'civweb4'; const homeType = self.globalConfig.homeType || 'civweb4';
const homePath = self.globalConfig.homepage ? self.globalConfig.homepage.startsWith(homeType) ? self.globalConfig.homepage: `/${homeType}/${self.globalConfig.homepage}`: `/${homeType}`; const homePath = self.globalConfig.homepage ? self.globalConfig.homepage.startsWith(homeType) ? self.globalConfig.homepage: `/${homeType}/${self.globalConfig.homepage}`: `/${homeType}`;
window.share && window.share.event && window.share.event.emit('event:favitor', { window.share && window.share.event && window.share.event.emit('event:favitor', {
...@@ -357,6 +358,8 @@ class Site { ...@@ -357,6 +358,8 @@ class Site {
icon: null, icon: null,
}); });
actionRef && actionRef.current && actionRef.current.reload()
// 重新加载订阅消息铃铛 // 重新加载订阅消息铃铛
window.share && window.share.event && window.share.event.emit('reloadNotice'); window.share && window.share.event && window.share.event.emit('reloadNotice');
const config = self.globalConfig; const config = self.globalConfig;
...@@ -369,7 +372,7 @@ class Site { ...@@ -369,7 +372,7 @@ class Site {
login.init(); login.init();
} }
changeGroup(event, item, onChangeVisible) { changeGroup(event, item, onChangeVisible, actionRef) {
event.persist(); event.persist();
const site = item ? item.site : event.target.dataset.site; const site = item ? item.site : event.target.dataset.site;
const { loginName } = this.globalConfig.userInfo; const { loginName } = this.globalConfig.userInfo;
...@@ -384,7 +387,7 @@ class Site { ...@@ -384,7 +387,7 @@ class Site {
// eslint-disable-next-line no-debugger // eslint-disable-next-line no-debugger
const { token } = res; const { token } = res;
if (token) { if (token) {
this.beforeChangeCheck(token, site, onChangeVisible); this.beforeChangeCheck(token, site, onChangeVisible, actionRef);
} }
}) })
.catch(error => { .catch(error => {
...@@ -393,7 +396,7 @@ class Site { ...@@ -393,7 +396,7 @@ class Site {
}); });
} }
beforeChangeCheck(token, site, onChangeVisible) { beforeChangeCheck(token, site, onChangeVisible, actionRef) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
appService appService
.getUserInfo({ .getUserInfo({
...@@ -404,7 +407,7 @@ class Site { ...@@ -404,7 +407,7 @@ class Site {
}) })
.then(res => { .then(res => {
if (res && !res.errMsg) { if (res && !res.errMsg) {
this.writeCookie(token, site, onChangeVisible); this.writeCookie(token, site, onChangeVisible, actionRef);
} else { } else {
message.warning('企业切换失败,请联系管理员排查问题!'); message.warning('企业切换失败,请联系管理员排查问题!');
this.setLoading(false); this.setLoading(false);
......
...@@ -209,9 +209,12 @@ export const initMicroApps = () => { ...@@ -209,9 +209,12 @@ export const initMicroApps = () => {
export const defaultApp = () => { export const defaultApp = () => {
const globalStore = store.getState().toJS();
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const config = window.globalConfig; const config = window.globalConfig;
// const flatMenu = globalStore.global.flatMenu;
// const current = flatMenu.find(item => item.name === '首页');
// config.homepage = current.path;
if (config && config.token) { if (config && config.token) {
let url = !config.home ? let url = !config.home ?
((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`; ((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`;
......
...@@ -59,7 +59,7 @@ const BootPage = props => { ...@@ -59,7 +59,7 @@ const BootPage = props => {
const [hasRole, setHasRole] = useState(false); const [hasRole, setHasRole] = useState(false);
const [scale, setScale] = useState(1); const [scale, setScale] = useState(1);
const [loginAction, setAction] = useState(() => new LoginAction(props)); const [loginAction, setAction] = useState(() => new LoginAction(props));
const history = useHistory(); // const history = useHistory();
useDocumentTitle( useDocumentTitle(
{ title: defaultSetting.title, id: '', pageName: '行业切换' }, { title: defaultSetting.title, id: '', pageName: '行业切换' },
props.global.title || defaultSetting.title, props.global.title || defaultSetting.title,
...@@ -98,7 +98,7 @@ const BootPage = props => { ...@@ -98,7 +98,7 @@ const BootPage = props => {
setLoadding(false); setLoadding(false);
props.history.push(`/?client=${props.global.client}`); props.history.push(`/?client=${props.global.client}`);
defaultApp(); defaultApp();
window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
props.updateCurrentIndex(0); props.updateCurrentIndex(0);
}; };
loginAction.events.on('toggleIndustry', handleToggleIndustry); loginAction.events.on('toggleIndustry', handleToggleIndustry);
......
...@@ -21,7 +21,7 @@ const Login = props => { ...@@ -21,7 +21,7 @@ const Login = props => {
otherChildren.push(child); otherChildren.push(child);
}); });
return ( return (
<LoginContext.Provider> <LoginContext.Provider value={{}}>
<div className={classNames(className, styles.login)}> <div className={classNames(className, styles.login)}>
<div className={styles.desc}> <div className={styles.desc}>
{intl.formatMessage({ id: 'pages.login.welcome' })} {intl.formatMessage({ id: 'pages.login.welcome' })}
......
@import '~antd/es/style/themes/default.less'; @root-entry-name: 'variable';
@import (reference) '~antd/es/style/themes/index';
.login { .login {
width: 250px; width: 250px;
:global { :global {
......
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { getParams } from '@wisdom-utils/utils/lib/helpers/params';
import BaseLogin from './template/baseLogin'; import BaseLogin from './template/baseLogin';
import NewYear from './template/newYear'; import NewYear from './template/newYear';
import InfoLogin from './template/infoLogin'; import InfoLogin from './template/infoLogin';
...@@ -10,7 +8,7 @@ import EnergyQuota from './template/energy_quota/index'; ...@@ -10,7 +8,7 @@ import EnergyQuota from './template/energy_quota/index';
import CloudLogin from './template/cloud'; import CloudLogin from './template/cloud';
import WaterLogin from './template/water'; import WaterLogin from './template/water';
import JSZHLogin from './template/project/JSZH'; import JSZHLogin from './template/project/JSZH';
import { initGlobalConfig } from '../../../initConfig'; import { AppInitState } from '../../../render';
const LoginTemplate = { const LoginTemplate = {
'新春 - 智联.html': NewYear, '新春 - 智联.html': NewYear,
'Dark - IOTMultiLogin.html': BaseLogin, 'Dark - IOTMultiLogin.html': BaseLogin,
...@@ -25,11 +23,13 @@ const LoginTemplate = { ...@@ -25,11 +23,13 @@ const LoginTemplate = {
}; };
/* eslint-disable */ /* eslint-disable */
export default (props) => { export default (props) => {
// const redirect = getParams('redirect'); const {location} = props.history;
useEffect(() => { useEffect(() => {
// if(getParams('loginName') && getParams('password')) return if(location.state && location.state.reload) {
initGlobalConfig(); AppInitState();
}
}, []); }, []);
if(Object.keys(window.globalConfig || {}).length === 0) return null;
const template = window.globalConfig && window.globalConfig.loginTemplate; const template = window.globalConfig && window.globalConfig.loginTemplate;
const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default']; const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default'];
return <RenderComponent {...props}/> return <RenderComponent {...props}/>
......
...@@ -4,8 +4,8 @@ import { Popover } from 'antd'; ...@@ -4,8 +4,8 @@ import { Popover } from 'antd';
import QRCode from 'qrcode.react'; import QRCode from 'qrcode.react';
import baseStyles from '../style.less'; import baseStyles from '../style.less';
const useRenderQcode = props => { const useRenderQcode = (props = {}) => {
const styles = props.styles || baseStyles; const styles = props.styles || {} || baseStyles;
if (!props.qrcode) { if (!props.qrcode) {
return null; return null;
} }
......
...@@ -137,6 +137,7 @@ class Login { ...@@ -137,6 +137,7 @@ class Login {
} }
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
self.getUserInfoAndConfig(); self.getUserInfoAndConfig();
} else { } else {
self.logout && self.logout(); self.logout && self.logout();
...@@ -308,15 +309,6 @@ class Login { ...@@ -308,15 +309,6 @@ class Login {
? `${homeType}/${params.getParams('redirect') || config.homepage}` ? `${homeType}/${params.getParams('redirect') || config.homepage}`
: ''; : '';
// 在云平台上,切换前后如果url一致会出问题
if (self.globalConfig.userInfo && self.globalConfig.userInfo.site) {
homepage = homepage
? `${homepage}${homepage.indexOf('|') > -1 ? '&' : '|'}_timestate=${Date.now().toString(16)}_${
self.globalConfig.userInfo.site
}`
: `civweb4/?_timestate=${Date.now().toString(16)}_${self.globalConfig.userInfo.site}`;
}
self.globalConfig = Object.assign(self.globalConfig, config, { self.globalConfig = Object.assign(self.globalConfig, config, {
theme: self.globalConfig.theme, theme: self.globalConfig.theme,
menu: self.globalConfig.menu, menu: self.globalConfig.menu,
...@@ -384,14 +376,17 @@ class Login { ...@@ -384,14 +376,17 @@ class Login {
self.globalConfig.shortcutIcon = mainConf.shortcutIcon; self.globalConfig.shortcutIcon = mainConf.shortcutIcon;
// if (mainConf.productType) // if (mainConf.productType)
// self.globalConfig.productType = mainConf.productType; // self.globalConfig.productType = mainConf.productType;
}
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
}
window.share.event = self.events;
self.callback && self.callback();
// console.log("===loginSuccess===") // console.log("===loginSuccess===")
getIndustry getIndustry
? self.events.emit('toggleIndustry') ? self.events.emit('toggleIndustry')
: self.events.emit('loginSuccess'); : self.events.emit('loginSuccess', self.history);
window.share.event = self.events;
self.callback && self.callback();
}); });
} else { } else {
// loginSuccess // loginSuccess
...@@ -400,7 +395,7 @@ class Login { ...@@ -400,7 +395,7 @@ class Login {
// console.log("===loginSuccess===") // console.log("===loginSuccess===")
getIndustry getIndustry
? self.events.emit('toggleIndustry') ? self.events.emit('toggleIndustry')
: self.events.emit('loginSuccess'); : self.events.emit('loginSuccess', self.history);
window.share.event = self.events; window.share.event = self.events;
self.callback && self.callback(); self.callback && self.callback();
} }
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/variable.less';
@userPageLogin-prefix-cls: ~'@{ant-prefix}-pro-pages-user-login'; @userPageLogin-prefix-cls: ~'@{ant-prefix}-pro-pages-user-login';
@keyframes loginTimeShow { @keyframes loginTimeShow {
0% { 0% {
......
...@@ -7,7 +7,7 @@ import classNames from 'classnames'; ...@@ -7,7 +7,7 @@ import classNames from 'classnames';
import { dom } from '@wisdom-utils/utils/lib/helpers'; import { dom } from '@wisdom-utils/utils/lib/helpers';
import { Helmet, HelmetProvider } from 'react-helmet-async'; import { Helmet, HelmetProvider } from 'react-helmet-async';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { useHistory, withRouter } from '@wisdom-utils/runtime'; import { useHistory } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import defaultSetting from '../../../../../config/defaultSetting'; import defaultSetting from '../../../../../config/defaultSetting';
import LoginAction from '../login'; import LoginAction from '../login';
...@@ -69,6 +69,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -69,6 +69,7 @@ const Login = forwardRef((props, _ref) => {
props.history.push(`/?client=${props.global.client}`); props.history.push(`/?client=${props.global.client}`);
// window.share.event.emit('triggerMicro', props.global); // window.share.event.emit('triggerMicro', props.global);
// initMicroApps(); // initMicroApps();
defaultApp(); defaultApp();
}); });
action && action &&
...@@ -136,7 +137,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -136,7 +137,7 @@ const Login = forwardRef((props, _ref) => {
return () => { return () => {
videoTimeout && clearTimeout(videoTimeout); videoTimeout && clearTimeout(videoTimeout);
videoRef.current.removeEventListener('ended', () => {}); videoRef && videoRef.current && videoRef.current.removeEventListener('ended', () => {});
}; };
}, [videoRef]); }, [videoRef]);
useEffect(() => { useEffect(() => {
...@@ -308,4 +309,4 @@ const mapDispatchToProps = dispatch => ({ ...@@ -308,4 +309,4 @@ const mapDispatchToProps = dispatch => ({
export default connect( export default connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps, mapDispatchToProps,
)(withRouter(Login)); )((Login));
...@@ -107,6 +107,7 @@ changeQrCode=(item)=>{ ...@@ -107,6 +107,7 @@ changeQrCode=(item)=>{
action.globalConfig = this.props.global; action.globalConfig = this.props.global;
this.props.updateCurrentIndex && this.props.updateCurrentIndex(-1); this.props.updateCurrentIndex && this.props.updateCurrentIndex(-1);
action && action.events.on('loginSuccess', event => { action && action.events.on('loginSuccess', event => {
debugger
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0); this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
this.props.history.push(`/?client=${this.props.global.client}`); this.props.history.push(`/?client=${this.props.global.client}`);
// window.share.event.emit('triggerMicro', this.props.global); // window.share.event.emit('triggerMicro', this.props.global);
...@@ -183,5 +184,5 @@ const mapDispatchToProps = dispatch => ({ ...@@ -183,5 +184,5 @@ const mapDispatchToProps = dispatch => ({
export default connect( export default connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps, mapDispatchToProps,
)(withRouter(InfoLogin)); )((InfoLogin));
...@@ -461,4 +461,4 @@ const mapDispatchToProps = dispatch => ({ ...@@ -461,4 +461,4 @@ const mapDispatchToProps = dispatch => ({
export default connect( export default connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps, mapDispatchToProps,
)(withRouter(Login)); )(Login);
import React from 'react'; import React, { useEffect } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { history } from '@wisdom-utils/runtime'; import { history } from '@wisdom-utils/runtime';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import Cookies from 'js-cookie';
import { getToken } from './utils/utils';
import { ConfigProvider, message, Modal, notification } from 'antd'; import { ConfigProvider, message, Modal, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable'; import { ConnectedRouter } from 'connected-react-router/immutable';
import { ErrorBoundary, LocaleContainer } from '@wisdom-utils/components'; import { ErrorBoundary, LocaleContainer } from '@wisdom-utils/components';
import store from './stores'; import Login from './pages/user/login/login';
import Container from './components/Container'; import { params, Storeage } from '@wisdom-utils/utils/lib/helpers';
import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
import canUseDom from 'rc-util/lib/Dom/canUseDom';
import App from './containers/App'; import App from './containers/App';
import Container from './components/Container';
import store from './stores';
import { appService } from './api';
import { defaultApp, initMicroApps } from './micro';
import { actionCreators } from './containers/App/store';
const { getThemeVariables } = require('antd/dist/theme');
const defaultSetting = require('../config/defaultSetting');
const MOUNT_NODE = document.getElementById('root'); const MOUNT_NODE = document.getElementById('root');
const customPrefixCls = 'panda-console-base'; const customPrefixCls = 'panda-console-base';
Modal.config({ const namespace = `__PANDA_STORE__${location.hostname}`;
rootPrefixCls: customPrefixCls window.createStoreage = new Storeage(namespace);
});
message.config({
rootPrefixCls: customPrefixCls const dynamicStyleMark = `-panda-${Date.now()}-${Math.random()}`;
}); function getStyle(prefixCls, theme) {
notification.config({ const variables = {};
rootPrefixCls: customPrefixCls
}); Object.keys(theme).forEach(item => {
ConfigProvider.config({ variables[item] = theme[item]
})
const cssList = Object.keys(variables).map(
key => `--${prefixCls}-${key}: ${variables[key]};`,
);
return `
:root {
${cssList.join('\n')}
}
`.trim();
}
const registerTheme = function(prefixCls, theme) {
const style = getStyle(prefixCls, theme);
if(canUseDom()) {
updateCSS(style, `${dynamicStyleMark}-dynamic-theme`)
}
}
export const AppInitState = () => {
const getClient = () => {
const value = params.getParams('client') || Cookies.get('client');
const client = value && value !== 'undefined' ? value : 'city';
return client;
}
const client = getClient();
let config = window.globalConfig || {};
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
window.globalConfig = {};
window.__INITIAL_STATE__ = {};
if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
config = {};
}
if (!params.getParams('client', window.location.search) && config) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
}
// eslint-disable-next-line no-undef
if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace);
}
if (!getToken()) {
localStorage.removeItem('loginSite');
}
const initGeteWay = () => {
appService.getWateWayConfig({ignoreSite: true}).then(res => {
const hasGateWay = !res || !res.data ? false : _.isString(res.data) ? JSON.parse(res.data) : typeof res.data === 'boolean' ? res.data : false;
return {
hasGateWay,
apiGatewayDomain: `${window.location.origin}${hasGateWay ? '/PandaCore/GateWay' : ''}`,
};
}).then(gateWayConfig => {
initGlobalConfig(gateWayConfig);
}).catch(err => {
initGlobalConfig();
});
}
const initGlobalConfig = (gateWayConfig = {}) => {
appService.queryConfig({
client: client || 'city',
ignoreSite: true,
}).then(res => {
if (res) {
const { data } = res;
if (!data.client) {
data.client = client;
}
store.dispatch(actionCreators.getConfig(Object.assign({},data,{
token: '',
access_token: '',
userInfo: null,
},gateWayConfig)));
const products = (data.products || []).map(item => {
if (item.PackageName === 'civweb4') {
return 'web4_console'
}
return `${item.PackageName}-main`;
});
if(products && products.length > 0) {
Object.keys(products).forEach(item => {
window[products[item]] && window[products[item]] && window[products[item]].unmount && window[products[item]].unmount({ store: store });
});
initMicroApps();
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
const action = new Login({
global: Object.assign({}, data,
{
token: getToken(),
},
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) &&
initMicroApps(loader, store);
})();
},
true,
);
action.events.on('loginSuccess', event =>{
window.history.pushState('', '', `/?client=${client}`);
defaultApp();
})
}
return window.globalConfig.variableTheme
}
})
.then(themeConfig => {
ConfigProvider.config({
prefixCls: customPrefixCls, prefixCls: customPrefixCls,
}); theme: {
primaryColor: themeConfig.primaryColor
}
});
registerTheme(customPrefixCls, {
'header-bg-color': themeConfig.headerPrimaryColor
//'linear-gradient(0deg, #0066d6, #39a9ff 100%)',
});
})
.catch(error => {
store.dispatch(actionCreators.getConfigError(error));
});
}
const initLocale = () => {
localStorage.setItem('umi_locale', 'zh-CN');
};
// 语音播报全局拦截
const initMessageVoice = () => {
const rawSpeak = window.speechSynthesis.speak;
window.speechSynthesis.speak = function(...args) {
if (
window.globalConfig &&
// eslint-disable-next-line no-prototype-builtins
window.globalConfig.hasOwnProperty('messageVoice') &&
window.globalConfig.messageVoice === false
)
return;
rawSpeak.apply(window.speechSynthesis, args);
};
};
initLocale();
initMessageVoice();
initGeteWay();
}
const RootContainer = () => {
useEffect(() => {
AppInitState();
}, []);
const finalConfig = {
...{
prefixCls: customPrefixCls,
theme: {
"root-entry-name": "default",
...getThemeVariables({}),
primaryColor: defaultSetting.primaryColor,
},
}
}
if(finalConfig.prefixCls) {
Modal.config({
rootPrefixCls: customPrefixCls
});
message.config({
rootPrefixCls: `${finalConfig.prefixCls}-message`
});
notification.config({
rootPrefixCls: `${finalConfig.prefixCls}-notification`
});
}
return React.createElement(Provider, {
store: store
}, React.createElement(ConnectedRouter, {
history: history
}, React.createElement(LocaleContainer, {
prefixCls: customPrefixCls
}, React.createElement(ConfigProvider, {
prefixCls: customPrefixCls
}, React.createElement(Container, null, React.createElement(App))))))
}
export const render = () => { export const render = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM.render( ReactDOM.render(<RootContainer/>, MOUNT_NODE);
<Provider store={store}>
<ConnectedRouter history={history}>
<LocaleContainer>
<ConfigProvider prefixCls={customPrefixCls}>
<ErrorBoundary>
<Container>
<App />
</Container>
</ErrorBoundary>
</ConfigProvider>
</LocaleContainer>
</ConnectedRouter>
</Provider>,
MOUNT_NODE,
);
}; };
// updateTheme('#ff9600'); // updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading }); const loader = (appContent, loading) => render({ appContent, loading });
......
...@@ -2,7 +2,7 @@ import LoadingComponent from '@wisdom-utils/components/lib/AppLayout/components/ ...@@ -2,7 +2,7 @@ import LoadingComponent from '@wisdom-utils/components/lib/AppLayout/components/
import { dynamic } from '@wisdom-utils/runtime'; import { dynamic } from '@wisdom-utils/runtime';
import { UserLayout } from '@wisdom-utils/components/lib/AppLayout'; import { UserLayout } from '@wisdom-utils/components/lib/AppLayout';
import BasicLayout from '../layouts/BasicLayout'; import BasicLayout from '../layouts/BasicLayout_PRO';
import HNLayout from '../layouts/HNLayout'; import HNLayout from '../layouts/HNLayout';
import BootPage from '../pages/bootpage'; import BootPage from '../pages/bootpage';
import Iframe from '../pages/iframe'; import Iframe from '../pages/iframe';
...@@ -26,6 +26,11 @@ export const dyRoutes = (routes, layout, theme) => { ...@@ -26,6 +26,11 @@ export const dyRoutes = (routes, layout, theme) => {
name: 'login', name: 'login',
path: '/user/login', path: '/user/login',
component: Login, component: Login,
props: {
onEnter(props) {
console.log("login props", props)
}
}
}, },
{ {
name: 'noscret', name: 'noscret',
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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