Commit 13b633f3 authored by 邓晓峰's avatar 邓晓峰

feat: es-build

parent 558dd7aa
Pipeline #47271 skipped with stages
......@@ -5,11 +5,14 @@ const cesiumBuild = '../node_modules/cesium/Build/Cesium';
const pkgName = require('../package.json').name;
// eslint-disable-next-line import/order
const { REACT_APP_ENV } = process.env;
// eslint-disable-next-line import/order
const path = require('path');
const CESIUM_BASE_URL = `/${pkgName}`;
module.exports = {
// mfsu: {},
esbuild: {},
webpack5: {},
workerLoader: true,
base: '/civbase',
title: '熊猫智慧城市监控管理解决方案',
hash: true,
......@@ -39,7 +42,7 @@ module.exports = {
'@wisdom-map/Amap',
'@wisdom-map/Map',
'swagger-ui-react',
'Cesium'
'Cesium',
],
},
proxy: proxy[REACT_APP_ENV || 'dev'],
......
/* eslint-disable */
// 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.47:8082';
const proxyURL = 'https://work.panda-water.cn';
// const proxyURL = 'http://192.168.12.47:8082';
module.exports = {
......
const { deepmerge, createDebug, winPath, resolve } = require('@umijs/utils');
// const { ESBuildPlugin, ESBuildMinifyPlugin } = require('esbuild-loader');
const { ESBuildPlugin, ESBuildMinifyPlugin } = require('esbuild-loader');
const fs = require('fs');
const terserOptions = require('./terserOptions');
const path = require('path');
const webpack = require('webpack');
const { css, createCSSRule } = require('./css');
const Config = require('webpack-chain');
const lodash = require('lodash');
const {
getTargetsAndBrowsersList,
getBabelPresetOpts,
getBabelOpts,
} = require('@umijs/bundler-utils');
const { join } = require('lodash');
const terserOptions = require('./terserOptions');
const { css, createCSSRule } = require('./css');
const pkg = require('../../package.json');
const ASSET_PATH = process.env.ASSET_PATH || '/';
const {
......@@ -21,13 +28,6 @@ const {
excludeToPkgs,
es5ImcompatibleVersionsToPkg,
} = require('./nodeModulesTransform');
const lodash = require('lodash');
const {
getTargetsAndBrowsersList,
getBabelPresetOpts,
getBabelOpts,
} = require('@umijs/bundler-utils');
const { join } = require('lodash');
function getUserLibDir({ library }) {
if (
......@@ -72,7 +72,7 @@ module.exports = options => {
const chainConfig = new Config();
chainConfig.mode(options.mode);
defineConfig = Object.assign(defineConfig, defaultConfig);
const {env} = process;
const { env } = process;
const isDev = process.env.NODE_ENV === 'development';
const isProd = process.env.NODE_ENV === 'production';
const disableCompress = process.env.COMPRESS === 'none';
......@@ -87,7 +87,7 @@ module.exports = options => {
: devtool || 'cheap-module-source-map'
: devtool,
);
const {mfsu} = defineConfig;
const { mfsu } = defineConfig;
const useHash = defineConfig.hash && isProd;
const absOutputPath = process.env.npm_config_releasepath
......@@ -277,7 +277,6 @@ module.exports = options => {
esModule: false,
});
chainConfig.module
.rule('svg')
.test(/\.(svg)(\?.*)?$/)
......@@ -447,7 +446,7 @@ module.exports = options => {
from: path.join(cwd, item.from),
to: path.resolve(
process.env.npm_config_releasepath || process.cwd(),
pkg.name.toLocaleLowerCase() + '/' + item.to,
`${pkg.name.toLocaleLowerCase()}/${item.to}`,
),
};
})
......@@ -531,10 +530,12 @@ module.exports = options => {
...excludeToPkgs({ exclude: nodeModulesTransform.exclude || [] }),
};
rule.include
.add(path => isMatch({
.add(path =>
isMatch({
path,
pkgs,
}))
}),
)
.end();
}
......@@ -654,19 +655,19 @@ module.exports = options => {
});
}
// if(defineConfig.esbuild) {
// const { target = 'es2015' } = defineConfig.esbuild || {};
// const optsMap = {
// ['csr']: {
// minify: true,
// target
// }
// };
// const opt = optsMap['csr'];
// chainConfig.optimization.minimize = true;
// // chainConfig.optimization.minimizer = [new ESBuildMinifyPlugin(opt)];
// // chainConfig.plugin('es-build').use(new ESBuildPlugin())
// }
if (defineConfig.esbuild) {
const { target = 'es2015' } = defineConfig.esbuild || {};
const optsMap = {
csr: {
minify: true,
target
},
};
const opt = optsMap.csr;
chainConfig.optimization.minimize = true;
chainConfig.optimization.minimizer = [new ESBuildMinifyPlugin(opt)];
chainConfig.plugin('es-build').use(new ESBuildPlugin())
}
if (defineConfig.chainWebpack) {
defineConfig.chainWebpack(chainConfig, {
......@@ -704,7 +705,7 @@ module.exports = options => {
ret = smp.wrap(ret);
}
const {entry} = options;
const { entry } = options;
if (defineConfig.runtimePublicPath) {
entry.push(require.resolve('./runtimePublicPathEntry'));
}
......@@ -714,7 +715,7 @@ module.exports = options => {
if (isWebpack5) {
ret.plugins.push(
new webpack.ProvidePlugin({
process: nodeLibs.process
process: nodeLibs.process,
}),
);
ret.resolve.fallback = {
......
......@@ -112,7 +112,7 @@
"@wisdom-map/util": "^1.0.27-0",
"@wisdom-utils/components": "0.0.14",
"@wisdom-utils/runtime": "0.0.15",
"@wisdom-utils/utils": "0.0.74",
"@wisdom-utils/utils": "0.0.77",
"animate.css": "^4.1.1",
"antd": "^4.17.4",
"compression": "1.7.4",
......@@ -212,6 +212,7 @@
"cz-customizable": "^6.3.0",
"dotenv": "^8.2.0",
"ejs": "^3.1.6",
"esbuild-loader": "^2.18.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "17.1.0",
"eslint-config-airbnb-base": "13.1.0",
......
// 主应用 和 子应用数据传递
import { initGlobalState } from 'qiankun';
import { event, store } from '@wisdom-utils/utils'
import { event, store } from '@wisdom-utils/utils';
export const initialState = {
globalConfig: {},
event: event,
store: store
globalConfig: {},
event,
store,
};
const actions = initGlobalState(initialState);
// action.setGlobalState({key: value}) 更新状态
// actions.onGlobalStateChange((newState, prevStaet) => {}) 监听状态
export const setGlobalState = actions.setGlobalState;
export const onGlobalStateChange = actions.onGlobalStateChange;
export const { setGlobalState } = actions;
export const { onGlobalStateChange } = actions;
export default actions;
import { Modal, notification } from 'antd';
import { instanceRequest, service } from '@wisdom-utils/utils';
import { event } from 'microser-data';
import { actionCreators } from '../containers/App/store';
import { instanceRequest, service, event } from '@wisdom-utils/utils';
import AppService from './service/base';
import notificationService from './service/notification';
import CloudService from './service/cloud';
......@@ -10,18 +8,32 @@ const { warning } = Modal;
// eslint-disable-next-line no-return-await
instanceRequest.reportCodeError = true;
instanceRequest.transformRequestURL = function(url) {
// url = url.replace(/\/GateWay/, '')
const excludeURL = ['/PandaCore/GCK/Basis/GateWayConfig', '/CityInterface/rest/services.svc/GetConfig'];
if(excludeURL.includes(url)) {
const excludeURL = [
'/PandaCore/GCK/Basis/GateWayConfig',
'/CityInterface/rest/services.svc/GetConfig',
];
if (excludeURL.includes(url)) {
return url;
}
if (window.globalConfig && window.globalConfig.hasGateWay && /^\/(cityinterface|CityInterface|Cityinterface|CityServer|PandaInformatization)/.test(url)) {
return /\/CityInterface\/rest\/services.svc\/GetConfig/.test(url) ? url ? /^\/GateWay/.test(url) ? url : '/GateWay' + url: '/GateWay' + url: '/GateWay' + url;
if (
window.globalConfig &&
window.globalConfig.hasGateWay &&
/^\/(cityinterface|CityInterface|Cityinterface|CityServer|PandaInformatization)/.test(
url,
)
) {
return /\/CityInterface\/rest\/services.svc\/GetConfig/.test(url)
? url
? /^\/GateWay/.test(url)
? url
: `/GateWay${url}`
: `/GateWay${url}`
: `/GateWay${url}`;
}
return url;
}
};
const codeMessage = {
200: '服务器成功返回请求的数据。',
201: '新建或修改数据成功。',
......@@ -40,7 +52,7 @@ const codeMessage = {
504: '网关超时。',
};
let instance = null;
const instance = null;
instanceRequest.setErrorHandler(error => {
const { response } = error;
if (response && response.status) {
......
import * as constants from '../../constants';
import { request } from '@wisdom-utils/utils';
import * as constants from '../../constants';
const API = {
GET_INFORMATION:
'/CityInterface/rest/services/CountyProduct.svc/SCADAOper/GetInformationInfo',
......
import 'whatwg-fetch';
import './public-path'
import './public-path';
import '!file-loader?name=[name].[ext]!./images/favicon.ico';
import './global.less';
import 'animate.css/animate.css';
......@@ -8,19 +8,19 @@ import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/e
import '@wisdom-utils/utils/lib/helpers/format';
import 'sanitize.css/sanitize.css';
import { event } from '@wisdom-utils/utils';
import _ from 'lodash';
import { ConfigProvider} from 'antd';
import { ConfigProvider } from 'antd';
import { Storeage } from '@wisdom-utils/utils/lib/helpers';
import { history } from '@wisdom-utils/runtime';
import { actionCreators } from './containers/App/store';
import { initGlobalConfig } from './initConfig'
import { initGlobalConfig } from './initConfig';
import './utils/event';
import store from './stores'
import store from './stores';
// eslint-disable-next-line no-restricted-globals
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
ConfigProvider.config({
prefixCls: 'panda-console-base'
prefixCls: 'panda-console-base',
});
const initLocale = () => {
localStorage.setItem('umi_locale', 'zh-CN');
......@@ -33,10 +33,10 @@ const unlisten = (function() {
let prePathname = '';
return history.listen(location => {
if (
location.pathname.indexOf('/civbase/user/login') > -1 &&
location.pathname.indexOf('/civbase/user/login') > -1 &&
location.pathname !== prePathname
) {
console.log('init config')
console.log('init config');
initGlobalConfig();
}
prePathname = location.pathname;
......@@ -44,5 +44,5 @@ const unlisten = (function() {
})();
event.on('event:logout', () => {
store.dispatch(actionCreators.logout())
store.dispatch(actionCreators.logout());
});
import React from 'react';
import { Redirect, Route } from 'umi';
import { Redirect, Route } from '@wisdom-utils/runtime';
import Authorized from './Authorized';
......
......@@ -11,12 +11,8 @@ import {
Upload,
} from 'antd';
import { withRouter } from 'react-router';
import Cookies from 'js-cookie';
import {
FormattedMessage,
useIntl,
} from '@/locales/localeExports';
import { request } from '@wisdom-utils/utils';
import { FormattedMessage, useIntl } from '@/locales/localeExports';
import { appService } from '../../api';
// eslint-disable-next-line import/named
......
......@@ -2,15 +2,15 @@ import React, { useState, useRef } from 'react';
import { message } from 'antd';
import _, { words } from 'lodash';
import { connect } from 'react-redux';
import { useIntl } from '@/locales/localeExports';
import Icon from '@ant-design/icons';
import classNames from 'classnames';
import { useHistory } from '@wisdom-utils/runtime';
import { useIntl } from '@/locales/localeExports';
import { actionCreators } from '../../containers/App/store';
import HeaderSearch from '../HeaderSearch';
import Avatar from './AvatarDropdown';
import styles from './index.less';
import NoticeIconView from './NoticeIconView';
import classNames from 'classnames';
import { useHistory } from '@wisdom-utils/runtime';
/* eslint-disable */
const orderSvg = () => (
<svg
......@@ -223,8 +223,8 @@ const GlobalHeaderRight = props => {
</div>
{
// 云平台去掉常用菜单
props.global && props.global.userInfo && props.global.userInfo.Groups && props.global.userInfo.Groups.length
? null
props.global && props.global.userInfo && props.global.userInfo.Groups && props.global.userInfo.Groups.length
? null
: (
<div className={classNames(styles.item)} onClick={handlerFavitor} ref={favitorRef}>
<FavitorIcon></FavitorIcon>
......
......@@ -3,10 +3,8 @@ import React, { useState } from 'react';
import { message } from 'antd';
import _ from 'lodash';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { useIntl } from '@/locales/localeExports';
import Icon from '@ant-design/icons';
import { useIntl } from '@/locales/localeExports';
import { actionCreators } from '../../containers/App/store';
import HeaderSearch from '../HeaderSearch';
......
......@@ -7,7 +7,7 @@ import React, {
import classNames from 'classnames';
import PinyinMatch from 'pinyin-match';
import { useHistory } from 'react-router-dom';
import { useHistory } from '@wisdom-utils/runtime';
import Icon, { RightCircleOutlined } from '@ant-design/icons';
......@@ -105,7 +105,7 @@ const SearchPanel = props => {
}
const goFeature = (path, rect, value) => {
// eslint-disable-next-line no-param-reassign
value = value || props.value;
const findKeywordIndex =
recentKeywords.length > 0
......@@ -126,10 +126,10 @@ const SearchPanel = props => {
const routes = props.menu[findIndex];
const selectedIndex = routes.routes.findIndex(item => item.name === rect.subSystem);
let currentPath = void 0;
// props.updateOpenKeys && props.updateOpenKeys([parents.key]);
if (rect && rect.routes && rect.routes.length > 0) {
if (rect && rect.routes && rect.routes.length > 0) {
currentPath = rect.routes[0].path;
} else {
currentPath = path;
......
......@@ -10,6 +10,7 @@ import useMergeValue from 'use-merge-value';
import { SearchOutlined } from '@ant-design/icons';
import styles from './index.less';
// eslint-disable-next-line import/no-unresolved
import SearchPanel from './Panel';
import ExtendPanel from './ExtendPanel';
......@@ -208,7 +209,7 @@ const HeaderSearch = props => {
console={willMenu}
/>
}
</div>
);
};
......
......@@ -3,41 +3,47 @@ import { Tooltip } from 'antd';
import { CheckOutlined } from '@ant-design/icons';
import classNames from 'classnames';
const BlockCheckbox = ({ value, configType, onChange, list = [], prefixCls }) => {
const baseClassName = `${prefixCls}-drawer-block-checkbox`;
const [dom, setDom] = useState([]);
useEffect(() => {
const domList = (list || []).map((item) => (
<Tooltip title={item.title} key={item.key}>
<div
className={classNames(
`${baseClassName}-item`,
`${baseClassName}-item-${item.key}`,
`${baseClassName}-${configType}-item`,
)}
onClick={() => onChange(item.key)}
>
<CheckOutlined
className={`${baseClassName}-selectIcon`}
style={{
display: value === item.key ? 'block' : 'none',
}}
/>
</div>
</Tooltip>
));
setDom(domList);
}, [value, list.length]);
return (
const BlockCheckbox = ({
value,
configType,
onChange,
list = [],
prefixCls,
}) => {
const baseClassName = `${prefixCls}-drawer-block-checkbox`;
const [dom, setDom] = useState([]);
useEffect(() => {
const domList = (list || []).map(item => (
<Tooltip title={item.title} key={item.key}>
<div
className={baseClassName}
style={{
minHeight: 42,
}}
className={classNames(
`${baseClassName}-item`,
`${baseClassName}-item-${item.key}`,
`${baseClassName}-${configType}-item`,
)}
onClick={() => onChange(item.key)}
>
{dom}
<CheckOutlined
className={`${baseClassName}-selectIcon`}
style={{
display: value === item.key ? 'block' : 'none',
}}
/>
</div>
);
</Tooltip>
));
setDom(domList);
}, [value, list.length, list, baseClassName, configType, onChange]);
return (
<div
className={baseClassName}
style={{
minHeight: 42,
}}
>
{dom}
</div>
);
};
export default BlockCheckbox;
\ No newline at end of file
export default BlockCheckbox;
import './index.less';
import {
CloseOutlined,
SettingOutlined,
} from '@ant-design/icons';
import { isBrowser } from '@ant-design/pro-utils';
import { useUrlSearchParams } from '@umijs/use-params';
import { Button, Divider, Drawer, List, Switch, message, Alert } from 'antd';
import { Divider, Drawer, message } from 'antd';
import React, { useState, useEffect, useRef } from 'react';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import merge from 'lodash.merge';
......@@ -21,7 +17,7 @@ import LayoutSetting, { renderLayoutSettingItem } from './LayoutChange';
import RegionalSetting from './RegionalChange';
const Body = ({ children, prefixCls, title }) => (
<div style={{ marginBottom: 24 }}>
<h3 className={`${prefixCls}-drawer-title`}>{title}</h3>
<h3 className={`${prefixCls}-drawer-title`}>{title}</h3>
{children}
</div>
);
......
import { isBrowser } from '@ant-design/pro-utils';
import zhLocal from './zh-CN';
const locales = {
'zh-CN': zhLocal
'zh-CN': zhLocal,
};
const getLanguage = () => {
......@@ -18,4 +18,4 @@ export default ()=> {
return locales[gLocale];
}
return locales['zh-CN'];
};
\ No newline at end of file
};
......@@ -2,14 +2,10 @@ import React, { Suspense } from 'react';
import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
// import { renderRoutes } from 'react-router-config';
import { Router, Switch, Route, Redirect } from '@wisdom-utils/runtime';
import { Router, Switch } from '@wisdom-utils/runtime';
import { renderRoutes } from '../../utils/routes';
// import BootPage from '../../pages/bootpage';
import { dyRoutes } from '../../routes/config';
// import routeContext from '@ant-design/pro-layout/lib/RouteContext';
// import { Route } from 'react-router-dom';
const pkg = require('../../../package.json');
const config = require('../../../config/config');
......
import Cookies from 'js-cookie';
import { appService } from './api';
import { initMicroApps } from './micro';
import { params, Storeage } from '@wisdom-utils/utils/lib/helpers';
import Cookies from 'js-cookie';
import { actionCreators } from './containers/App/store';
import { getToken, isString } 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 = () => {
......@@ -28,7 +29,7 @@ export const initGlobalConfig = () => {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
}
// eslint-disable-next-line no-undef
if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace);
......@@ -36,7 +37,7 @@ export const initGlobalConfig = () => {
if (!getToken()) {
localStorage.removeItem('loginSite');
}
if (window.globalConfig.token !== null && Object.keys(window.globalConfig).length > 0) {
store.dispatch(actionCreators.getConfig(window.globalConfig));
// render({ appContent: '', loading: true });
......@@ -83,21 +84,21 @@ export const initGlobalConfig = () => {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, data, {
token: '',
token: '',
access_token: '',
userInfo: null
}, gateWayConfig),
),
);
//Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
......@@ -119,7 +120,7 @@ export const initGlobalConfig = () => {
true,
);
}
// eslint-disable-next-line no-shadow
}
return res;
......@@ -139,4 +140,4 @@ export const initGlobalConfig = () => {
});
}
};
\ No newline at end of file
};
......@@ -6,14 +6,7 @@ import React, {
useState,
} from 'react';
import {
Anchor,
Button,
Popover,
Radio,
Result,
Spin,
} from 'antd';
import { Anchor, Button, Popover, Radio, Result, Spin } from 'antd';
import { store } from '@wisdom-utils/utils';
import classNames from 'classnames';
import Cookies from 'js-cookie';
......@@ -21,14 +14,6 @@ import { dom } from '@wisdom-utils/utils/lib/helpers';
import { connect } from 'react-redux';
import { useMountedState } from 'react-use';
import RightContent from '@/components/GlobalHeader/RightContent';
import { Panel } from '@/components/SliderPanel';
import { actionCreators } from '@/containers/App/store';
import Authorized from '@/utils/Authorized';
import {
findPathByLeafId,
getBaseName,
} from '@/utils/utils';
import {
LeftOutlined,
LoadingOutlined,
......@@ -36,9 +21,12 @@ import {
} from '@ant-design/icons';
import ProLayout, { getPageTitle } from '@ant-design/pro-layout';
import { getMatchMenu } from '@umijs/route-utils';
// import { renderRoutes } from 'react-router-config';
import { useHistory } from '@wisdom-utils/runtime';
import RightContent from '@/components/GlobalHeader/RightContent';
import { Panel } from '@/components/SliderPanel';
import { actionCreators } from '@/containers/App/store';
import Authorized from '@/utils/Authorized';
import { findPathByLeafId, getBaseName } from '@/utils/utils';
import pkg from '../../package.json';
import SecurityLayout from './SecurityLayout';
import Site from './Site';
......@@ -463,7 +451,7 @@ const BasicLayout = props => {
useEffect(() => {
siteAction.setGlobalConfig(props.global);
if (!Cookies.get('token')) {
let client = props.global.get('client');
client = _.isNull(client) || _.isUndefined(client) || client === 'undefined' ? client: 'city';
history.replace(`/user/login?client=${client}`);
......
import React, {
useCallback,
useEffect,
useRef,
useState,
......@@ -8,10 +7,8 @@ import React, {
import {
Anchor,
Button,
Popover,
Radio,
Result,
Spin,
Tabs,
Divider,
......@@ -19,10 +16,8 @@ import {
Menu,
Tooltip,
ConfigProvider,
Skeleton
Skeleton,
} from 'antd';
// import { RouteWithSubRoutes, renderRoutes } from '../utils/routes';
// import { renderRoutes } from 'react-router-config';
import { PageContainer } from '@ant-design/pro-layout';
import Icon, {
// LeftOutlined,
......@@ -35,19 +30,15 @@ import classNames from 'classnames';
import { ReactSVG } from 'react-svg';
import Cookies from 'js-cookie';
import { connect } from 'react-redux';
import { useHistory } from '@wisdom-utils/runtime';
import { useHistory } from '@wisdom-utils/runtime';
import KeepAlive from 'react-activation';
import AMapLoader from '@amap/amap-jsapi-loader';
import RightContent from '@/components/GlobalHeader/ExtendRightContent';
import Panel from '@/components/SliderPanel/MinPanel';
import { actionCreators } from '@/containers/App/store';
import CreateBaseMap from '@/pages/map';
import AMap from '@/pages/amap';
import CesiumMap from '@/pages/cesiumMap';
import KeepAlive from 'react-activation'
import AMapLoader from '@amap/amap-jsapi-loader';
import { WEB_GIS_TYPE } from '../constants'
// import Authorized from '@/utils/Authorized';
import { ArcgisMap, AMap, CesiumMap } from '../pages/map';
import { WEB_GIS_TYPE } from '../constants';
import { findPathByLeafId, getBaseName } from '@/utils/utils';
// import { renderRoutes } from 'react-router-config';
import { renderRoutes, getParams } from '../utils/routes';
import SecurityLayout from './SecurityLayout';
import Site from './Site';
......@@ -273,7 +264,7 @@ const BasicLayout = props => {
// 处理隐藏菜单
useEffect(() => {
const newRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex] || {};
if(!_.isEqual(currentRoutes, newRoutes)) {
setCurrentRoutes({})
......@@ -283,13 +274,13 @@ const BasicLayout = props => {
}, [props.route, props.currentMenuIndex]);
// let currentRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex];
//props.currentMenuIndex
useEffect(() => {
const initSelectRoute = findPathByLeafId(
`${props.location && props.location.pathname || ''}`,
[currentRoutes],
......@@ -316,7 +307,7 @@ const BasicLayout = props => {
currentChildrenRoute && currentChildrenRoute.routes ? setChildrenRoutes(currentChildrenRoute.routes) : setChildrenRoutes([currentChildrenRoute]);
} else {
let url = props.global && props.global.hasOwnProperty('get') && props.global.get('homepage')
let url = props.global && props.global.hasOwnProperty('get') && props.global.get('homepage')
? _.isString(props.global.get('homepage'))
? props.global.get('homepage')
: props.global.get('homepage.url')
......@@ -506,7 +497,7 @@ const BasicLayout = props => {
}
const handlerSelectMenu = ({ item, key, keyPath, domEvent }) => {
setSelectedKeys([key]);
window.history.pushState(null, '', `/civbase${key}`);
}
......@@ -630,11 +621,11 @@ const BasicLayout = props => {
</ul>
</React.Fragment>
}
</div>
}
</div>
<div className="ant-pro-sider-links" >
<ul className="ant-menu ant-menu-root ant-menu-inline ant-menu-dark ant-pro-sider-link-menu" role="menu" tabIndex="0" >
......@@ -730,14 +721,14 @@ const BasicLayout = props => {
}
{
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <CreateBaseMap options={{ type: 'ArcgisMap' }}/>)) : null
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <ArcgisMap options={{ type: 'ArcgisMap' }}/>)) : null
}
<div id="micro-container" className="subapp-container">
{props.children}
</div>
{props.children}
......@@ -754,8 +745,8 @@ const BasicLayout = props => {
}
{
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <CreateBaseMap options={{ type: 'ArcgisMap' }}/>)) : null
}
window.location.pathname.startsWith('/civbase/civ_3d') ? <KeepAlive><CesiumMap /></KeepAlive> : window.location.pathname.startsWith('/civbase/civ_webgis') ? ((mapMode === 'AMap' ? <AMap/>: <ArcgisMap options={{ type: 'ArcgisMap' }}/>)) : null
}
<div id="micro-container" className="subapp-container">
{/*<CreateBaseMap/>*/}
{props.children}
......
import React from 'react';
import {
Anchor,
message,
} from 'antd';
import { Anchor, message } from 'antd';
import classNames from 'classnames';
import { encode } from 'js-base64';
import Cookies from 'js-cookie';
......@@ -16,7 +13,6 @@ import Login from '../pages/user/login/login';
import styles from './UserLayout.less';
import { initMicroApps } from '@/micro';
const { Link } = Anchor;
const ERR_OK = '0000';
......@@ -211,7 +207,7 @@ class Site {
stations,
weathers: {
icon: `https://panda-water.cn/web4/assets/images/weather2/${imgPath}`,
text: text + " " + firtValue.temperatureFirst,
text: `${text} ${firtValue.temperatureFirst}`,
},
siteCityList: self.siteCityList,
citySelector: self.citySelector,
......@@ -321,7 +317,6 @@ class Site {
}
writeCookie(token, site) {
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......@@ -342,7 +337,6 @@ class Site {
const self = this;
self.props.updateCurrentIndex && self.props.updateCurrentIndex(-1);
const login = new Login(this.props, () => {
self.setLoading(false);
// eslint-disable-next-line no-unused-expressions
self.props.updateCurrentIndex && self.props.updateCurrentIndex(0);
......@@ -351,21 +345,23 @@ class Site {
// 切换站点后,重置掉三级菜单
const homeType = self.globalConfig.homeType || 'civweb4';
const homePath =
self.globalConfig.homepage
? self.globalConfig.homepage.startsWith(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', {
name: "首页",
path: homePath,
icon: null,
});
: `/${homeType}`;
window.share &&
window.share.event &&
window.share.event.emit('event:favitor', {
name: '首页',
path: homePath,
icon: null,
});
// 重新加载订阅消息铃铛
window.share && window.share.event && window.share.event.emit('reloadNotice');
window.share &&
window.share.event &&
window.share.event.emit('reloadNotice');
// window.history.replaceState(
// '',
......@@ -382,7 +378,12 @@ class Site {
self.props &&
self.props.updateComplexConfig &&
self.props.updateComplexConfig({});
self.props.history && self.props.history.push(self.globalConfig.homepage ? `/${self.globalConfig.homepage}` : `/?client=${self.globalConfig.client}`);
self.props.history &&
self.props.history.push(
self.globalConfig.homepage
? `/${self.globalConfig.homepage}`
: `/?client=${self.globalConfig.client}`,
);
// window.location.reload();
window.share.event.emit('triggerMicro', this.props.global);
});
......
......@@ -8,13 +8,13 @@ import {
setDefaultMountApp,
start,
} from 'qiankun';
import { event, store as microStore } from '@wisdom-utils/utils'
import { event, store as microStore } from '@wisdom-utils/utils';
import micorConfig, { genActiveRule } from '../config/micor';
import { actionCreators } from './containers/App/store';
import loader from './render';
import store from './stores';
import actions from './actions';
import { processComponentName } from './utils/utils'
import { processComponentName } from './utils/utils';
// eslint-disable-next-line no-undef
const Logger = logger('micro');
......
const mapSetting = {
zooms: [14],
mapSettings: {
mapStyle: 'amap://styles/74fae00a851749793870b658f9f22d55',
pipeStyle: 'image',
viewMode: '2D',
},
propertysName: ['所在位置', '开关状态', '编号', '口径'],
showSearchFileds: ['开关状态', '编号', '口径'],
showFileds: ['编号'],
contextMenu: true,
theme: 'dark',
radius: 120,
isEdit: false,
};
export default mapSetting;
\ No newline at end of file
import {PdRender, parseScheme} from '@wisdom-cesium/cesium'
import { useRef , useEffect } from 'react'
import { connect } from 'react-redux'
import { actionCreators } from '@/containers/App/store';
const cesiumMap = props => {
const ref = useRef(null)
const storeRef = useRef(null)
useEffect(() => {
const mapConfig3d = props.globalConfig?.mapConfig3d
if(!(props.globalConfig.mapsettings?.areasettings && globalConfig.mapsettings?.basemaps?.length > 0)) return
if(storeRef.current) return
const {widgets} = mapConfig3d
const schemes = parseScheme.parseSchemes(mapConfig3d)
const schemeData = parseScheme.parseDatas(schemes)
const pdView = new PdRender({
el: ref.current,
widgets,
...schemeData
})
storeRef.current = pdView
props.updatePdCesiumView(pdView)
}, [props.globalConfig?.mapConfig3d ?? {}])
return (<div style={{
inset: 0,
position : "absolute"
}} ref = {ref}></div>)
}
const mapStateToProps = state => ({
globalConfig : state.getIn(['global','globalConfig'])
})
const mapDispatchToProps = dispatch => ({
updatePdCesiumView(pdView) {
dispatch(actionCreators.updatePdCesiumView(pdView))
}
})
export default connect(mapStateToProps, mapDispatchToProps)(cesiumMap)
......@@ -6,9 +6,9 @@ import classnames from 'classnames';
import * as _ from 'lodash';
import PinyinMatch from 'pinyin-match';
import PandaEmpty from '@wisdom-components/empty';
import { useHistory } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store';
import { appService } from '@/api';
import { useHistory } from '@wisdom-utils/runtime';
import { savePagePartInfo } from '@/api/service/base';
import styles from './index.less';
......
const mapSetting = {
zooms: [14],
mapSettings: {
mapStyle: 'amap://styles/74fae00a851749793870b658f9f22d55',
pipeStyle: 'image',
viewMode: '2D',
},
propertysName: ['所在位置', '开关状态', '编号', '口径'],
showSearchFileds: ['开关状态', '编号', '口径'],
showFileds: ['编号'],
contextMenu: true,
theme: 'dark',
radius: 120,
isEdit: false,
};
export default mapSetting;
import React, { useEffect, useState } from 'react';
import React from 'react';
import { AMapScene } from '@wisdom-map/Amap';
import { connect } from 'react-redux';
import { store } from '@wisdom-utils/utils';
const AMap = (props) => {
const AMap = props => {
const getMap = (obj, current) => {
store.set('amapView', {
Amap:obj,
map:current
})
Amap: obj,
map: current,
});
props.updageAMapView({
Amap:obj,
map:current
Amap: obj,
map: current,
});
};
const mapOptions = {
config:props.global.mapsettings,
theme:'amap://styles/74fae00a851749793870b658f9f22d55'
}
config: props.global.mapsettings,
theme: 'amap://styles/74fae00a851749793870b658f9f22d55',
};
return (
<div style={{
<div
style={{
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
}}>
<AMapScene
{...mapOptions}
getMapInfo={getMap}
/>
}}
>
<AMapScene {...mapOptions} getMapInfo={getMap} />
</div>
);
};
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig'])
global: state.getIn(['global', 'globalConfig']),
});
const mapDispatchToProps = dispatch => ({
updageAMapView(amapView) {
// eslint-disable-next-line no-undef
dispatch(actionCreators.updageAMapView(amapView));
},
});
......@@ -50,7 +48,3 @@ export default connect(
mapStateToProps,
mapDispatchToProps,
)(AMap);
import React from 'react';
import _ from 'lodash';
import { connect } from 'react-redux';
import AMapLoader from '@amap/amap-jsapi-loader';
import { store } from '@wisdom-utils/utils';
import { actionCreators } from '@/containers/App/store';
import MapComponent from '@/components/mapView';
class CreateMap extends React.Component {
constructor(props) {
super(props);
this.mapManganerRef = React.createRef();
[
'_AMap_vectorlayer',
'_AMap_AMap.MouseTool',
'_AMap_AMap.DistrictSearch',
'_AMap_AMap.Autocomplete',
'_AMap_sync',
'_AMap_AMap.PlaceSearch',
'_AMap_wgl',
'_AMap_overlay',
'_AMap_mouse',
].forEach(item => {
localStorage.removeItem(item);
});
AMapLoader.reset();
}
getView = view => {
store.set('view', view);
this.props.updageMapView(view);
};
render() {
if (_.isNull(this.props.global.mapsettings.areasettings)) {
return null;
}
const props = {
loading: true,
config: this.props.global.mapsettings,
widgets: this.props.global.uiwidgets,
};
return (
<>
<MapComponent {...props} getMapInfo={this.getView} />
</>
);
}
}
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
});
const mapDispatchToProps = dispatch => ({
updageMapView(mapView) {
dispatch(actionCreators.updageMapView(mapView));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(CreateMap);
import { PdRender, parseScheme } from '@wisdom-cesium/cesium';
import { useRef, useEffect } from 'react';
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
const cesiumMap = props => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const ref = useRef(null);
// eslint-disable-next-line react-hooks/rules-of-hooks
const storeRef = useRef(null);
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
const mapConfig3d = props.globalConfig?.mapConfig3d;
if (
!(
props.globalConfig.mapsettings?.areasettings &&
// eslint-disable-next-line no-undef
globalConfig.mapsettings?.basemaps?.length > 0
)
)
return;
if (storeRef.current) return;
const { widgets } = mapConfig3d;
const schemes = parseScheme.parseSchemes(mapConfig3d);
const schemeData = parseScheme.parseDatas(schemes);
const pdView = new PdRender({
el: ref.current,
widgets,
...schemeData,
});
storeRef.current = pdView;
props.updatePdCesiumView(pdView);
}, [props]);
return (
// eslint-disable-next-line react/react-in-jsx-scope
<div
style={{
inset: 0,
position: 'absolute',
}}
ref={ref}
/>
);
};
const mapStateToProps = state => ({
globalConfig: state.getIn(['global', 'globalConfig']),
});
const mapDispatchToProps = dispatch => ({
updatePdCesiumView(pdView) {
dispatch(actionCreators.updatePdCesiumView(pdView));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(cesiumMap);
import React from 'react';
import _ from 'lodash'
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import MapComponent from '@/components/mapView';
import AMapLoader from '@amap/amap-jsapi-loader';
import { store } from '@wisdom-utils/utils';
class CreateMap extends React.Component {
constructor(props) {
super(props);
this.mapManganerRef = React.createRef();
['_AMap_vectorlayer', '_AMap_AMap.MouseTool', '_AMap_AMap.DistrictSearch', '_AMap_AMap.Autocomplete', '_AMap_sync', '_AMap_AMap.PlaceSearch', '_AMap_wgl', '_AMap_overlay', '_AMap_mouse'].forEach(item => {
localStorage.removeItem(item)
});
AMapLoader.reset();
}
getView = view => {
store.set('view', view);
this.props.updageMapView(view);
};
render() {
if(_.isNull(this.props.global.mapsettings.areasettings)) {
return null;
}
const props = {
loading: true,
config: this.props.global.mapsettings,
widgets: this.props.global.uiwidgets,
}
return (
<>
<MapComponent {...props}
getMapInfo={this.getView}
/>
</>
);
}
}
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig'])
});
const mapDispatchToProps = dispatch => ({
updageMapView(mapView) {
dispatch(actionCreators.updageMapView(mapView));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(CreateMap);
import ArcgisMap from './arcgis';
import AMap from './amap';
import CesiumMap from './cesiumMap';
export { ArcgisMap, AMap, CesiumMap };
import 'kit_logger';
import { params } from 'kit_utils';
import { params } from '@wisdom-utils/utils/lib/helpers';
import { message } from 'antd';
import { decode, encode } from 'js-base64';
import Cookies from 'js-cookie';
......@@ -14,17 +14,26 @@ import {
WX_REDIRECT_URI,
} from '@/constants';
import store from '@/stores';
import { DEFAULT_MQTT_PATH, DEFAULT_TCP_IP, DEFAULT_TCP_PORT, DEFAULT_PARSE_LEVEL } from '@/components/Notifier/constants';
import {
DEFAULT_MQTT_PATH,
DEFAULT_TCP_IP,
DEFAULT_TCP_PORT,
DEFAULT_PARSE_LEVEL,
} from '@/components/Notifier/constants';
// eslint-disable-next-line no-undef
const Logger = logger('login');
const getGlobalConfig = () => store.getState().toJS().global?.globalConfig ?? {};
const getGlobalConfig = () =>
store.getState().toJS().global?.globalConfig ?? {};
class Login {
constructor(props, callback, isInit) {
this.events = window.share.event;
this.globalConfig = props.global;
// this.updateConfig = props.updateConfig;
this.updateConfig = (config) => { props.updateConfig(config); this.globalConfig = getGlobalConfig(); }
this.updateConfig = config => {
props.updateConfig(config);
this.globalConfig = getGlobalConfig();
};
this.createContext = props.createContext;
this.history = props.history;
this.callback = callback;
......@@ -218,47 +227,60 @@ class Login {
client: self.globalConfig.client,
token,
'request.preventCache': Date.now(),
})
]).then(results => {
const res = results[0] ?? {};
if (res && res.say.statusCode === '0000') {
let mqttConfig = {
mqtt_mess: {},
mqtt_path: DEFAULT_MQTT_PATH,
nginxStart: false,
mqtt_IsSSL: true
};
if (Array.isArray(res.getMe) && res.getMe.length > 0) {
if (res.getMe[0]) {
const data = res.getMe[0];
mqttConfig.mqtt_IsSSL = data.IsSSL ? data.IsSSL : false;
mqttConfig.mqtt_mess.site_code = data.SiteCode || self.globalConfig.userInfo.site;
mqttConfig.mqtt_mess.TcpIP = data.TcpIP;
mqttConfig.mqtt_mess.TcpPort = data.TcpPort ? parseInt(data.TcpPort) : 8083;
mqttConfig.mqtt_mess.MessageLevel = data.MessageLevel ? data.MessageLevel : DEFAULT_PARSE_LEVEL;
if (data.NginxStart) {
mqttConfig.NginxStart = data.NginxStart;
mqttConfig.mqtt_mess.TcpIP = window.location.hostname;
mqttConfig.mqtt_mess.TcpPort = parseInt(window.location.port);
mqttConfig.mqtt_path = '/ws/';
}),
])
.then(results => {
const res = results[0] ?? {};
if (res && res.say.statusCode === '0000') {
const mqttConfig = {
mqtt_mess: {},
mqtt_path: DEFAULT_MQTT_PATH,
nginxStart: false,
mqtt_IsSSL: true,
};
if (Array.isArray(res.getMe) && res.getMe.length > 0) {
if (res.getMe[0]) {
const data = res.getMe[0];
mqttConfig.mqtt_IsSSL = data.IsSSL ? data.IsSSL : false;
mqttConfig.mqtt_mess.site_code =
data.SiteCode || self.globalConfig.userInfo.site;
mqttConfig.mqtt_mess.TcpIP = data.TcpIP;
mqttConfig.mqtt_mess.TcpPort = data.TcpPort
? parseInt(data.TcpPort)
: 8083;
mqttConfig.mqtt_mess.MessageLevel = data.MessageLevel
? data.MessageLevel
: DEFAULT_PARSE_LEVEL;
if (data.NginxStart) {
mqttConfig.NginxStart = data.NginxStart;
mqttConfig.mqtt_mess.TcpIP = window.location.hostname;
mqttConfig.mqtt_mess.TcpPort = parseInt(window.location.port);
mqttConfig.mqtt_path = '/ws/';
} else {
mqttConfig.nginxStart = data.NginxStart;
}
} else {
mqttConfig.nginxStart = data.NginxStart
mqttConfig.mqtt_mess.TcpIP = DEFAULT_TCP_IP;
mqttConfig.mqtt_mess.TcpPort = DEFAULT_TCP_PORT;
mqttConfig.mqtt_IsSSL = `${mqttConfig.mqtt_mess.TcpIP}:${
mqttConfig.mqtt_mess.TcpPort
}`;
}
}else {
mqttConfig.mqtt_mess.TcpIP = DEFAULT_TCP_IP;
mqttConfig.mqtt_mess.TcpPort = DEFAULT_TCP_PORT;
mqttConfig.mqtt_IsSSL = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort;
}
mqttConfig.mqtt_iotIP = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort;
mqttConfig.mqtt_iotIP = `${mqttConfig.mqtt_mess.TcpIP}:${
mqttConfig.mqtt_mess.TcpPort
}`;
self.globalConfig = Object.assign(self.globalConfig, { ...mqttConfig });
self.globalConfig = Object.assign(self.globalConfig, {
...mqttConfig,
});
}
} else {
Logger.info('获取mqtt服务器参数失败');
}
} else {
Logger.info('获取mqtt服务器参数失败');
}
return results;
}).then(results => {
return results;
})
.then(results => {
const response = results[1] ?? {};
const result =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
......@@ -284,7 +306,7 @@ class Login {
// eslint-disable-next-line no-prototype-builtins
if (self.globalConfig.hasOwnProperty('webConfig')) {
self.globalConfig = Object.assign(self.globalConfig ,{
self.globalConfig = Object.assign(self.globalConfig, {
// ...self.globalConfig,
...self.globalConfig.webConfig.basicConfig,
...self.globalConfig.webConfig.optionalConfig,
......
import 'kit_utils/lib/format';
import '@wisdom-utils/utils/lib/helpers/format';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { params } from 'kit_utils';
import React, { forwardRef, useEffect, useState } from 'react';
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 LoginAction from './login';
import { initMicroApps } from '../../../micro';
const Login = forwardRef((props, _ref) => {
const history = useHistory();
const [action, setAction] = useState(
() => new LoginAction(Object.assign({}, props, {history}), () => {}, true),
() =>
new LoginAction(Object.assign({}, props, { history }), () => {}, true),
);
useEffect(() => {
action.globalConfig = props.global;
}, [props.global]);
}, [action.globalConfig, props.global]);
useEffect(() => {
action &&
action.events.on('loginSuccess', event => {
//http://127.0.0.1:8080/civbase/civweb4/
// props.updateConfig(Object.assign({}, props.global, {
// homepage: params.getParams('redirect')
// }));
action.events.on('loginSuccess', event => {
// http://127.0.0.1:8080/civbase/civweb4/
// props.updateConfig(Object.assign({}, props.global, {
// homepage: params.getParams('redirect')
// }));
// props.history.push('/' + params.getParams('redirect'))
props.history.push(`/?client=${props.global.client}&generateType=${props.global.generateType}`);
// window.share.event.emit('triggerMicro', props.global);
initMicroApps();
});
}, [props.globalConfig && props.globalConfig.userInfo])
props.history.push(
`/?client=${props.global.client}&generateType=${
props.global.generateType
}`,
);
// window.share.event.emit('triggerMicro', props.global);
initMicroApps();
});
}, [action, props.global.client, props.global.generateType, props.history]);
return <div>{props.children}</div>;
});
......
......@@ -4,12 +4,10 @@ import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { Modal } from 'antd';
import classNames from 'classnames';
import { dom } from 'kit_utils';
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 { LOGIN_DISPLAY, LOGIN_WAY } from '@/constants';
import { actionCreators } from '@/containers/App/store';
import defaultSetting from '../../../../../config/defaultSetting';
import LoginAction from '../login';
......@@ -35,7 +33,8 @@ const Login = forwardRef((props, _ref) => {
const [visible, setVisible] = useState(false);
const history = useHistory();
const [action, setAction] = useState(
() => new LoginAction(Object.assign({}, props, {history}), setVisible, true),
() =>
new LoginAction(Object.assign({}, props, { history }), setVisible, true),
);
// useEffect(() => {
......@@ -76,7 +75,7 @@ const Login = forwardRef((props, _ref) => {
setVisible(false);
setSubmitting(false);
});
action &&
action &&
action.events.on('loginVisible', status => {
setVisible(status);
});
......
import 'kit_utils/lib/format';
import React, {
forwardRef,
useEffect,
useRef,
useState,
} from 'react';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import {
Alert,
Checkbox,
Form,
Modal,
Popover,
} from 'antd';
import { Alert, Checkbox, Form, Modal, Popover } from 'antd';
import classNames from 'classnames';
import { encode } from 'js-base64';
import Cookies from 'js-cookie';
import { dom } from 'kit_utils';
import QRCode from 'qrcode.react';
import {
Helmet,
HelmetProvider,
} from 'react-helmet-async';
import { dom } from '@wisdom-utils/utils/lib/helpers';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import {
LOGIN_DISPLAY,
LOGIN_WAY,
} from '@/constants';
import { LOGIN_DISPLAY, LOGIN_WAY } from '@/constants';
import { actionCreators } from '@/containers/App/store';
import {
FormattedMessage,
useIntl,
} from '@/locales/localeExports';
import { FormattedMessage, useIntl } from '@/locales/localeExports';
import defaultSetting from '../../../../../config/defaultSetting';
import LoginForm from '../components/Login';
......
import { store } from '@wisdom-utils/utils';
import { appService } from '../api';
store.on('event:route', (url) => {
history.pushState(null, `/civbase/${url}`, `/civbase/${url}`);
store.on('event:route', url => {
// eslint-disable-next-line no-restricted-globals
history.pushState(null, `/civbase/${url}`, `/civbase/${url}`);
});
window.share && window.share.event && window.share.event.on('event:logs', params => {
window.share &&
window.share.event &&
window.share.event.on('event:logs', params => {
delete params.site;
appService.pvLogs(params);
});
});
// store.on('event:logout', () => {
// window.globalConfig = {};
......
import { transformURL } from './utils';
import React from 'react';
import { guid, params, urlHelpers } from '@wisdom-utils/utils/lib/helpers';
import LoadingComponent from '@ant-design/pro-layout/es/PageLoading';
import {
dynamic
} from '@wisdom-utils/runtime';
import { dynamic } from '@wisdom-utils/runtime';
import { matchPath, Route, Switch} from 'react-router';
import React, { Suspense, Fragment } from 'react';
export const isURL = function(url) {
// eslint-disable-next-line no-useless-escape
return /^(http|https)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/.test(url);
};
const { getParamsV1 } = params;
const { isURL, isAbsoluteURL, getURL, transformURL } = urlHelpers
export const getParams = getParamsV1;
const DEFAULT_APPLICATION = 'civweb4';
/* eslint-disable */
export const guid = function(prefix) {
let date = new Date().getTime();
if (window.performance && typeof window.performance.now === 'function') {
date += performance.now();
}
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(
c,
) {
const r = (date + Math.random() * 16) % 16 | 0;
date = Math.floor(date / 16);
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
});
return prefix + uuid.replace(/-/g, '.') + new Date().getTime();
};
export function getParams(pathname) {
let ret = {};
const url = pathname ? pathname : decodeURIComponent(window.location.pathname);
if (url.indexOf('|') > -1) {
const params = url.split('|')[1];
params.split('&').map(item => ret[item.split("=")[0]] = item.split("=")[1])
return ret;
}
return ret;
}
function isAbsoluteURL(url) {
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
};
const level = 0;
const getURL = url => {
const i = url.indexOf('#');
const href = i >= 0 ? url.slice(0, i) : url;
return href;
};
const generRotes = (widgets, parent, level = 0) => {
......
const camelizeRE = /-(\w)/g
export function camelize (str) {
str = String(str)
return str.replace(camelizeRE, function (m, c) {
return c ? c.toUpperCase() : ''
})
}
export function kebab (str) {
str = String(str)
return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}
\ No newline at end of file
import Cookies from 'js-cookie';
import pathRegexp from 'path-to-regexp';
import { parse } from 'querystring';
import { camelize } from './strings';
import pkg from '../../package.json';
const { toString } = Object.prototype;
......@@ -86,14 +85,6 @@ export function findPathByLeafId(leafId, nodes, path, key, clear) {
}
}
export function transformURL(path) {
//civweb4/
// path = path.replace(/[(\\|)|(&)]widget=[0-9]*/, '');
const el = document.createElement('input');
el.value = path;
String.fromCharCode(92);
return el.value.replace(/\\/g, '/');
}
export function findPathByWidget(leafId, nodes, path, key) {
if (path === undefined) {
......@@ -168,14 +159,3 @@ export function getToken() {
export function setToken(token) {
Cookies.set(token);
}
export const closeTabAction = (history, returnUrl, callback) => {};
export function processComponentName(name, { prefix = '', firstUpperCase = false } = {}) {
const pureName = name;
let camelizeName = `${camelize(`${prefix}${pureName}`)}`
if (firstUpperCase) {
camelizeName = camelizeName.charAt(0).toUpperCase() + camelizeName.slice(1)
}
return camelizeName
}
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