Commit 0e7ab93d authored by 邓晓峰's avatar 邓晓峰

feat: 菜单框架调整

parent 7d0e33ac
......@@ -29,7 +29,7 @@ module.exports = {
baseNavigator: true,
},
dynamicImport: {
loading: '@ant-design/pro-layout/es/PageLoading',
loading: '@wisdom-utils/components/lib/AppLayout/components/PageLoading',
},
// theme: {
// '@primary-color': '#ff9600',
......@@ -40,6 +40,9 @@ module.exports = {
exclude: ['@wisdom-map/arcgismap', '@wisdom-map/amap', '@wisdom-map/basemap', 'swagger-ui-react', 'Cesium'],
},
proxy: proxy[NODE_ENV],
theme: {
'root-entry-name': 'variable',
},
// openAPI: {
// requestLibPath: "import { request } from '@wisdom-utils/utils'",
// schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
......@@ -77,7 +80,7 @@ module.exports = {
modifyVars: {
// hack: `true; @import "~@/global.less";`,
'@ant-prefix': 'panda-console-base',
'@iconPrefixCls': 'panda-console-base-icon',
// '@iconPrefixCls': 'panda-console-base-icon',
},
javascriptEnabled: true,
},
......
......@@ -22,7 +22,7 @@ export default {
// },
{
name: 'civ_water',
entry: `//${window.location.hostname}:8081/civ_water`,
entry: `//${window.location.hostname}:3000/civ_water`,
container: '#micro-container',
activeRule: '/civbase/civ_water',
},
......
......@@ -2,7 +2,7 @@
// 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 = 'http://192.168.12.3:8082';
const proxyURL = 'https://panda-water.cn'
const proxyURL = 'http://192.168.10.150:8670'
module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
......
......@@ -173,7 +173,7 @@ module.exports = options => {
reactRemovePropTypes: isProd,
reactRequire: true,
lockCoreJS3: {},
import: (presetOpts.import || []).concat([{ libraryName: 'antd', libraryDirectory: 'es', style: true }]),
// import: (presetOpts.import || []).concat([{ libraryName: 'antd', libraryDirectory: 'es', style: true }]),
});
const babelOpts = {
......
......@@ -106,15 +106,15 @@
"@wisdom-cesium/cesium": "^1.0.80",
"@wisdom-components/basictable": "^1.5.16",
"@wisdom-components/empty": "^1.4.1",
"@wisdom-map/amap": "^1.0.49--27.3",
"@wisdom-map/amap": "^1.0.49--27.3",
"@wisdom-map/arcgismap": "^1.0.79-44",
"@wisdom-map/basemap": "^1.0.12-44",
"@wisdom-map/util": "^1.0.27-0",
"@wisdom-utils/components": "0.1.84",
"@wisdom-utils/components": "0.1.198",
"@wisdom-utils/runtime": "0.0.15",
"@wisdom-utils/utils": "0.1.124",
"@wisdom-utils/utils": "0.1.238",
"animate.css": "^4.1.1",
"antd": "^4.17.4",
"antd": "^4.20.7",
"compression": "1.7.4",
"connected-react-router": "6.4.0",
"echarts": "^5.3.0",
......@@ -138,9 +138,9 @@
"qiankun": "^2.4.6",
"qrcode.react": "^1.0.0",
"rc-cascader": "^2.3.2",
"react": "16.12.0",
"react": "17.0.2",
"react-activation": "^0.9.9",
"react-dom": "16.12.0",
"react-dom": "17.0.2",
"react-draggable": "^4.4.3",
"react-helmet": "6.0.0-beta",
"react-helmet-async": "^1.0.4",
......@@ -148,7 +148,7 @@
"react-intl": "^3.12.1",
"react-redux": "7.0.2",
"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",
"redux": "4.0.1",
......@@ -237,7 +237,7 @@
"jest-dom": "3.1.3",
"jest-styled-components": "6.3.1",
"jsonp": "^0.2.1",
"less": "3.12.0",
"less": "4.1.2",
"less-loader": "5.0.0",
"lint-staged": "8.1.5",
"memoizee": "^0.4.15",
......
......@@ -3,41 +3,16 @@ import './public-path';
import '!file-loader?name=[name].[ext]!./images/favicon.ico';
import './global.less';
import 'animate.css/animate.css';
// import 'antd/dist/antd.less';
import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions
import '@wisdom-utils/utils/lib/helpers/format';
import 'sanitize.css/sanitize.css';
import { Storeage, params } from '@wisdom-utils/utils/lib/helpers';
import { initGlobalConfig } from './initConfig';
import './utils/event';
// import { Storeage, params } from '@wisdom-utils/utils/lib/helpers';
import { render } from './render';
// import store from './stores';
import './utils/event';
// eslint-disable-next-line no-restricted-globals
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
const initLocale = () => {
localStorage.setItem('umi_locale', 'zh-CN');
};
// 语音播报全局拦截
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();
// const namespace = `__PANDA_STORE__${location.hostname}`;
// window.createStoreage = new Storeage(namespace);
;(() => {
render();
})();
\ No newline at end of file
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 {
count={this.state.count}
confirmRead={this.notifier.confirmRead}
config={this.props.global}
bell={this.props.bell}
>
<NoticeIcon.Tab
list={this.state.noticeData}
......
This diff is collapsed.
@import '~antd/es/style/themes/default.less';
@import '~antd/es/style/themes/variable.less';
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
.menu {
......@@ -16,6 +16,7 @@
height: 46px;
margin-left: auto;
overflow: hidden;
align-items: center;
.action {
display: flex;
align-items: center;
......@@ -46,6 +47,26 @@
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 {
// .avatar {
// margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0;
......@@ -62,6 +83,7 @@
// overflow: hidden;
// }
//}
}
.dark {
......@@ -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 {
position: absolute;
......
......@@ -32,6 +32,7 @@ function App(props) {
(props.global && props.global.theme) || 'dark',
).routes,
)}
</Switch>
</Router>
</>
......@@ -40,7 +41,7 @@ function App(props) {
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']),
menu: state.getIn(['global', 'menu'])
});
export default connect(
mapStateToProps,
......
......@@ -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 pkg from '../../../../package.json';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
import _ from 'lodash';
import memoized from 'nano-memoize';
// import { transformWidgets } from '../../../utils/routes';
// eslint-disable-next-line import/no-duplicates
import {
......@@ -97,11 +99,32 @@ const appReducer = (state = initialState, action) => {
window.globalConfig && window.globalConfig.products && Array.isArray(window.globalConfig.products) && window.globalConfig.products.map(item => {
modulePkg[item.PackageName] = item;
});
config.widgets = transformWidgets(config.widgets);
config.widgets =transformWidgets(config.widgets);
// const pickMenus = memoized(() => )
const generMenu = generMainRoutes(config.widgets || [], null, 0, modulePkg);
let flatMenu = [];
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 => {
......@@ -113,6 +136,8 @@ 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;
......@@ -126,7 +151,7 @@ const appReducer = (state = initialState, action) => {
Cookies.set('client', Cookies.get('client') || window.globalConfig.client);
window.globalConfig = config;
return state.merge({
globalConfig: config,
globalConfig: config || {},
menu: generMenu || [],
flatMenu,
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,
body,
......@@ -202,11 +203,11 @@ select:-webkit-autofill {
}
}
}
.@{ant-prefix}-pro-global-header-layout-side {
> div {
display: flex;
}
}
// .@{ant-prefix}-pro-global-header-layout-side {
// > div {
// display: flex;
// }
// }
.@{ant-prefix}-pro-basicLayout-side {
.@{ant-prefix}-pro-sider-extra {
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);
@panda-prefix-cls: ~'@{ant-prefix}';
.@{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';
@primary-color: #1685ff;
@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);
.mainPane {
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);
@primary-color: #1685ff;
@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-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@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-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@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-1: color(~`colorPalette('@{primary-color}', 1) `); // replace tint(@primary-color, 90%)
@primary-2: color(~`colorPalette('@{primary-color}', 2) `); // replace tint(@primary-color, 80%)
......@@ -38,6 +38,10 @@
color: #FFFFFF;
font-size: 14px;
margin-left: 9px;
word-spacing: normal;
text-overflow: ellipsis;
overflow: hidden;
word-break: keep-all;
}
.arrow {
margin-left: 9px;
......@@ -221,16 +225,16 @@
padding: 0 14px;
// margin-bottom: 0px;
}
:global(.@{ant-prefix}-layout-sider-collapsed .@{ant-prefix}-menu-item.@{ant-prefix}-menu-item-only-child) {
padding-left: 0px!important;
}
:global(.@{ant-prefix}-layout-sider-collapsed
.@{ant-prefix}-menu-inline-collapsed
.@{ant-prefix}-menu-item-only-child.@{ant-prefix}-menu-item-selected) {
border-left: 2px solid @primary-color;
background-color: @menu-dark-inline-submenu-bg!important;
transition: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
// :global(.@{ant-prefix}-layout-sider-collapsed .@{ant-prefix}-menu-item.@{ant-prefix}-menu-item-only-child) {
// padding-left: 0px!important;
// }
// :global(.@{ant-prefix}-layout-sider-collapsed
// .@{ant-prefix}-menu-inline-collapsed
// .@{ant-prefix}-menu-item-only-child.@{ant-prefix}-menu-item-selected) {
// border-left: 2px solid @primary-color;
// background-color: @menu-dark-inline-submenu-bg!important;
// transition: cubic-bezier(0.175, 0.885, 0.32, 1.275);
// }
:global(.@{ant-prefix}-menu-submenu-popup
li.@{ant-prefix}-menu-item-only-child
.panda-pro-layouts-user-layout-minixName) {
......@@ -372,7 +376,7 @@
li {
// margin-top: 10px;
a {
color: #3f70b5;
color: @primary-color;
&.city_select {
cursor: pointer;
}
......@@ -380,7 +384,7 @@
position: relative;
}
&:hover {
color: #23527c !important;
color: @primary-7 !important;
transition: color 0.3s;
}
div[title] {
......@@ -476,7 +480,7 @@
display: flex;
margin-top: 2px;
.proviceName {
color: #3d6dcc;
color: @primary-color;
font-weight: bolder;
min-width: 36px;
}
......@@ -506,6 +510,9 @@
top: 50%;
transform: translate(-50%, -50%);
}
:global(.@{ant-prefix}-popover-arrow) {
display: none;
}
}
:global(.@{ant-prefix}-pro-basicLayout .@{ant-prefix}-pro-sider-logo h1) {
display: none;
......
This diff is collapsed.
@import '~~antd/es/style/variable.less';
@hn-greenColor: #00b278;
:global{
.@{ant-prefix}-drawer-left.@{ant-prefix}-drawer-open{
......
......@@ -2,7 +2,7 @@ import React from 'react';
import Cookies from 'js-cookie';
import { connect } from 'react-redux';
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 { stringify } from 'querystring';
import { store, helpers } from '@wisdom-utils/utils';
......@@ -48,6 +48,7 @@ class SecurityLayout extends React.Component {
const { children, global, loading } = this.props;
const tk = Cookies.get('token') || global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0);
if (!isLogin && window.location.pathname !== '/civbase/user/login' || (global.hasOwnProperty('size') && global.size === 0)) {
const { query = {}, search, pathname } = history.location;
const { redirect } = query;
......@@ -61,7 +62,7 @@ class SecurityLayout extends React.Component {
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
return (
<Redirect
to={`/user/login?client=${client}${generateType}`}
to={{pathname: `/user/login?client=${client}${generateType}`, state:{reload: true}}}
/>
);
};
......
......@@ -319,7 +319,7 @@ class Site {
return arr;
}
writeCookie(token, site, onChangeVisible) {
writeCookie(token, site, onChangeVisible, actionRef) {
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......@@ -349,6 +349,7 @@ class Site {
// debugger
// initMicroApps();
// 切换站点后,重置掉三级菜单
const homeType = self.globalConfig.homeType || 'civweb4';
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', {
......@@ -356,6 +357,8 @@ class Site {
path: homePath,
icon: null,
});
actionRef && actionRef.current && actionRef.current.reload()
// 重新加载订阅消息铃铛
window.share && window.share.event && window.share.event.emit('reloadNotice');
......@@ -369,7 +372,7 @@ class Site {
login.init();
}
changeGroup(event, item, onChangeVisible) {
changeGroup(event, item, onChangeVisible, actionRef) {
event.persist();
const site = item ? item.site : event.target.dataset.site;
const { loginName } = this.globalConfig.userInfo;
......@@ -384,7 +387,7 @@ class Site {
// eslint-disable-next-line no-debugger
const { token } = res;
if (token) {
this.beforeChangeCheck(token, site, onChangeVisible);
this.beforeChangeCheck(token, site, onChangeVisible, actionRef);
}
})
.catch(error => {
......@@ -393,7 +396,7 @@ class Site {
});
}
beforeChangeCheck(token, site, onChangeVisible) {
beforeChangeCheck(token, site, onChangeVisible, actionRef) {
// eslint-disable-next-line no-undef
appService
.getUserInfo({
......@@ -404,7 +407,7 @@ class Site {
})
.then(res => {
if (res && !res.errMsg) {
this.writeCookie(token, site, onChangeVisible);
this.writeCookie(token, site, onChangeVisible, actionRef);
} else {
message.warning('企业切换失败,请联系管理员排查问题!');
this.setLoading(false);
......
This diff is collapsed.
......@@ -64,7 +64,7 @@ const BootPage = props => {
const [hasRole, setHasRole] = useState(false);
const [scale, setScale] = useState(1);
const [loginAction, setAction] = useState(() => new LoginAction(props));
const history = useHistory();
// const history = useHistory();
useDocumentTitle(
{ title: defaultSetting.title, id: '', pageName: '行业切换' },
props.global.title || defaultSetting.title,
......@@ -103,7 +103,7 @@ const BootPage = props => {
setLoadding(false);
props.history.push(`/?client=${props.global.client}`);
defaultApp();
window.share.event.emit('triggerMicro', props.global);
// window.share.event.emit('triggerMicro', props.global);
props.updateCurrentIndex(0);
};
loginAction.events.on('toggleIndustry', handleToggleIndustry);
......
......@@ -21,7 +21,7 @@ const Login = props => {
otherChildren.push(child);
});
return (
<LoginContext.Provider>
<LoginContext.Provider value={{}}>
<div className={classNames(className, styles.login)}>
<div className={styles.desc}>
{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 {
width: 250px;
:global {
......
import React, { useEffect } from 'react';
import { getParams } from '@wisdom-utils/utils/lib/helpers/params';
import BaseLogin from './template/baseLogin';
import NewYear from './template/newYear';
import InfoLogin from './template/infoLogin';
......@@ -8,7 +6,7 @@ import Yulin from './template/yulin';
// import { useParams } from '@wisdom-utils/runtime';
import EnergyQuota from './template/energy_quota/index';
import CloudLogin from './template/cloud';
import { initGlobalConfig } from '../../../initConfig';
import { AppInitState } from '../../../render';
const LoginTemplate = {
'新春 - 智联.html': NewYear,
'Dark - IOTMultiLogin.html': BaseLogin,
......@@ -21,11 +19,13 @@ const LoginTemplate = {
};
/* eslint-disable */
export default (props) => {
// const redirect = getParams('redirect');
const {location} = props.history;
useEffect(() => {
// if(getParams('loginName') && getParams('password')) return
initGlobalConfig();
if(location.state && location.state.reload) {
AppInitState();
}
}, []);
if(Object.keys(window.globalConfig || {}).length === 0) return null;
const template = window.globalConfig && window.globalConfig.loginTemplate;
const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default'];
return <RenderComponent {...props}/>
......
......@@ -4,8 +4,8 @@ import { Popover } from 'antd';
import QRCode from 'qrcode.react';
import baseStyles from '../style.less';
const useRenderQcode = props => {
const styles = props.styles || baseStyles;
const useRenderQcode = (props = {}) => {
const styles = props.styles || {} || baseStyles;
if (!props.qrcode) {
return null;
}
......
......@@ -137,6 +137,7 @@ class Login {
}
self.updateConfig && self.updateConfig(self.globalConfig);
self.getUserInfoAndConfig();
} else {
self.logout && self.logout();
......@@ -297,7 +298,7 @@ class Login {
? Array.isArray(response.data)
? response.data
: []
: response;
: response;
if (result && result.length > 0) {
const config = result.shift();
const homeType = config.productType || 'civweb4';
......@@ -307,15 +308,6 @@ class Login {
: homeType && 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, {
theme: self.globalConfig.theme,
......@@ -324,7 +316,7 @@ class Login {
homepage: homepage || '',
// mapsettings: config.mapsettings
});
self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then(res => {
window.subSysCfg = {};
......@@ -384,14 +376,17 @@ class Login {
self.globalConfig.shortcutIcon = mainConf.shortcutIcon;
// if (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===")
getIndustry
? self.events.emit('toggleIndustry')
: self.events.emit('loginSuccess');
window.share.event = self.events;
self.callback && self.callback();
: self.events.emit('loginSuccess', self.history);
});
} else {
// loginSuccess
......@@ -400,7 +395,7 @@ class Login {
// console.log("===loginSuccess===")
getIndustry
? self.events.emit('toggleIndustry')
: self.events.emit('loginSuccess');
: self.events.emit('loginSuccess', self.history);
window.share.event = self.events;
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';
@keyframes loginTimeShow {
0% {
......
......@@ -7,7 +7,7 @@ import classNames from 'classnames';
import { dom } from '@wisdom-utils/utils/lib/helpers';
import { Helmet, HelmetProvider } from 'react-helmet-async';
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 defaultSetting from '../../../../../config/defaultSetting';
import LoginAction from '../login';
......@@ -69,6 +69,7 @@ const Login = forwardRef((props, _ref) => {
props.history.push(`/?client=${props.global.client}`);
// window.share.event.emit('triggerMicro', props.global);
// initMicroApps();
defaultApp();
});
action &&
......@@ -136,7 +137,7 @@ const Login = forwardRef((props, _ref) => {
return () => {
videoTimeout && clearTimeout(videoTimeout);
videoRef.current.removeEventListener('ended', () => {});
videoRef && videoRef.current && videoRef.current.removeEventListener('ended', () => {});
};
}, [videoRef]);
useEffect(() => {
......@@ -308,4 +309,4 @@ const mapDispatchToProps = dispatch => ({
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(Login));
)((Login));
......@@ -107,6 +107,7 @@ changeQrCode=(item)=>{
action.globalConfig = this.props.global;
this.props.updateCurrentIndex && this.props.updateCurrentIndex(-1);
action && action.events.on('loginSuccess', event => {
debugger
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
this.props.history.push(`/?client=${this.props.global.client}`);
// window.share.event.emit('triggerMicro', this.props.global);
......@@ -183,5 +184,5 @@ const mapDispatchToProps = dispatch => ({
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(InfoLogin));
)((InfoLogin));
......@@ -461,4 +461,4 @@ const mapDispatchToProps = dispatch => ({
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(Login));
)(Login);
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom';
import { history } from '@wisdom-utils/runtime';
import { Provider } from 'react-redux';
import Cookies from 'js-cookie';
import { getToken } from './utils/utils';
import { ConfigProvider, message, Modal, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable';
import { ErrorBoundary, LocaleContainer } from '@wisdom-utils/components';
import store from './stores';
import Container from './components/Container';
import Login from './pages/user/login/login';
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 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 customPrefixCls = 'panda-console-base';
Modal.config({
rootPrefixCls: customPrefixCls
});
message.config({
rootPrefixCls: customPrefixCls
});
notification.config({
rootPrefixCls: customPrefixCls
});
ConfigProvider.config({
prefixCls: customPrefixCls,
});
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
const dynamicStyleMark = `-panda-${Date.now()}-${Math.random()}`;
function getStyle(prefixCls, theme) {
const variables = {};
Object.keys(theme).forEach(item => {
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 => {
console.log("err", error)
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 });
});
debugger
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();
})
}
}
})
.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 customPrefixCls = 'panda-console-base';
const finalConfig = {
...{
prefixCls: customPrefixCls,
theme: {
"root-entry-name": "default",
...getThemeVariables({}),
primaryColor: defaultSetting.primaryColor,
},
}
}
if(finalConfig.prefixCls) {
ConfigProvider.config({
prefixCls: finalConfig.prefixCls,
theme: finalConfig.theme
});
Modal.config({
rootPrefixCls: customPrefixCls
});
message.config({
rootPrefixCls: `${finalConfig.prefixCls}-message`
});
notification.config({
rootPrefixCls: `${finalConfig.prefixCls}-notification`
});
registerTheme('panda-console-base', {
'header-bg-color': 'linear-gradient(0deg, #0066d6, #39a9ff 100%)',
});
}
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 = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<LocaleContainer>
<ConfigProvider prefixCls={customPrefixCls}>
<ErrorBoundary>
<Container>
<App />
</Container>
</ErrorBoundary>
</ConfigProvider>
</LocaleContainer>
</ConnectedRouter>
</Provider>,
MOUNT_NODE,
);
ReactDOM.render(<RootContainer/>, MOUNT_NODE);
};
// updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading });
......
......@@ -2,7 +2,7 @@ import LoadingComponent from '@wisdom-utils/components/lib/AppLayout/components/
import { dynamic } from '@wisdom-utils/runtime';
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 BootPage from '../pages/bootpage';
import Iframe from '../pages/iframe';
......@@ -26,6 +26,11 @@ export const dyRoutes = (routes, layout, theme) => {
name: 'login',
path: '/user/login',
component: Login,
props: {
onEnter(props) {
console.log("login props", props)
}
}
},
{
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