Commit fc82af14 authored by 邓晓峰's avatar 邓晓峰

fix applayout

parent 4cfcff24
"use strict";
module.exports = {
dev: {
'/CityInterface': {
// target: 'http://192.168.10.150:8050',
target: 'https://panda-water.cn',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/CityInterface': '/CityInterface'
}
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'http://192.168.12.8:8098',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/cityinterface': '/cityinterface'
}
}
}
};
\ No newline at end of file
module.exports = {
dev: {
'/CityInterface': {
// target: 'http://192.168.10.150:8050',
target: 'https://panda-water.cn',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/CityInterface': '/CityInterface',
},
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'http://192.168.12.8:8098',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/cityinterface': '/cityinterface',
},
},
},
};
...@@ -6,13 +6,15 @@ var webpack = require('webpack'); ...@@ -6,13 +6,15 @@ var webpack = require('webpack');
var slash = require('slash2'); var slash = require('slash2');
var pkg = require('../../package.json');
module.exports = function (options) { module.exports = function (options) {
return { return {
mode: options.mode, mode: options.mode,
entry: options.entry, entry: options.entry,
output: Object.assign({ output: Object.assign({
path: path.resolve(process.cwd(), 'civweb'), path: path.resolve(process.cwd(), pkg.name.toLocaleLowerCase()),
publicPath: '/' publicPath: "/".concat(pkg.name.toLocaleLowerCase())
}, options.output), }, options.output),
// Merge with env dependent settings // Merge with env dependent settings
optimization: options.optimization, optimization: options.optimization,
...@@ -93,28 +95,29 @@ module.exports = function (options) { ...@@ -93,28 +95,29 @@ module.exports = function (options) {
// Inline files smaller than 10 kB // Inline files smaller than 10 kB
limit: 10 * 1024 limit: 10 * 1024
} }
}, { } // {
loader: 'image-webpack-loader', // loader: 'image-webpack-loader',
options: { // options: {
mozjpeg: { // mozjpeg: {
enabled: false // NOTE: mozjpeg is disabled as it causes errors in some Linux environments // enabled: false,
// Try enabling it in your environment by switching the config to: // // NOTE: mozjpeg is disabled as it causes errors in some Linux environments
// enabled: true, // // Try enabling it in your environment by switching the config to:
// progressive: true, // // enabled: true,
// // progressive: true,
}, // },
gifsicle: { // gifsicle: {
interlaced: false // interlaced: false,
}, // },
optipng: { // optipng: {
optimizationLevel: 7 // optimizationLevel: 7,
}, // },
pngquant: { // pngquant: {
quality: '65-90', // quality: '65-90',
speed: 4 // speed: 4,
} // },
} // },
}] // },
]
}, { }, {
test: /\.html$/, test: /\.html$/,
use: 'html-loader' use: 'html-loader'
......
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const slash = require('slash2'); const slash = require('slash2');
module.exports = options => ({ const pkg = require('../../package.json');
module.exports = (options) => ({
mode: options.mode, mode: options.mode,
entry: options.entry, entry: options.entry,
output: Object.assign( output: Object.assign(
{ {
path: path.resolve(process.cwd(), 'civweb'), path: path.resolve(process.cwd(), pkg.name.toLocaleLowerCase()),
publicPath: '/', publicPath: `/${pkg.name.toLocaleLowerCase()}`,
}, },
options.output, options.output,
), // Merge with env dependent settings ), // Merge with env dependent settings
...@@ -42,7 +43,6 @@ module.exports = options => ({ ...@@ -42,7 +43,6 @@ module.exports = options => ({
loader: 'css-loader', loader: 'css-loader',
options: { options: {
modules: { modules: {
// localIdentName: '[name]__[local]___[hash:base64:5]' // localIdentName: '[name]__[local]___[hash:base64:5]'
// modules: true, // modules: true,
getLocalIdent: (context, _, localName) => { getLocalIdent: (context, _, localName) => {
...@@ -60,15 +60,17 @@ module.exports = options => ({ ...@@ -60,15 +60,17 @@ module.exports = options => ({
const antdProPath = match[1].replace('.less', ''); const antdProPath = match[1].replace('.less', '');
const arr = slash(antdProPath) const arr = slash(antdProPath)
.split('/') .split('/')
.map(a => a.replace(/([A-Z])/g, '-$1')) .map((a) => a.replace(/([A-Z])/g, '-$1'))
.map(a => a.toLowerCase()); .map((a) => a.toLowerCase());
return `panda-pro${arr.join('-')}-${localName}`.replace(/--/g, '-'); return `panda-pro${arr.join('-')}-${localName}`.replace(
/--/g,
'-',
);
} }
return localName; return localName;
}, },
} },
}, },
}, },
{ {
...@@ -111,28 +113,28 @@ module.exports = options => ({ ...@@ -111,28 +113,28 @@ module.exports = options => ({
limit: 10 * 1024, limit: 10 * 1024,
}, },
}, },
{ // {
loader: 'image-webpack-loader', // loader: 'image-webpack-loader',
options: { // options: {
mozjpeg: { // mozjpeg: {
enabled: false, // enabled: false,
// NOTE: mozjpeg is disabled as it causes errors in some Linux environments // // NOTE: mozjpeg is disabled as it causes errors in some Linux environments
// Try enabling it in your environment by switching the config to: // // Try enabling it in your environment by switching the config to:
// enabled: true, // // enabled: true,
// progressive: true, // // progressive: true,
}, // },
gifsicle: { // gifsicle: {
interlaced: false, // interlaced: false,
}, // },
optipng: { // optipng: {
optimizationLevel: 7, // optimizationLevel: 7,
}, // },
pngquant: { // pngquant: {
quality: '65-90', // quality: '65-90',
speed: 4, // speed: 4,
}, // },
}, // },
}, // },
], ],
}, },
{ {
......
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var getNotices = function getNotices(req, res) {
res.json([{
id: '000000001',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '你收到了 14 份新周报',
datetime: '2017-08-09',
type: 'notification'
}, {
id: '000000002',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
title: '你推荐的 曲妮妮 已通过第三轮面试',
datetime: '2017-08-08',
type: 'notification'
}, {
id: '000000003',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
title: '这种模板可以区分多种通知类型',
datetime: '2017-08-07',
read: true,
type: 'notification'
}, {
id: '000000004',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
title: '左侧图标用于区分不同的类型',
datetime: '2017-08-07',
type: 'notification'
}, {
id: '000000005',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '内容不要超过两行字,超出时自动截断',
datetime: '2017-08-07',
type: 'notification'
}, {
id: '000000006',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '曲丽丽 评论了你',
description: '描述信息描述信息描述信息',
datetime: '2017-08-07',
type: 'message',
clickClose: true
}, {
id: '000000007',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '朱偏右 回复了你',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true
}, {
id: '000000008',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '标题',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true
}, {
id: '000000009',
title: '任务名称',
description: '任务需要在 2017-01-12 20:00 前启动',
extra: '未开始',
status: 'todo',
type: 'event'
}, {
id: '000000010',
title: '第三方紧急代码变更',
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
extra: '马上到期',
status: 'urgent',
type: 'event'
}, {
id: '000000011',
title: '信息安全考试',
description: '指派竹尔于 2017-01-09 前完成更新并发布',
extra: '已耗时 8 天',
status: 'doing',
type: 'event'
}, {
id: '000000012',
title: 'ABCD 版本发布',
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
extra: '进行中',
status: 'processing',
type: 'event'
}]);
};
var _default = {
'GET /api/notices': getNotices
};
exports["default"] = _default;
\ No newline at end of file
const getNotices = (req, res) => {
res.json([
{
id: '000000001',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '你收到了 14 份新周报',
datetime: '2017-08-09',
type: 'notification',
},
{
id: '000000002',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
title: '你推荐的 曲妮妮 已通过第三轮面试',
datetime: '2017-08-08',
type: 'notification',
},
{
id: '000000003',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
title: '这种模板可以区分多种通知类型',
datetime: '2017-08-07',
read: true,
type: 'notification',
},
{
id: '000000004',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
title: '左侧图标用于区分不同的类型',
datetime: '2017-08-07',
type: 'notification',
},
{
id: '000000005',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '内容不要超过两行字,超出时自动截断',
datetime: '2017-08-07',
type: 'notification',
},
{
id: '000000006',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '曲丽丽 评论了你',
description: '描述信息描述信息描述信息',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000007',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '朱偏右 回复了你',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000008',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '标题',
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
{
id: '000000009',
title: '任务名称',
description: '任务需要在 2017-01-12 20:00 前启动',
extra: '未开始',
status: 'todo',
type: 'event',
},
{
id: '000000010',
title: '第三方紧急代码变更',
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
extra: '马上到期',
status: 'urgent',
type: 'event',
},
{
id: '000000011',
title: '信息安全考试',
description: '指派竹尔于 2017-01-09 前完成更新并发布',
extra: '已耗时 8 天',
status: 'doing',
type: 'event',
},
{
id: '000000012',
title: 'ABCD 版本发布',
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
extra: '进行中',
status: 'processing',
type: 'event',
},
]);
};
export default {
'GET /api/notices': getNotices,
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "CivWeb", "name": "CivBase",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "",
"repository": { "repository": {
...@@ -96,8 +96,10 @@ ...@@ -96,8 +96,10 @@
"intl": "1.2.5", "intl": "1.2.5",
"invariant": "2.2.4", "invariant": "2.2.4",
"ip": "1.1.5", "ip": "1.1.5",
"kit_global_config": "git+https://g.civnet.cn:8443/test/kit_global_config.git", "js-base64": "^3.5.2",
"kit_utils": "git+https://g.civnet.cn:8443/test/kit-utils.git", "js-cookie": "^2.2.1",
"kit_global_config": "^1.0.5",
"kit_utils": "^1.3.6",
"lodash": "4.17.11", "lodash": "4.17.11",
"minimist": "1.2.0", "minimist": "1.2.0",
"prop-types": "15.7.2", "prop-types": "15.7.2",
...@@ -106,17 +108,18 @@ ...@@ -106,17 +108,18 @@
"react-helmet": "6.0.0-beta", "react-helmet": "6.0.0-beta",
"react-intl": "2.8.0", "react-intl": "2.8.0",
"react-redux": "7.0.2", "react-redux": "7.0.2",
"react-router-dom": "5.0.0", "react-router-dom": "5.1.0",
"redux": "4.0.1", "redux": "4.0.1",
"redux-saga": "1.0.2", "redux-saga": "1.0.2",
"reselect": "4.0.0", "reselect": "4.0.0",
"sanitize.css": "8.0.0", "sanitize.css": "8.0.0",
"sha1": "^1.1.1",
"styled-components": "4.2.0", "styled-components": "4.2.0",
"use-merge-value": "^1.0.2" "use-merge-value": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@ant-design/icons": "^4.0.0", "@ant-design/icons": "^4.0.0",
"@ant-design/pro-layout": "^6.5.4", "@ant-design/pro-layout": "^6.5.10",
"@ant-design/pro-table": "^2.5.3", "@ant-design/pro-table": "^2.5.3",
"@babel/cli": "7.4.3", "@babel/cli": "7.4.3",
"@babel/core": "7.4.3", "@babel/core": "7.4.3",
...@@ -147,6 +150,7 @@ ...@@ -147,6 +150,7 @@
"classnames": "^2.2.6", "classnames": "^2.2.6",
"compare-versions": "3.4.0", "compare-versions": "3.4.0",
"compression-webpack-plugin": "2.0.0", "compression-webpack-plugin": "2.0.0",
"connect-api-mocker": "^1.9.0",
"conventional-changelog-cli": "^2.1.0", "conventional-changelog-cli": "^2.1.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"coveralls": "3.0.3", "coveralls": "3.0.3",
...@@ -164,20 +168,22 @@ ...@@ -164,20 +168,22 @@
"eslint-plugin-react": "7.12.4", "eslint-plugin-react": "7.12.4",
"eslint-plugin-react-hooks": "1.6.0", "eslint-plugin-react-hooks": "1.6.0",
"eslint-plugin-redux-saga": "1.0.0", "eslint-plugin-redux-saga": "1.0.0",
"express": "^4.17.1",
"file-loader": "3.0.1", "file-loader": "3.0.1",
"html-loader": "0.5.5", "html-loader": "0.5.5",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
"http-proxy-middleware": "^1.0.5", "http-proxy-middleware": "^1.0.5",
"husky": "^2.3.0", "husky": "^2.3.0",
"image-webpack-loader": "4.6.0",
"imports-loader": "0.8.0", "imports-loader": "0.8.0",
"jest-cli": "24.7.1", "jest-cli": "24.7.1",
"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",
"less": "3.12.0", "less": "3.12.0",
"less-loader": "5.0.0", "less-loader": "5.0.0",
"lint-staged": "8.1.5", "lint-staged": "8.1.5",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"mockjs": "^1.0.1-beta3",
"moment": "^2.25.3", "moment": "^2.25.3",
"ngrok": "3.1.1", "ngrok": "3.1.1",
"node-plop": "0.18.0", "node-plop": "0.18.0",
...@@ -192,7 +198,7 @@ ...@@ -192,7 +198,7 @@
"postcss-safe-parser": "4.0.2", "postcss-safe-parser": "4.0.2",
"pre-commit": "1.2.2", "pre-commit": "1.2.2",
"prettier": "1.17.0", "prettier": "1.17.0",
"qiankun": "^2.0.25", "qiankun": "^2.2.2",
"qs": "^6.9.0", "qs": "^6.9.0",
"react": "^16.8.6", "react": "^16.8.6",
"react-app-polyfill": "0.2.2", "react-app-polyfill": "0.2.2",
......
"use strict";
/* eslint consistent-return:0 import/order:0 */
var express = require('express');
var logger = require('./logger');
var argv = require('./argv');
var port = require('./port');
var setup = require('./middlewares/frontendMiddleware');
var isDev = process.env.NODE_ENV !== 'production';
var pkg = require('../package.json');
var ngrok = isDev && process.env.ENABLE_TUNNEL || argv.tunnel ? require('ngrok') : false;
var _require = require('path'),
resolve = _require.resolve;
var app = express();
setup(app, {
outputPath: resolve(process.cwd(), pkg.name.toLocaleLowerCase()),
publicPath: "/".concat(pkg.name.toLocaleLowerCase())
});
var customHost = argv.host || process.env.HOST;
var host = customHost || null;
var prettyHost = customHost || 'localhost'; // use the gzipped bundle
app.get('*.js', function (req, res, next) {
req.url = req.url + '.gz'; // eslint-disable-line
res.set('Content-Encoding', 'gzip');
next();
}); // Start your app.
app.listen(port, host, function _callee(err) {
var url;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!err) {
_context.next = 2;
break;
}
return _context.abrupt("return", logger.error(err.message));
case 2:
if (!ngrok) {
_context.next = 15;
break;
}
_context.prev = 3;
_context.next = 6;
return regeneratorRuntime.awrap(ngrok.connect(port));
case 6:
url = _context.sent;
_context.next = 12;
break;
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](3);
return _context.abrupt("return", logger.error(_context.t0));
case 12:
logger.appStarted(port, prettyHost, url);
_context.next = 16;
break;
case 15:
logger.appStarted(port, prettyHost);
case 16:
case "end":
return _context.stop();
}
}
}, null, null, [[3, 9]]);
});
\ No newline at end of file
"use strict";
/* eslint-disable no-console */
var chalk = require('chalk');
var ip = require('ip');
var pkg = require('../package.json');
var divider = chalk.gray('\n-----------------------------------');
/**
* Logger middleware, you can customize it to make messages more personal
*/
var logger = {
// Called whenever there's an error on the server we want to print
error: function error(err) {
console.error(chalk.red(err));
},
// Called when express.js app starts on given port w/o errors
appStarted: function appStarted(port, host, tunnelStarted) {
console.log("Server started ! ".concat(chalk.green('✓'))); // If the tunnel started, log that and the URL it's available at
if (tunnelStarted) {
console.log("Tunnel initialised ".concat(chalk.green('✓')));
}
console.log("\n".concat(chalk.bold('Access URLs:')).concat(divider, "\nLocalhost: ").concat(chalk.magenta("http://".concat(host, ":").concat(port, "/").concat(pkg.name.toLocaleLowerCase())), "\n LAN: ").concat(chalk.magenta("http://".concat(ip.address(), ":").concat(port, "/").concat(pkg.name.toLocaleLowerCase())) + (tunnelStarted ? "\n Proxy: ".concat(chalk.magenta(tunnelStarted)) : '')).concat(divider, "\n").concat(chalk.blue("Press ".concat(chalk.italic('CTRL-C'), " to stop")), "\n "));
}
};
module.exports = logger;
\ No newline at end of file
...@@ -7,6 +7,7 @@ const argv = require('./argv'); ...@@ -7,6 +7,7 @@ const argv = require('./argv');
const port = require('./port'); const port = require('./port');
const setup = require('./middlewares/frontendMiddleware'); const setup = require('./middlewares/frontendMiddleware');
const isDev = process.env.NODE_ENV !== 'production'; const isDev = process.env.NODE_ENV !== 'production';
const pkg = require('../package.json');
const ngrok = const ngrok =
(isDev && process.env.ENABLE_TUNNEL) || argv.tunnel (isDev && process.env.ENABLE_TUNNEL) || argv.tunnel
? require('ngrok') ? require('ngrok')
...@@ -14,18 +15,13 @@ const ngrok = ...@@ -14,18 +15,13 @@ const ngrok =
const { resolve } = require('path'); const { resolve } = require('path');
const app = express(); const app = express();
// If you need a backend, e.g. an API, add your custom backend-specific middleware here
// app.use('/api', myApi);
// In production we need to pass these values in instead of relying on webpack
setup(app, { setup(app, {
outputPath: resolve(process.cwd(), 'build'), outputPath: resolve(process.cwd(), pkg.name.toLocaleLowerCase()),
publicPath: '/', publicPath: `/${pkg.name.toLocaleLowerCase()}`,
}); });
// get the intended host and port number, use localhost and port 3000 if not provided
const customHost = argv.host || process.env.HOST; const customHost = argv.host || process.env.HOST;
const host = customHost || null; // Let http.Server use its default IPv6/4 host const host = customHost || null;
const prettyHost = customHost || 'localhost'; const prettyHost = customHost || 'localhost';
// use the gzipped bundle // use the gzipped bundle
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
const chalk = require('chalk'); const chalk = require('chalk');
const ip = require('ip'); const ip = require('ip');
const pkg = require('../package.json');
const divider = chalk.gray('\n-----------------------------------'); const divider = chalk.gray('\n-----------------------------------');
/** /**
...@@ -25,8 +25,12 @@ const logger = { ...@@ -25,8 +25,12 @@ const logger = {
console.log(` console.log(`
${chalk.bold('Access URLs:')}${divider} ${chalk.bold('Access URLs:')}${divider}
Localhost: ${chalk.magenta(`http://${host}:${port}`)} Localhost: ${chalk.magenta(
LAN: ${chalk.magenta(`http://${ip.address()}:${port}`) + `http://${host}:${port}/${pkg.name.toLocaleLowerCase()}`,
)}
LAN: ${chalk.magenta(
`http://${ip.address()}:${port}/${pkg.name.toLocaleLowerCase()}`,
) +
(tunnelStarted (tunnelStarted
? `\n Proxy: ${chalk.magenta(tunnelStarted)}` ? `\n Proxy: ${chalk.magenta(tunnelStarted)}`
: '')}${divider} : '')}${divider}
......
const path = require('path'); const path = require('path');
const express = require('express'); const express = require('express');
const compression = require('compression'); const compression = require('compression');
const pkg = require('../../package.json');
module.exports = function addProdMiddlewares(app, options) { module.exports = function addProdMiddlewares(app, options) {
const publicPath = options.publicPath || '/'; const publicPath = options.publicPath || pkg.name.toLocaleLowerCase() || '/';
const outputPath = options.outputPath || path.resolve(process.cwd(), 'build'); const outputPath =
options.outputPath ||
path.resolve(process.cwd(), pkg.name.toLocaleLowerCase());
// compression middleware compresses your server responses which makes them // compression middleware compresses your server responses which makes them
// smaller (applies also to assets). You can read more about that technique // smaller (applies also to assets). You can read more about that technique
......
"use strict";
var path = require('path');
var express = require('express');
var compression = require('compression');
var pkg = require('../../package.json');
module.exports = function addProdMiddlewares(app, options) {
var publicPath = options.publicPath || pkg.name.toLocaleLowerCase() || '/';
var outputPath = options.outputPath || path.resolve(process.cwd(), pkg.name.toLocaleLowerCase()); // compression middleware compresses your server responses which makes them
// smaller (applies also to assets). You can read more about that technique
// and other good practices on official Express.js docs http://mxs.is/googmy
app.use(compression());
app.use(publicPath, express["static"](outputPath));
app.get('*', function (req, res) {
return res.sendFile(path.resolve(outputPath, 'index.html'));
});
};
\ No newline at end of file
...@@ -5,35 +5,20 @@ ...@@ -5,35 +5,20 @@
/** /**
* Front-end middleware * Front-end middleware
*/ */
var proxyConfig = require('../../config/proxy');
var fs = require('fs');
var path = require('path');
var apiMocker = require('connect-api-mocker');
module.exports = function (app, options) { module.exports = function (app, options) {
var isProd = process.env.NODE_ENV === 'production'; var isProd = process.env.NODE_ENV === 'production';
var _require = require('http-proxy-middleware'), var _require = require('http-proxy-middleware'),
createProxyMiddleware = _require.createProxyMiddleware; createProxyMiddleware = _require.createProxyMiddleware;
var apiProxy = createProxyMiddleware('/CityInterface', {
target: 'http://192.168.10.150:8050',
// target: 'https://panda-water.cn',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/CityInterface': '/CityInterface'
}
});
var apiProxy2 = createProxyMiddleware('/cityinterface', {
target: 'http://192.168.10.150:8050',
// target: 'https://panda-water.cn',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/cityinterface': '/cityinterface'
}
});
if (isProd) { if (isProd) {
var addProdMiddlewares = require('./addProdMiddlewares'); var addProdMiddlewares = require('./addProdMiddlewares');
...@@ -43,8 +28,9 @@ module.exports = function (app, options) { ...@@ -43,8 +28,9 @@ module.exports = function (app, options) {
var addDevMiddlewares = require('./addDevMiddlewares'); var addDevMiddlewares = require('./addDevMiddlewares');
app.use(apiProxy); Object.keys(proxyConfig.dev).forEach(function (item) {
app.use(apiProxy2); app.use(createProxyMiddleware(item, proxyConfig.dev[item]));
});
addDevMiddlewares(app, webpackConfig); addDevMiddlewares(app, webpackConfig);
} }
......
...@@ -3,32 +3,13 @@ ...@@ -3,32 +3,13 @@
/** /**
* Front-end middleware * Front-end middleware
*/ */
const proxyConfig = require('../../config/proxy');
const fs = require('fs');
const path = require('path');
const apiMocker = require('connect-api-mocker');
module.exports = (app, options) => { module.exports = (app, options) => {
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
const { createProxyMiddleware } = require('http-proxy-middleware'); const { createProxyMiddleware } = require('http-proxy-middleware');
const apiProxy = createProxyMiddleware('/CityInterface', {
target: 'http://192.168.10.150:8050',
// target: 'https://panda-water.cn',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/CityInterface': '/CityInterface'
}
});
const apiProxy2 = createProxyMiddleware('/cityinterface', {
target: 'http://192.168.10.150:8050',
// target: 'https://panda-water.cn',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/cityinterface': '/cityinterface'
}
})
if (isProd) { if (isProd) {
const addProdMiddlewares = require('./addProdMiddlewares'); const addProdMiddlewares = require('./addProdMiddlewares');
...@@ -36,8 +17,11 @@ const apiProxy2 = createProxyMiddleware('/cityinterface', { ...@@ -36,8 +17,11 @@ const apiProxy2 = createProxyMiddleware('/cityinterface', {
} else { } else {
const webpackConfig = require('../../internals/webpack/webpack.dev.babel'); const webpackConfig = require('../../internals/webpack/webpack.dev.babel');
const addDevMiddlewares = require('./addDevMiddlewares'); const addDevMiddlewares = require('./addDevMiddlewares');
app.use(apiProxy)
app.use(apiProxy2) Object.keys(proxyConfig.dev).forEach(item => {
app.use(createProxyMiddleware(item, proxyConfig.dev[item]));
});
addDevMiddlewares(app, webpackConfig); addDevMiddlewares(app, webpackConfig);
} }
......
import axios from 'axios'; import axios from 'axios';
import uuid from 'uuid'; import uuid from 'uuid';
const baseURL = process.env.NODE_ENV === 'development' ? window.location.origin : ''; const baseURL =
process.env.NODE_ENV === 'development' ? window.location.origin : '';
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
let pending = []; //声明一个数组用于存储每个ajax请求的取消函数和ajax标识 let pending = []; //声明一个数组用于存储每个ajax请求的取消函数和ajax标识
let cancelToken = axios.CancelToken; let cancelToken = axios.CancelToken;
class HttpRequest { class HttpRequest {
...@@ -13,22 +13,24 @@ class HttpRequest { ...@@ -13,22 +13,24 @@ class HttpRequest {
baseURL, baseURL,
timeout: 30000, timeout: 30000,
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8' 'Content-Type': 'application/json;charset=UTF-8',
} },
}); });
this.requestApi.interceptors.request.use( this.requestApi.interceptors.request.use(
(config)=> { config => {
// if(config.params&&config.params.cancelAllRequest){ // if(config.params&&config.params.cancelAllRequest){
// removeAllPending() // removeAllPending()
// } // }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
debugger;
if (this.getSite()) {
config.headers['Civ-Site'] = this.getSite();
}
this.removePending(config); //在一个ajax发送前执行一下取消操作 this.removePending(config); //在一个ajax发送前执行一下取消操作
config.cancelToken = new cancelToken((c)=>{ config.cancelToken = new cancelToken(c => {
let uid = uuid.v1() let uid = uuid.v1();
config.uuid = uid config.uuid = uid;
pending.push({ uuid:uid, f: c }); pending.push({ uuid: uid, f: c });
}); });
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
return config; return config;
...@@ -39,7 +41,7 @@ class HttpRequest { ...@@ -39,7 +41,7 @@ class HttpRequest {
); );
this.requestApi.interceptors.response.use( this.requestApi.interceptors.response.use(
(response)=> { response => {
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
this.removePending(response.config); //在一个ajax响应后再执行一下取消操作,把已经完成的请求从pending中移除 this.removePending(response.config); //在一个ajax响应后再执行一下取消操作,把已经完成的请求从pending中移除
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -49,7 +51,7 @@ class HttpRequest { ...@@ -49,7 +51,7 @@ class HttpRequest {
return response; return response;
}, },
function(error) { function(error) {
console.log(error) console.log(error);
if (error && error.response) { if (error && error.response) {
switch (error.response.status) { switch (error.response.status) {
case 400: case 400:
...@@ -98,34 +100,63 @@ class HttpRequest { ...@@ -98,34 +100,63 @@ class HttpRequest {
}, },
); );
} }
removePending = (ever) => { removePending = ever => {
for(let p in pending){ for (let p in pending) {
if(pending[p].uuid === ever.uuid) { //当当前请求在数组中存在时执行函数体 if (pending[p].uuid === ever.uuid) {
//当当前请求在数组中存在时执行函数体
pending[p].f(); //执行取消操作 pending[p].f(); //执行取消操作
pending.splice(p, 1); //把这条记录从数组中移除 pending.splice(p, 1); //把这条记录从数组中移除
} }
} }
} };
removeAllPending = () => { removeAllPending = () => {
for(let p in pending){ for (let p in pending) {
pending[p].f(); //执行取消操作 pending[p].f(); //执行取消操作
pending.splice(p, 1); //把这条记录从数组中移除 pending.splice(p, 1); //把这条记录从数组中移除
} }
};
getSite() {
return (
(window.globalConfig &&
window.globalConfig.userInfo &&
window.globalConfig.userInfo.site) ||
''
);
} }
get(url, params, config={}) { get(url, params, config = {}) {
return this.requestApi.get(url, {...config, params}); params = this.getSite()
? Object.assign({}, params, {
site: this.getSite(),
})
: params;
return this.requestApi.get(url, { ...config, params });
} }
post(url, data, config ={}) { post(url, data, config = {}) {
data = this.getSite()
? Object.assign({}, data, {
site: this.getSite(),
})
: data;
return this.requestApi.post(url, { ...data, ...config }); return this.requestApi.post(url, { ...data, ...config });
} }
delete(url, params, config ={} ) { delete(url, params, config = {}) {
return this.requestApi.delete(url, {...config, params}) params = this.getSite()
? Object.assign({}, params, {
site: this.getSite(),
})
: params;
return this.requestApi.delete(url, { ...config, params });
} }
put(url, params, config ={}) { put(url, params, config = {}) {
return this.requestApi.delete(url, params, config) params = this.getSite()
? Object.assign({}, params, {
site: this.getSite(),
})
: params;
return this.requestApi.delete(url, params, config);
} }
} }
......
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = jsonp;
exports.param = param;
var _jsonp = _interopRequireDefault(require("jsonp"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function jsonp(url, data, option) {
url += (url.indexOf('?') < 0 ? '?' : '&') + param(data);
return new Promise(function (resolve, reject) {
(0, _jsonp["default"])(url, option, function (err, data) {
if (!err) {
resolve(data);
} else {
reject(err);
}
});
});
}
function param(data) {
var url = '';
for (var k in data) {
var value = data[k] !== undefined ? data[k] : '';
url += '&' + k + '=' + encodeURIComponent(value);
}
return url ? url.substring(1) : '';
}
\ No newline at end of file
import jsonp from './jsonpConfig';
export function searchAutoCity(keywords) {
const url = 'https://restapi.amap.com/v3/assistant/inputtips';
const options = {
callback: `jsonp_${new Date().getTime()}`,
};
const params = Object.assign(
{},
{
s: 'rsv3',
key: 'e83f64300a2a55a33fa8e4ab9a46bca6',
platform: 'JS',
logversion: '2.0',
csid: '5A098355-8164-41D5-A2DC-78E1471CCD28',
appname: window.location.href,
sdkversion: '1.4.15',
keywords: keywords,
},
);
return jsonp(url, params, options);
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.searchAutoCity = searchAutoCity;
var _jsonpConfig = _interopRequireDefault(require("./jsonpConfig"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function searchAutoCity(keywords) {
var url = 'https://restapi.amap.com/v3/assistant/inputtips';
var options = {
callback: "jsonp_".concat(new Date().getTime())
};
var params = Object.assign({}, {
s: 'rsv3',
key: 'e83f64300a2a55a33fa8e4ab9a46bca6',
platform: 'JS',
logversion: '2.0',
csid: '5A098355-8164-41D5-A2DC-78E1471CCD28',
appname: window.location.href,
sdkversion: '1.4.15',
keywords: keywords
});
return (0, _jsonpConfig["default"])(url, params, options);
}
\ No newline at end of file
import originJsonp from 'jsonp';
export default function jsonp(url, data, option) {
url += (url.indexOf('?') < 0 ? '?' : '&') + param(data);
return new Promise((resolve, reject) => {
originJsonp(url, option, (err, data) => {
if (!err) {
resolve(data);
} else {
reject(err);
}
});
});
}
export function param(data) {
let url = '';
for (var k in data) {
let value = data[k] !== undefined ? data[k] : '';
url += '&' + k + '=' + encodeURIComponent(value);
}
return url ? url.substring(1) : '';
}
...@@ -16,23 +16,17 @@ import { ...@@ -16,23 +16,17 @@ import {
params, params,
Storeage, Storeage,
} from 'kit_utils'; } from 'kit_utils';
import {
addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted,
setDefaultMountApp,
start,
} from 'qiankun';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import Http from './api'; import Http from './api';
import configureStore from './configureStore'; import configureStore from './configureStore';
import App from './containers/App'; import App from './containers/App';
import { actionCreators } from './containers/App/store'; import { actionCreators } from './containers/App/store';
import { initMicroApps } from './micro';
import history from './utils/history'; import history from './utils/history';
window.createStoreage = new Storeage("PANDA_STORE") window.createStoreage = new Storeage('PANDA_STORE');
window.Http = Http window.Http = Http;
const initialState = Immutable.Map(); const initialState = Immutable.Map();
const store = configureStore(initialState, history); const store = configureStore(initialState, history);
...@@ -50,113 +44,48 @@ const render = () => { ...@@ -50,113 +44,48 @@ const render = () => {
const loader = (appContent, loading) => render({ appContent, loading }); const loader = (appContent, loading) => render({ appContent, loading });
const initLocale = () => { const initLocale = () => {
localStorage.setItem("umi_locale", 'zh-CN') localStorage.setItem('umi_locale', 'zh-CN');
} };
const initMicroApps = () => {
registerMicroApps(
[
{
name: 'purehtml',
entry: `//${window.location.hostname}:3020`,
container: '#subapp-container',
activeRule: '/web4/',
loader,
props: {
emitter: window.share.event,
globalConfig: createStoreage.get("globalConfig") || {},
XMLHttpRequest: window.XMLHttpRequest
}
},
],
{
beforeLoad: [
app => {
// hookRequest()
console.log('[LifeCycle] before load %c%s', 'color: green;', JSON.stringify(app));
},
],
beforeMount: [
app => {
// hookRequest()
console.log('[LifeCycle] before mount %c%s', 'color: green;', JSON.stringify(app));
},
],
afterUnmount: [
app => {
console.log('[LifeCycle] after unmount %c%s', 'color: green;', JSON.stringify(app));
},
],
},
);
const config = createStoreage.get("globalConfig")
if(config && config.token) {
setDefaultMountApp(`/web4/?client=${window.globalConfig.client}`)
}
start({
sandbox: {
experimentalStyleIsolation: true
},
singular: true,
scopedCSS: true,
getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
excludeAssetFilter: (url) => {
return url.indexOf('webapi.amap.com') !== -1 || url.indexOf('api.map.baidu.com') !== -1 || url.indexOf('pv.sohu.com') !== -1 || url.indexOf('mt0.google.cn') !==-1
}
});
runAfterFirstMounted(() => {
console.log('[MainApp] first app mounted');
});
addGlobalUncaughtErrorHandler(event => console.log(event));
// if (process.env.NODE_ENV === 'production') {
// require('offline-plugin/runtime').install(); // eslint-disable-line global-require
// }
}
const initGlobalConfig = () => { const initGlobalConfig = () => {
const config = createStoreage.get("globalConfig") || {}; const config = createStoreage.get('globalConfig') || {};
if(config.title == null) { if (config.title == null) {
createStoreage.remove("PANDA_STORE") createStoreage.remove('PANDA_STORE');
} }
if(!params.getParams('client') && config) { if (!params.getParams('client') && config) {
createStoreage.remove("PANDA_STORE") createStoreage.remove('PANDA_STORE');
} }
if(!createStoreage.get("globalConfig")) { if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage("PANDA_STORE") window.createStoreage = new Storeage('PANDA_STORE');
} }
if(config.title !== null && Object.keys(config).length > 0) { if (config.title !== null && Object.keys(config).length > 0) {
store.dispatch(actionCreators.getConfig(config)) store.dispatch(actionCreators.getConfig(config));
render({ appContent: '', loading: true }); render({ appContent: '', loading: true });
} else { } else {
Http.getConfig().then(res => { Http.getConfig()
store.dispatch(actionCreators.getConfig(res)) .then(res => {
}).then(res => { store.dispatch(actionCreators.getConfig(res));
})
.then(res => {
render({ appContent: '', loading: true }); render({ appContent: '', loading: true });
}).catch(error => {
store.dispatch(actionCreators.getConfigError(error))
}) })
.catch(error => {
store.dispatch(actionCreators.getConfigError(error));
});
} }
if(config.token) { if (config.token) {
initMicroApps() initMicroApps();
} }
};
window.share &&
window.share.event &&
window.share.event.on('triggerMicro', () => {
console.log('triggerMicro');
initMicroApps(loader);
});
initGlobalConfig();
initLocale();
}
window.share && window.share.event && window.share.event.on('loginSuccess', () => {
initMicroApps()
})
initGlobalConfig()
initLocale()
// console.log("globalConfig", globalConfig)
import React from 'react'; import React from 'react';
import { CURRENT } from './renderAuthorize';
import PromiseRender from './PromiseRender'; import PromiseRender from './PromiseRender';
import { CURRENT } from './renderAuthorize';
const checkPermissions = (authority, currentAuthority, target, Exception) => { const checkPermissions = (authority, currentAuthority, target, Exception) => {
if (!authority) { if (!authority) {
...@@ -46,7 +47,8 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { ...@@ -46,7 +47,8 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
} }
return Exception; return Exception;
} }
throw new Error('unsupported parameters'); return target;
// throw new Error('unsupported parameters');
}; };
function check(authority, target, Exception) { function check(authority, target, Exception) {
......
...@@ -19,24 +19,32 @@ import styles from './index.less'; ...@@ -19,24 +19,32 @@ import styles from './index.less';
class AvatarDropdown extends React.Component { class AvatarDropdown extends React.Component {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
onMenuClick = (event) => { onMenuClick = event => {
const { key } = event; const { key } = event;
if (key === 'logout') { if (key === 'logout') {
createStoreage.remove("PANDA_STORE") createStoreage.remove('PANDA_STORE');
this.props.history.push(`/user/login/?client=${window.globalConfig.client}`); this.props.history.push(
`/civbase/user/login/?client=${window.globalConfig.client}`,
);
location.reload(); location.reload();
return; return;
} }
}; };
render() { render() {
const props = this.props; const props = this.props;
const { const {
currentUser = { currentUser = {
avatar: props.global && props.global.userInfo && props.global.userInfo.UserImge || 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', avatar:
name: props.global && props.global.userInfo && props.global.userInfo.fullName || 'Serati Ma', (props.global &&
props.global.userInfo &&
props.global.userInfo.UserImge) ||
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
name:
(props.global &&
props.global.userInfo &&
props.global.userInfo.fullName) ||
'Serati Ma',
}, },
} = this.props; } = this.props;
const menuHeaderDropdown = ( const menuHeaderDropdown = (
...@@ -91,9 +99,12 @@ class AvatarDropdown extends React.Component { ...@@ -91,9 +99,12 @@ class AvatarDropdown extends React.Component {
} }
} }
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} };
} };
export default connect(mapStateToProps, null)(withRouter(AvatarDropdown)); export default connect(
mapStateToProps,
null,
)(withRouter(AvatarDropdown));
...@@ -4,7 +4,6 @@ import { ...@@ -4,7 +4,6 @@ import {
message, message,
Tag, Tag,
} from 'antd'; } from 'antd';
import groupBy from 'lodash/groupBy';
import moment from 'moment'; import moment from 'moment';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -12,7 +11,23 @@ import NoticeIcon from '../NoticeIcon'; ...@@ -12,7 +11,23 @@ import NoticeIcon from '../NoticeIcon';
import styles from './index.less'; import styles from './index.less';
class NoticeIconView extends Component { class NoticeIconView extends Component {
componentDidMount() {} state = {
count: 0,
noticeData: [],
};
componentDidMount() {
// Http.getInformationInfo({
// userID: this.props.global.userInfo.OID,
// pageIndex: 1,
// pageSize: 10,
// 'request.preventCache': Date.now(),
// }).then(res => {
// this.setState({
// count: res.totalRcdNum,
// noticeData: res.getMe,
// });
// });
}
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
changeReadState = clickedItem => {}; changeReadState = clickedItem => {};
...@@ -60,33 +75,18 @@ class NoticeIconView extends Component { ...@@ -60,33 +75,18 @@ class NoticeIconView extends Component {
return newNotice; return newNotice;
}); });
return groupBy(newNotices, 'type');
};
getUnreadData = noticeData => {
const unreadMsg = {};
Object.keys(noticeData).forEach(key => {
const value = noticeData[key];
if (!unreadMsg[key]) {
unreadMsg[key] = 0;
}
if (Array.isArray(value)) {
unreadMsg[key] = value.filter(item => !item.read).length;
}
});
return unreadMsg;
}; };
render() { render() {
const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props; const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props;
const noticeData = this.getNoticeData(); const noticeData = [];
const unreadMsg = this.getUnreadData(noticeData); //this.getNoticeData();
const unreadMsg = [];
//this.getUnreadData(noticeData);
return ( return (
<NoticeIcon <NoticeIcon
className={styles.action} className={styles.action}
count={currentUser && currentUser.unreadCount} count={this.state.count}
onItemClick={item => { onItemClick={item => {
this.changeReadState(item); this.changeReadState(item);
}} }}
...@@ -100,36 +100,22 @@ class NoticeIconView extends Component { ...@@ -100,36 +100,22 @@ class NoticeIconView extends Component {
> >
<NoticeIcon.Tab <NoticeIcon.Tab
tabKey="notification" tabKey="notification"
count={unreadMsg.notification} list={this.state.noticeData}
list={noticeData.notification}
title="通知" title="通知"
emptyText="你已查看所有通知" emptyText="你已查看所有通知"
showViewMore showViewMore
/> />
<NoticeIcon.Tab
tabKey="message"
count={unreadMsg.message}
list={noticeData.message}
title="消息"
emptyText="您已读完所有消息"
showViewMore
/>
<NoticeIcon.Tab
tabKey="event"
title="待办"
emptyText="你已完成所有待办"
count={unreadMsg.event}
list={noticeData.event}
showViewMore
/>
</NoticeIcon> </NoticeIcon>
); );
} }
} }
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} };
} };
export default connect(mapStateToProps, null)(NoticeIconView); export default connect(
mapStateToProps,
null,
)(NoticeIconView);
import React from 'react'; import React, { useState } from 'react';
// import { searchAutoCity } from '../../api/jsonp/autoService';
import HeaderSearch from '../HeaderSearch'; import HeaderSearch from '../HeaderSearch';
import NoticeIcon from '../NoticeIcon'; // import NoticeIcon from '../NoticeIcon';
import Avatar from './AvatarDropdown'; import Avatar from './AvatarDropdown';
import styles from './index.less'; import styles from './index.less';
import NoticeIconView from './NoticeIconView';
const GlobalHeaderRight = props => { const GlobalHeaderRight = props => {
const { theme, layout } = props; const { theme, layout } = props;
const [options, setOptions] = useState([]);
let className = styles.right; let className = styles.right;
if (theme === 'dark' && layout === 'top') { if (theme === 'dark' && layout === 'top') {
className = `${styles.right} ${styles.dark}`; className = `${styles.right} ${styles.dark}`;
} }
const handleSearch = value => {
const search = new AMap.Autocomplete();
const areaName =
createStoreage.get('globalConfig').mapsettings.areasettings &&
createStoreage.get('globalConfig').mapsettings.areasettings.areaName;
const area = (areaName ? areaName : '') + value;
setOptions([]);
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 handleSelect = (value, data) => {
window.share.event.emit('addTips', options, data);
};
return ( return (
<div className={className}> <div className={className}>
<HeaderSearch <HeaderSearch
className={`${styles.action} ${styles.search}`} className={`${styles.action} ${styles.search}`}
placeholder="搜索位置" placeholder="搜索位置"
defaultValue="" defaultValue=""
options={[ options={options}
{ onSelect={handleSelect}
label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, onChange={handleSearch}
value: 'umi ui', onSearch={handleSearch}
},
{
label: <a href="next.ant.design">Ant Design</a>,
value: 'Ant Design',
},
{
label: <a href="https://protable.ant.design/">Pro Table</a>,
value: 'Pro Table',
},
{
label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
value: 'Pro Layout',
},
]}
/> />
<NoticeIcon className={styles.action} /> <NoticeIconView notices={[]} />
<Avatar /> <Avatar menu />
{/* <SelectLang className={styles.action} /> */} {/* <SelectLang className={styles.action} /> */}
</div> </div>
); );
......
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createAddress = createAddress;
exports.ERROR_OK = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Address = function Address(_ref) {
var id = _ref.id,
adcode = _ref.adcode,
address = _ref.address,
city = _ref.city,
district = _ref.district,
name = _ref.name,
typecode = _ref.typecode;
_classCallCheck(this, Address);
this.id = id;
this.adcode = adcode;
this.address = address;
this.city = city;
this.district = district;
this.name = name;
this.typecode;
};
var ERROR_OK = '10000';
exports.ERROR_OK = ERROR_OK;
function createAddress(data) {
return new Address({
id: data.id,
adcode: data.adcode,
address: data.address,
city: data.city,
district: data.district,
name: data.name,
typecode: data.typecode
});
}
\ No newline at end of file
...@@ -30,26 +30,20 @@ const HeaderSearch = props => { ...@@ -30,26 +30,20 @@ const HeaderSearch = props => {
onChange: props.onChange, onChange: props.onChange,
}); });
const [searchMode, setSearchMode] = useMergeValue(defaultOpen || false, { const [searchMode, setSearchMode] = useMergeValue(defaultOpen || true, {
value: props.open, value: props.open,
onChange: onVisibleChange, onChange: onVisibleChange,
}); });
const inputClass = classNames( const inputClass = classNames(styles.input, styles.search, {
styles.input, // [styles.show]: searchMode,
{ });
[styles.show]: searchMode,
},
);
return ( return (
<div <div
className={classNames( className={classNames(className, styles.headerSearch)}
className,
styles.headerSearch,
)}
onClick={() => { onClick={() => {
setSearchMode(true); // setSearchMode(true);
if (searchMode && inputRef.current) { if (searchMode && inputRef.current) {
inputRef.current.focus(); inputRef.current.focus();
} }
...@@ -62,15 +56,9 @@ const HeaderSearch = props => { ...@@ -62,15 +56,9 @@ const HeaderSearch = props => {
} }
}} }}
> >
<SearchOutlined
key="Icon"
style={{
cursor: 'pointer',
}}
/>
<AutoComplete <AutoComplete
key="AutoComplete" key="AutoComplete"
className={inputClass} // className={inputClass}
value={value} value={value}
style={{ style={{
height: 28, height: 28,
...@@ -78,12 +66,15 @@ const HeaderSearch = props => { ...@@ -78,12 +66,15 @@ const HeaderSearch = props => {
}} }}
options={restProps.options} options={restProps.options}
onChange={setValue} onChange={setValue}
onSelect={restProps.onSelect}
> >
<Input <Input
ref={inputRef} ref={inputRef}
defaultValue={defaultValue} defaultValue={defaultValue}
aria-label={placeholder} aria-label={placeholder}
placeholder={placeholder} placeholder={placeholder}
className={inputClass}
allowClear={true}
onKeyDown={e => { onKeyDown={e => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
if (restProps.onSearch) { if (restProps.onSearch) {
...@@ -94,6 +85,7 @@ const HeaderSearch = props => { ...@@ -94,6 +85,7 @@ const HeaderSearch = props => {
onBlur={() => { onBlur={() => {
setSearchMode(false); setSearchMode(false);
}} }}
prefix={<SearchOutlined className="site-form-item-icon" />}
/> />
</AutoComplete> </AutoComplete>
</div> </div>
...@@ -103,6 +95,7 @@ const HeaderSearch = props => { ...@@ -103,6 +95,7 @@ const HeaderSearch = props => {
HeaderSearch.propTypes = { HeaderSearch.propTypes = {
onSearch: PropType.func, onSearch: PropType.func,
onChange: PropType.func, onChange: PropType.func,
onSelect: PropType.func,
onVisibleChange: PropType.func, onVisibleChange: PropType.func,
className: PropType.string, className: PropType.string,
placeholder: PropType.string, placeholder: PropType.string,
......
...@@ -27,4 +27,10 @@ ...@@ -27,4 +27,10 @@
margin-left: 8px; margin-left: 8px;
} }
} }
:global(.ant-select-selection-search .ant-input-affix-wrapper) {
border: 1px solid #b1b9c7;
border-radius: 28px;
width: 320px!important;
color: #555555;
}
} }
\ No newline at end of file
import React from 'react'; import React from 'react';
import { Avatar, List } from 'antd'; import {
Avatar,
List,
} from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import styles from './NoticeList.less'; import styles from './NoticeList.less';
...@@ -46,7 +49,8 @@ const NoticeList = ({ ...@@ -46,7 +49,8 @@ const NoticeList = ({
<span className={styles.iconElement}>{item.avatar}</span> <span className={styles.iconElement}>{item.avatar}</span>
) )
) : null; ) : null;
const content = item.InfoContent.replace('\n', '');
console.log(content);
return ( return (
<List.Item <List.Item
className={itemCls} className={itemCls}
...@@ -59,7 +63,12 @@ const NoticeList = ({ ...@@ -59,7 +63,12 @@ const NoticeList = ({
title={ title={
<div className={styles.title}> <div className={styles.title}>
{item.title} {item.title}
<div className={styles.extra}>{item.extra}</div> <div
className={styles.extra}
dangerouslySetInnerHTML={{
__html: content,
}}
/>
</div> </div>
} }
description={ description={
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
padding: 73px 0 88px; padding: 73px 0 88px;
color: @text-color-secondary; color: @text-color-secondary;
text-align: center; text-align: center;
border-radius: 0!important;
img { img {
display: inline-block; display: inline-block;
height: 76px; height: 76px;
......
import React, { import React from 'react';
useEffect,
useState,
} from 'react';
import { import {
Badge, Badge,
Spin,
Tabs, Tabs,
} from 'antd'; } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
...@@ -20,17 +16,6 @@ import NoticeList from './NoticeList'; ...@@ -20,17 +16,6 @@ import NoticeList from './NoticeList';
const { TabPane } = Tabs; const { TabPane } = Tabs;
const NoticeIcon = props => { const NoticeIcon = props => {
const [message, setMessage] = useState({});
useEffect(() => {
Http.getInformationInfo({
userID: props.global.userInfo.OID,
pageIndex: 1,
pageSize: 10,
'request.preventCache': Date.now()
}).then(res => {
setMessage(res)
})
}, [])
const getNotificationBox = () => { const getNotificationBox = () => {
const { const {
children, children,
...@@ -62,28 +47,29 @@ const NoticeIcon = props => { ...@@ -62,28 +47,29 @@ const NoticeIcon = props => {
const msgCount = count || count === 0 ? count : len; const msgCount = count || count === 0 ? count : len;
const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title; const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title;
panes.push( panes.push(
<TabPane tab={tabTitle} key={tabKey}>
<NoticeList <NoticeList
{...child.props} {...child.props}
clearText={clearText} clearText={clearText}
viewMoreText={viewMoreText} viewMoreText={viewMoreText}
data={list} data={list}
key={child}
onClear={() => onClear && onClear(title, tabKey)} onClear={() => onClear && onClear(title, tabKey)}
onClick={item => onItemClick && onItemClick(item, child.props)} onClick={item => onItemClick && onItemClick(item, child.props)}
onViewMore={event => onViewMore && onViewMore(child.props, event)} onViewMore={event => onViewMore && onViewMore(child.props, event)}
showClear={showClear} showClear={showClear}
showViewMore={showViewMore} showViewMore={showViewMore}
title={title} title={title}
/> />,
</TabPane>,
); );
}); });
return ( return (
<Spin spinning={loading} delay={300}> <>
<Tabs className={styles.tabs} onChange={onTabChange}> <div className={styles.header}>
<span>通知</span>
<span>全部标记已读</span>
</div>
{panes} {panes}
</Tabs> </>
</Spin>
); );
}; };
...@@ -93,18 +79,13 @@ const NoticeIcon = props => { ...@@ -93,18 +79,13 @@ const NoticeIcon = props => {
value: props.popupVisible, value: props.popupVisible,
onChange: props.onPopupVisibleChange, onChange: props.onPopupVisibleChange,
}); });
const noticeButtonClass = classNames( const noticeButtonClass = classNames(className, styles.noticeButton);
className,
styles.noticeButton,
);
const notificationBox = getNotificationBox(); const notificationBox = getNotificationBox();
const NoticeBellIcon = bell || ( const NoticeBellIcon = bell || <BellOutlined className={styles.icon} />;
<BellOutlined className={styles.icon} />
);
const trigger = ( const trigger = (
<span className={classNames(noticeButtonClass, { opened: visible })}> <span className={classNames(noticeButtonClass, { opened: visible })}>
<Badge <Badge
count={message.totalRcdNum} count={props.count}
style={{ boxShadow: 'none' }} style={{ boxShadow: 'none' }}
className={styles.badge} className={styles.badge}
> >
...@@ -136,9 +117,12 @@ NoticeIcon.defaultProps = { ...@@ -136,9 +117,12 @@ NoticeIcon.defaultProps = {
}; };
NoticeIcon.Tab = NoticeList; NoticeIcon.Tab = NoticeList;
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} };
} };
export default connect(mapStateToProps, null)(NoticeIcon); export default connect(
mapStateToProps,
null,
)(NoticeIcon);
...@@ -33,3 +33,16 @@ ...@@ -33,3 +33,16 @@
} }
} }
} }
.header {
border-radius: 0!important;
padding: 8px;
display: flex;
justify-content: space-between;
span {
&:last-child {
cursor: pointer;
color: @primary-color;
}
}
}
\ No newline at end of file
...@@ -2,61 +2,76 @@ import React from 'react'; ...@@ -2,61 +2,76 @@ import React from 'react';
import styles from './index.less'; import styles from './index.less';
const Menu = (props) => { const Menu = props => {
console.log(props.data.routes) const renderTitle = title => {
const renderTitle = (title) => { return <h4 className={styles.title}>{title}</h4>;
return (<h4 className={styles.title}>{title}</h4>) };
const renderMenuItem = data => {
let menuItem = [];
if (!data) {
return;
} }
const renderMenuItem = (data) => { if (!data.hasOwnProperty('routes')) {
let menuItem = []
if(!data) {
return
}
if(!data.hasOwnProperty('routes')) {
menuItem = ( menuItem = (
<div className={styles['main-menus-recentAll-menu-group-items-menu-item']}> <div
<img src={`https://panda-water.cn/web4/${data.extData.icon}`}/> className={styles['main-menus-recentAll-menu-group-items-menu-item']}
<a className={`${styles['main-menus-recentAll-menu-group-items-menu-item-name']} ${styles.pad}`}>{data.name}</a> onClick={event => props.handleClick(event, data)}
>
<img src={`https://panda-water.cn/web4/${data.extData.icon}`} />
<a
className={`${
styles['main-menus-recentAll-menu-group-items-menu-item-name']
} ${styles.pad}`}
>
{data.name}
</a>
</div> </div>
) );
} else { } else {
data.routes.forEach((item, index) => { data.routes.forEach((item, index) => {
let render = ( let render = (
<div className={styles['main-menus-recentAll-menu-group-items-menu-item']} key={item.name}> <div
<img src={`https://panda-water.cn/web4/${item.extData.icon}`}/> className={
<a className={`${styles['main-menus-recentAll-menu-group-items-menu-item-name']} ${styles.pad}`}>{item.name}</a> styles['main-menus-recentAll-menu-group-items-menu-item']
}
key={item.name}
onClick={event => props.handleClick(event, item)}
>
<img src={`https://panda-water.cn/web4/${item.extData.icon}`} />
<a
className={`${
styles['main-menus-recentAll-menu-group-items-menu-item-name']
} ${styles.pad}`}
>
{item.name}
</a>
</div> </div>
) );
menuItem.push(render) menuItem.push(render);
}) });
} }
return menuItem return menuItem;
};
}
return ( return (
<div className={styles['main-menus']}> <div className={styles['main-menus']}>
<div className={styles['main-menus-recentAll']}> <div className={styles['main-menus-recentAll']}>
<div className={styles['main-menus-recentAll-menu-group']}> <div className={styles['main-menus-recentAll-menu-group']}>
{ {(props.data.routes || []).map((item, index) => {
(props.data.routes || []).map((item, index) => {
return ( return (
<div className={styles['main-menus-recentAll-menu-group-items']} key={item.name}> <div
{ className={styles['main-menus-recentAll-menu-group-items']}
renderTitle(item.name) key={item.name}
} >
{ {renderTitle(item.name)}
renderMenuItem(item) {renderMenuItem(item)}
}
</div> </div>
) );
}) })}
}
</div> </div>
</div> </div>
</div> </div>
) );
} };
export default Menu; export default Menu;
...@@ -13,30 +13,38 @@ import styles from './index.less'; ...@@ -13,30 +13,38 @@ import styles from './index.less';
import Menu from './Menu'; import Menu from './Menu';
import { events } from './utils/index.js'; import { events } from './utils/index.js';
const Panel = (props) => { const Panel = props => {
const panelCls = classNames(styles.mainPane, props.visible ? styles.visible: styles.hidden); const panelCls = classNames(
const domRef = useRef() styles.mainPane,
props.visible ? styles.visible : styles.hidden,
);
const domRef = useRef();
const [currentMenu, setCurrentMenu] = useState(() => { const [currentMenu, setCurrentMenu] = useState(() => {
return props.data && Array.isArray(props.data) && props.data.length > 0 && props.data[0] || {}; return (
}) (props.data &&
Array.isArray(props.data) &&
props.data.length > 0 &&
props.data[0]) ||
{}
);
});
let _clickEvents = null; let _clickEvents = null;
const handleKeyDown = (event) => { const handleKeyDown = event => {
if(event.keyCode === KeyCode.ESC) { if (event.keyCode === KeyCode.ESC) {
const { onClose } = props; const { onClose } = props;
event.stopPropagation(); event.stopPropagation();
if (onClose) { if (onClose) {
onClose(event); onClose(event);
} }
} }
} };
const domFocus = () => { const domFocus = () => {
if(domRef) { if (domRef) {
domRef.current.focus() domRef.current.focus();
} }
} };
const handleDocumentClick = (e) => { const handleDocumentClick = e => {
if (props.visible) {
if(props.visible) {
const node = domRef && domRef.current; const node = domRef && domRef.current;
if ( if (
node && node &&
...@@ -47,67 +55,77 @@ const Panel = (props) => { ...@@ -47,67 +55,77 @@ const Panel = (props) => {
) { ) {
return; return;
} }
props.onClose && props.onClose(e) props.onClose && props.onClose(e);
}
} }
};
const addDocumentEvents = () => { const addDocumentEvents = () => {
if(props.canCloseByOutSideClick) { if (props.canCloseByOutSideClick) {
_clickEvents = events.on(document, 'click', handleDocumentClick) _clickEvents = events.on(document, 'click', handleDocumentClick);
}
} }
};
const removeDocumentEvents = () => { const removeDocumentEvents = () => {
_clickEvents.off(); _clickEvents.off();
_clickEvents = null; _clickEvents = null;
} };
const getCategories = () => { const getCategories = () => {
let data = props.data let data = props.data;
data = data.filter(item => { data = data.filter(item => {
return item.hasOwnProperty("extData") return item.hasOwnProperty('extData');
}) });
return data return data;
} };
const handleCategories = (index) => {
setCurrentMenu(props.data[index]) const handleCategories = index => {
props.onChange && props.onChange(index) setCurrentMenu(props.data[index]);
props.onChange && props.onChange(index);
};
} const selectItem = (event, item) => {
console.log(event, item);
props.onSelect && props.onSelect(item.path);
};
useEffect(() => { useEffect(() => {
if(props.visible) { if (props.visible) {
domFocus(); domFocus();
} }
addDocumentEvents() addDocumentEvents();
return () => removeDocumentEvents() return () => removeDocumentEvents();
}, [props.visible]); }, [props.visible]);
return ( return (
<div className={panelCls} tabIndex="-1" onKeyDown={ (event) => (props.visible && props.keyboard) ? handleKeyDown(event): undefined} ref={domRef}> <div
className={panelCls}
tabIndex="-1"
onKeyDown={event =>
props.visible && props.keyboard ? handleKeyDown(event) : undefined
}
ref={domRef}
>
<div className={styles.header}> <div className={styles.header}>
<div className={styles['header-title']}>子系统切换</div> <div className={styles['header-title']}>子系统切换</div>
</div> </div>
<div className={styles.main}> <div className={styles.main}>
<div className={styles['main-left']}> <div className={styles['main-left']}>
<Categories data={getCategories()} onChange={handleCategories}/> <Categories data={getCategories()} onChange={handleCategories} />
</div> </div>
<div className={styles['main-menus']}> <div className={styles['main-menus']}>
<Menu data={currentMenu || []}/> <Menu data={currentMenu || []} handleClick={selectItem} />
</div> </div>
</div> </div>
</div> </div>
) );
}; };
Panel.propTypes = { Panel.propTypes = {
visible: propTypes.bool, visible: propTypes.bool,
keyboard: propTypes.bool, keyboard: propTypes.bool,
onClose: propTypes.func, onClose: propTypes.func,
canCloseByOutSideClick: propTypes.bool canCloseByOutSideClick: propTypes.bool,
} };
Panel.defaultProps = { Panel.defaultProps = {
visible: false, visible: false,
keyboard: true, keyboard: true,
canCloseByOutSideClick: true, canCloseByOutSideClick: true,
onClose: () => {} onClose: () => {},
} };
export default Panel; export default Panel;
...@@ -8,32 +8,39 @@ import { ...@@ -8,32 +8,39 @@ import {
Switch, Switch,
} from 'react-router-dom'; } from 'react-router-dom';
import config from '../../routes/config'; import { dyRoutes } from '../../routes/config';
import generRoutes from '../../utils/routes';
function App(props) { function App(props) {
// console.log("APP",config.routes.concat(generRoutes(props.global.widgets || [])))
return ( return (
<> <>
<Helmet <Helmet
titleTemplate={`%s - ${props.global && props.global.title}`} titleTemplate={`%s - ${props.global && props.global.title}`}
defaultTitle={`${props.global && props.global.title}`} defaultTitle={`${props.global && props.global.title}`}
> >
<link rel="shortcut icon" href={`https://panda-water.cn/web4/${props.global && props.global.shortcutIcon}`}/> <link
<meta name="description" content={`${props.global && props.global.title}`} /> rel="shortcut icon"
href={`https://panda-water.cn/web4/${props.global &&
props.global.shortcutIcon}`}
/>
<meta
name="description"
content={`${props.global && props.global.title}`}
/>
</Helmet> </Helmet>
<Router> <Router>
<Switch>{renderRoutes(config.routes.concat(generRoutes(props.global && props.global.widgets || [])))}</Switch> <Switch>{renderRoutes(dyRoutes(props.menu || []).routes)}</Switch>
</Router> </Router>
</> </>
); );
} }
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} menu: state.getIn(['global', 'menu']),
} };
export default connect(mapStateToProps, null)(App); };
export default connect(
mapStateToProps,
null,
)(App);
import { import {
CREATE_CONEXT,
GENERATE_MENU,
GET_CONFIG, GET_CONFIG,
GET_CURRENT_ROUTES,
GET_ERROR_CONFIG, GET_ERROR_CONFIG,
} from './constants'; } from './constants';
export function getConfig(data) { export function getConfig(data) {
return { return {
type: GET_CONFIG, type: GET_CONFIG,
data data,
}; };
} }
...@@ -16,3 +19,23 @@ export function getConfigError(error) { ...@@ -16,3 +19,23 @@ export function getConfigError(error) {
error, error,
}; };
} }
export function getCurrentRoute(data) {
return {
type: GET_CURRENT_ROUTES,
data,
};
}
export function createContext(data) {
return {
type: CREATE_CONEXT,
data,
};
}
export function generateMenu(data) {
return {
type: GENERATE_MENU,
data,
};
}
export const GET_CONFIG = 'App/GET_CONFIG'; export const GET_CONFIG = 'App/GET_CONFIG';
export const GET_ERROR_CONFIG = 'App/GET_ERROR_CONFIG'; export const GET_ERROR_CONFIG = 'App/GET_ERROR_CONFIG';
export const GET_CURRENT_ROUTES = 'App/GET_CURRENT_ROUTES';
export const CREATE_CONEXT = 'App/CREATE_CONEXT';
export const GENERATE_MENU = 'App/GENERATE_MENU';
...@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.getConfig = getConfig; exports.getConfig = getConfig;
exports.getConfigError = getConfigError; exports.getConfigError = getConfigError;
exports.getCurrentRoute = getCurrentRoute;
exports.createContext = createContext;
exports.generateMenu = generateMenu;
var _constants = require("./constants"); var _constants = require("./constants");
...@@ -21,3 +24,24 @@ function getConfigError(error) { ...@@ -21,3 +24,24 @@ function getConfigError(error) {
error: error error: error
}; };
} }
function getCurrentRoute(data) {
return {
type: _constants.GET_CURRENT_ROUTES,
data: data
};
}
function createContext(data) {
return {
type: _constants.CREATE_CONEXT,
data: data
};
}
function generateMenu(data) {
return {
type: _constants.GENERATE_MENU,
data: data
};
}
\ No newline at end of file
...@@ -3,8 +3,14 @@ ...@@ -3,8 +3,14 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.GET_ERROR_CONFIG = exports.GET_CONFIG = void 0; exports.GENERATE_MENU = exports.CREATE_CONEXT = exports.GET_CURRENT_ROUTES = exports.GET_ERROR_CONFIG = exports.GET_CONFIG = void 0;
var GET_CONFIG = 'App/GET_CONFIG'; var GET_CONFIG = 'App/GET_CONFIG';
exports.GET_CONFIG = GET_CONFIG; exports.GET_CONFIG = GET_CONFIG;
var GET_ERROR_CONFIG = 'App/GET_ERROR_CONFIG'; var GET_ERROR_CONFIG = 'App/GET_ERROR_CONFIG';
exports.GET_ERROR_CONFIG = GET_ERROR_CONFIG; exports.GET_ERROR_CONFIG = GET_ERROR_CONFIG;
var GET_CURRENT_ROUTES = 'App/GET_CURRENT_ROUTES';
exports.GET_CURRENT_ROUTES = GET_CURRENT_ROUTES;
var CREATE_CONEXT = 'App/CREATE_CONEXT';
exports.CREATE_CONEXT = CREATE_CONEXT;
var GENERATE_MENU = 'App/GENERATE_MENU';
exports.GENERATE_MENU = GENERATE_MENU;
\ No newline at end of file
...@@ -7,11 +7,18 @@ exports["default"] = exports.initialState = void 0; ...@@ -7,11 +7,18 @@ exports["default"] = exports.initialState = void 0;
var _immutable = require("immutable"); var _immutable = require("immutable");
var _routes = _interopRequireDefault(require("../../../utils/routes"));
var _constants = require("./constants"); var _constants = require("./constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var initialState = (0, _immutable.fromJS)({ var initialState = (0, _immutable.fromJS)({
globalConfig: {}, globalConfig: {},
globalConfigError: "" globalConfigError: '',
currentRoutes: {},
instance: null,
menu: []
}); });
/* eslint-disable default-case, no-param-reassign */ /* eslint-disable default-case, no-param-reassign */
...@@ -23,11 +30,18 @@ var appReducer = function appReducer() { ...@@ -23,11 +30,18 @@ var appReducer = function appReducer() {
switch (action.type) { switch (action.type) {
case _constants.GET_CONFIG: case _constants.GET_CONFIG:
window.__INITIAL_STATE__ = action.data; debugger;
console.log('updateConfig', action.data);
window.__INITIAL_STATE__ = Object.assign({}, action.data, {
allWidgets: action.data.widgets || []
});
debugger;
window.globalConfig = require('kit_global_config')["default"]; window.globalConfig = require('kit_global_config')["default"];
createStoreage.set("globalConfig", window.globalConfig); createStoreage.set('globalConfig', window.globalConfig);
var config = createStoreage.get('globalConfig');
return state.merge({ return state.merge({
globalConfig: createStoreage.get("globalConfig") globalConfig: config,
menu: (0, _routes["default"])(config.widgets || [])
}); });
case _constants.GET_ERROR_CONFIG: case _constants.GET_ERROR_CONFIG:
...@@ -35,6 +49,21 @@ var appReducer = function appReducer() { ...@@ -35,6 +49,21 @@ var appReducer = function appReducer() {
globalConfigError: action.data globalConfigError: action.data
}); });
case _constants.GET_CURRENT_ROUTES:
return state.merge({
currentRoutes: action.data
});
case _constants.CREATE_CONEXT:
return state.merge({
instance: action.data
});
case _constants.GENERATE_MENU:
return state.merge({
menu: action.data
});
default: default:
return state; return state;
} }
......
import { fromJS } from 'immutable'; import { fromJS } from 'immutable';
import generRoutes from '../../../utils/routes';
import { import {
CREATE_CONEXT,
GENERATE_MENU,
GET_CONFIG, GET_CONFIG,
GET_CURRENT_ROUTES,
GET_ERROR_CONFIG, GET_ERROR_CONFIG,
} from './constants'; } from './constants';
export const initialState = fromJS({ export const initialState = fromJS({
globalConfig: {}, globalConfig: {},
globalConfigError: "" globalConfigError: '',
currentRoutes: {},
instance: null,
menu: [],
}); });
/* eslint-disable default-case, no-param-reassign */ /* eslint-disable default-case, no-param-reassign */
const appReducer = (state = initialState, action) => { const appReducer = (state = initialState, action) => {
switch (action.type) { switch (action.type) {
case GET_CONFIG: case GET_CONFIG:
window.__INITIAL_STATE__ = action.data; debugger;
console.log('updateConfig', action.data);
window.__INITIAL_STATE__ = Object.assign({}, action.data, {
allWidgets: action.data.widgets || [],
});
debugger;
window.globalConfig = require('kit_global_config').default; window.globalConfig = require('kit_global_config').default;
createStoreage.set("globalConfig", window.globalConfig) createStoreage.set('globalConfig', window.globalConfig);
const config = createStoreage.get('globalConfig');
return state.merge({ return state.merge({
globalConfig: createStoreage.get("globalConfig") globalConfig: config,
}) menu: generRoutes(config.widgets || []),
});
case GET_ERROR_CONFIG: case GET_ERROR_CONFIG:
return state.merge({ return state.merge({
globalConfigError: action.data globalConfigError: action.data,
}) });
case GET_CURRENT_ROUTES:
return state.merge({
currentRoutes: action.data,
});
case CREATE_CONEXT:
return state.merge({
instance: action.data,
});
case GENERATE_MENU:
return state.merge({
menu: action.data,
});
default: default:
return state; return state;
} }
} };
export default appReducer; export default appReducer;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultApp = exports.initMicroApps = void 0;
var _reactDom = _interopRequireDefault(require("react-dom"));
var _qiankun = require("qiankun");
var _package = _interopRequireDefault(require("../package.json"));
var _constants = require("./utils/constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var initMicroApps = function initMicroApps(loader) {
debugger;
(0, _qiankun.registerMicroApps)([{
name: 'web4_console',
entry: "//".concat(window.location.hostname, ":3020/civweb4"),
container: '#subapp-container',
activeRule: function activeRule(location) {
return location.href.indexOf("/".concat(_package["default"].name.toLocaleLowerCase(), "/civweb4")) !== -1;
},
loader: loader,
props: {
emitter: window.share.event,
baseRoot: 'civweb4',
globalConfig: JSON.stringify(createStoreage.get('globalConfig') || {}),
XMLHttpRequest: window.XMLHttpRequest
}
}], {
beforeLoad: [function (app) {
debugger; // hookRequest()
console.log('[LifeCycle] before load %c%s', 'color: green;', JSON.stringify(app));
}],
beforeMount: [function (app) {
debugger; // hookRequest()
_reactDom["default"].unmountComponentAtNode(document.getElementById('subapp-container'));
console.log('[LifeCycle] before mount %c%s', 'color: green;', JSON.stringify(app)); // window.share.event.removeAllListeners();
}],
beforeUnmount: [function (app) {
debugger;
console.log('[LifeCycle] before unmount %c%s', 'color: green;', JSON.stringify(app));
}],
afterUnmount: [function (app) {
debugger;
console.log('[LifeCycle] after unmount %c%s', 'color: green;', JSON.stringify(app));
}]
});
defaultApp();
(0, _qiankun.start)({
sandbox: {
experimentalStyleIsolation: true,
loose: true
},
singular: false,
scopedCSS: true,
getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
excludeAssetFilter: function excludeAssetFilter(url) {
return url.indexOf('webapi.amap.com') !== -1 || url.indexOf('api.map.baidu.com') !== -1 || url.indexOf('map.baidu.com') !== -1 || url.indexOf('pv.sohu.com') !== -1 || url.indexOf('mt0.google.cn') !== -1 || url.indexOf('mt1.google.cn') !== -1;
}
});
(0, _qiankun.runAfterFirstMounted)(function () {
console.log('[MainApp] first app mounted');
});
(0, _qiankun.addGlobalUncaughtErrorHandler)(function (event) {
return console.log(event);
});
};
exports.initMicroApps = initMicroApps;
var defaultApp = function defaultApp() {
var config = createStoreage.get('globalConfig');
if (config && config.token) {
var startWith = config.homepage ? config.homepage.split('/') : [];
var basePath = _constants.FILTER_FOLER.indexOf(startWith[0]) > -1 ? 'civweb4' : 'civweb';
(0, _qiankun.setDefaultMountApp)("/".concat(_package["default"].name.toLocaleLowerCase(), "/").concat(basePath, "/?client=").concat(config.client) // config.homepage
// ? `/${pkg.name.toLocaleLowerCase()}/${basePath}/${config.homepage}`
// : `/${pkg.name.toLocaleLowerCase()}/${basePath}/?client=${
// window.globalConfig.client
// }`,
);
}
};
exports.defaultApp = defaultApp;
\ No newline at end of file
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
</div> </div>
<!-- Open Sans Font --> <!-- Open Sans Font -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"> <!-- <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"> -->
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically injects all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this file. Don't add any assets here! (Check out webpack.dev.babel.js and webpack.prod.babel.js if you want to know more) --> <!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically injects all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this file. Don't add any assets here! (Check out webpack.dev.babel.js and webpack.prod.babel.js if you want to know more) -->
</body> </body>
......
import React, { useState } from 'react'; import React, {
useEffect,
useRef,
useState,
} from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { matchRoutes } from 'react-router-config';
import { import {
matchRoutes, Link,
renderRoutes, useHistory,
} from 'react-router-config'; } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { MenuFoldOutlined } from '@ant-design/icons'; import { MenuFoldOutlined } from '@ant-design/icons';
import ProLayout, { SettingDrawer } from '@ant-design/pro-layout'; import ProLayout, { SettingDrawer } from '@ant-design/pro-layout';
import RightContent from '../components/GlobalHeader/RightContent'; import RightContent from '../components/GlobalHeader/RightContent';
import { Panel } from '../components/SliderPanel'; import { Panel } from '../components/SliderPanel';
import generRoutes from '../utils/routes'; import SecurityLayout from './SecurityLayout';
// import routes from '../routes/mockRoute';
import styles from './UserLayout.less'; import styles from './UserLayout.less';
const settings = {
// navTheme: 'dark',
// 拂晓蓝
primaryColor: '#1890ff',
layout: 'side',
contentWidth: 'Fixed',
fixedHeader: false,
autoHideHeader: false,
fixSiderbar: true,
colorWeak: false,
menu: {
locale: "zh-CN",
},
title: 'Ant Design Pro',
pwa: false,
iconfontUrl: ''
};
const renderIcon = (icon, size) => { const renderIcon = (icon, size) => {
return <img src={`https://panda-water.cn/web4/${icon}`} style={{width: `${size}px`, height: `${size}px`, opacity: '0.8'}}/> return (
} <img
const menuExtraRender = (currentRoutes) => { src={`https://panda-water.cn/web4/${icon}`}
const [toggleSystem, setToggleSystem] = useState(false) style={{ width: `${size}px`, height: `${size}px`, opacity: '0.8' }}
/>
);
};
const menuExtraRender = currentRoutes => {
const [toggleSystem, setToggleSystem] = useState(false);
return { return {
render: ({collapsed}) => ( render: ({ collapsed }) => {
<a style={{display: 'flex', alignItems: 'center'}}> if (currentRoutes) {
<img src={`http://panda-water.cn/web4/${currentRoutes && currentRoutes.extData.icon}`} style={{width: '20px', height: '20px'}}/> return (
<span style={{margin: '0 10px', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap'}}>{currentRoutes && currentRoutes.name}</span> <a style={{ display: 'flex', alignItems: 'center' }}>
<MenuFoldOutlined onClick={() => setToggleSystem(!toggleSystem)}/> <img
src={`http://panda-water.cn/web4/${currentRoutes &&
currentRoutes.extData.icon}`}
style={{ width: '20px', height: '20px' }}
/>
<span
style={{
margin: '0 10px',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
}}
>
{currentRoutes && currentRoutes.name}
</span>
<MenuFoldOutlined onClick={() => setToggleSystem(!toggleSystem)} />
</a> </a>
), );
toggleSystem,
onClose: () => setToggleSystem(!toggleSystem)
} }
return return null;
},
toggleSystem,
onClose: () => setToggleSystem(!toggleSystem),
};
return;
}; };
const renderTitle = (title) => { const renderTitle = title => {
return <span className={styles['header-title']}>{title}</span> return <span className={styles['header-title']}>{title}</span>;
} };
const BasicLayout = props => { const BasicLayout = props => {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
const routes = generRoutes(props.global && props.global.widgets || []); const history = useHistory();
const [pathname, setPathname] = useState('/welcome'); const [pathname, setPathname] = useState('/welcome');
const [currentRoutes, setCurrentRoutes] = useState(() => { const [currentRoutes, setCurrentRoutes] = useState(props.route.routes[0]);
return routes[0] const [currentIndex, setCurrentIndex] = useState(0);
}) const [selectedKeys, setSelectedKeys] = useState([]);
const [collapse, setCollapse] = useState(false) const [collapse, setCollapse] = useState(false);
const handleMenuCollapse = (collapse) => { const [loading, setLoading] = useState(true);
setCollapse(collapse) const menuDataRef = useRef([]);
const microApp = useRef(null);
const handleMenuCollapse = collapse => {
setCollapse(collapse);
}; };
matchRoutes(props.route.routes, props.location.pathname); matchRoutes(props.route.routes, props.location.pathname);
const extraRender = menuExtraRender(currentRoutes) const extraRender = menuExtraRender(currentRoutes);
const onChange = (index) => { let clearTime = null;
setCurrentRoutes(routes[index]) useEffect(() => {
} setLoading(true);
const updateSettings = (config) => { clearTime = setTimeout(() => {
console.log(config) setCurrentRoutes(props.route.routes[currentIndex]);
} setLoading(false);
}, 100);
return () => clearTimeout && clearTimeout(clearTime);
}, [currentIndex]);
const updateSettings = config => {
console.log(config);
};
const handleSelectedKey = key => {
setSelectedKeys(`${key}`);
extraRender.onClose();
history.push(key);
};
const handleLogo = event => {
setTimeout(() => {
history.replace('/civbase/industry');
}, 300);
//
};
return ( return (
<SecurityLayout>
<ProLayout <ProLayout
logo="http://panda-water.cn/web4/assets/images/logo/单独图案-白色.svg" logo="http://panda-water.cn/web4/assets/images/logo/单独图案-白色.svg"
siderWidth="145px" siderWidth="145px"
title="" title=""
fixSiderbar={true} fixSiderbar={true}
onCollapse={(collapse) => handleMenuCollapse(collapse)} onMenuHeaderClick={event => handleLogo(event)}
onCollapse={collapse => handleMenuCollapse(collapse)}
menuExtraRender={extraRender.render} menuExtraRender={extraRender.render}
rightContentRender={() => <RightContent />} rightContentRender={() => <RightContent />}
headerContentRender={() => renderTitle(props.global.title)} headerContentRender={() => renderTitle(props.global.title)}
location={{ location={{
pathname, pathname,
}} }}
locale={'zh-CN'} menu={{
menuDataRender={() => [ loading,
...(currentRoutes && currentRoutes.routes || []) }}
]} locale={true}
menuDataRender={() => currentRoutes && currentRoutes.routes}
menuItemRender={(menuItemProps, defaultDom) => { menuItemRender={(menuItemProps, defaultDom) => {
if (menuItemProps.isUrl || !menuItemProps.path) { if (menuItemProps.isUrl || !menuItemProps.path) {
return defaultDom; return defaultDom;
} }
return <Link to={menuItemProps.path}> return (
{renderIcon(menuItemProps.extData && menuItemProps.extData.icon, 17)} <Link to={menuItemProps.path}>
{ {renderIcon(
defaultDom menuItemProps.extData && menuItemProps.extData.icon,
} 17,
</Link>; )}
{defaultDom}
</Link>
);
}} }}
subMenuItemRender={(menuItemProps, defaultDom) => { subMenuItemRender={(menuItemProps, defaultDom) => {
return (
return <> <>
{renderIcon(menuItemProps.extData && menuItemProps.extData.icon, 17)} {renderIcon(
{ menuItemProps.extData && menuItemProps.extData.icon,
collapse ? <div className={`ant-pro-menu-item ${styles.shortName}`}>{menuItemProps.extData.shortName}</div>:defaultDom 17,
} )}
</>; {collapse ? (
<div className={`ant-pro-menu-item ${styles.shortName}`}>
{menuItemProps.extData.shortName}
</div>
) : (
defaultDom
)}
</>
);
}}
menuProps={{
onClick: ({ item, key, keyPath, domEvent }) => {
setSelectedKeys(`${key}`);
window.share.event.emit('changeRoute', key);
},
selectedKeys: [selectedKeys],
}}
postMenuData={menuData => {
menuDataRef.current = menuData || [];
return menuData || [];
}} }}
{...props} {...props}
> >
{renderRoutes(props.route.routes)} {/* {renderRoutes(props.route.routes)} */}
<Panel visible={extraRender.toggleSystem} keyboard={true} onClose={extraRender.onClose} data={routes || []} onChange={onChange}/> <Panel
<div id="subapp-container" className="subapp-container" /> visible={extraRender.toggleSystem}
<SettingDrawer settings={settings} onSettingChange={(config) => updateSettings(config)}/> keyboard={true}
onClose={extraRender.onClose}
data={props.route.routes || []}
onChange={index => setCurrentIndex(index)}
onSelect={selectKeys => handleSelectedKey(selectKeys)}
/>
<div
id="subapp-container"
className="subapp-container"
ref={microApp}
/>
<SettingDrawer onSettingChange={config => updateSettings(config)} />
</ProLayout> </ProLayout>
</SecurityLayout>
); );
}; };
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} };
} };
export default connect(mapStateToProps, null)(BasicLayout); export default connect(
mapStateToProps,
null,
)(BasicLayout);
import React from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
class SecurityLayout extends React.Component {
state = {
isReady: false,
};
componentDidMount() {
this.setState({
isReady: true,
});
}
render() {
console.log(this.props);
// const { isReady } = this.state;
const { children, global } = this.props;
const isLogin = global.token !== null;
if (!isLogin && window.location.pathname !== '/civbase/user/login') {
return <Redirect to={`/civbase/user/login?client=${global.client}`} />;
}
return children;
}
}
const mapStateToProps = state => {
return {
global: state.getIn(['global', 'globalConfig']),
};
};
export default connect(
mapStateToProps,
null,
)(SecurityLayout);
import ReactDOM from 'react-dom';
import {
addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted,
setDefaultMountApp,
start,
} from 'qiankun';
import pkg from '../package.json';
import { FILTER_FOLER } from './utils/constants';
export const initMicroApps = loader => {
debugger;
registerMicroApps(
[
{
name: 'web4_console',
entry: `//${window.location.hostname}:3020/civweb4`,
container: '#subapp-container',
activeRule: location =>
location.href.indexOf(`/${pkg.name.toLocaleLowerCase()}/civweb4`) !==
-1,
loader,
props: {
emitter: window.share.event,
baseRoot: 'civweb4',
globalConfig: JSON.stringify(
createStoreage.get('globalConfig') || {},
),
XMLHttpRequest: window.XMLHttpRequest,
},
},
],
{
beforeLoad: [
app => {
debugger;
// hookRequest()
console.log(
'[LifeCycle] before load %c%s',
'color: green;',
JSON.stringify(app),
);
},
],
beforeMount: [
app => {
debugger;
// hookRequest()
ReactDOM.unmountComponentAtNode(
document.getElementById('subapp-container'),
);
console.log(
'[LifeCycle] before mount %c%s',
'color: green;',
JSON.stringify(app),
);
// window.share.event.removeAllListeners();
},
],
beforeUnmount: [
app => {
debugger;
console.log(
'[LifeCycle] before unmount %c%s',
'color: green;',
JSON.stringify(app),
);
},
],
afterUnmount: [
app => {
debugger;
console.log(
'[LifeCycle] after unmount %c%s',
'color: green;',
JSON.stringify(app),
);
},
],
},
);
defaultApp();
start({
sandbox: {
experimentalStyleIsolation: true,
loose: true,
},
singular: false,
scopedCSS: true,
getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
excludeAssetFilter: url => {
return (
url.indexOf('webapi.amap.com') !== -1 ||
url.indexOf('api.map.baidu.com') !== -1 ||
url.indexOf('map.baidu.com') !== -1 ||
url.indexOf('pv.sohu.com') !== -1 ||
url.indexOf('mt0.google.cn') !== -1 ||
url.indexOf('mt1.google.cn') !== -1
);
},
});
runAfterFirstMounted(() => {
console.log('[MainApp] first app mounted');
});
addGlobalUncaughtErrorHandler(event => console.log(event));
};
export const defaultApp = () => {
const config = createStoreage.get('globalConfig');
if (config && config.token) {
const startWith = config.homepage ? config.homepage.split('/') : [];
const basePath =
FILTER_FOLER.indexOf(startWith[0]) > -1 ? 'civweb4' : 'civweb';
setDefaultMountApp(
`/${pkg.name.toLocaleLowerCase()}/${basePath}/?client=${config.client}`,
// config.homepage
// ? `/${pkg.name.toLocaleLowerCase()}/${basePath}/${config.homepage}`
// : `/${pkg.name.toLocaleLowerCase()}/${basePath}/?client=${
// window.globalConfig.client
// }`,
);
}
};
import React from 'react';
import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
import { Card, Typography, Alert } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
export default () => (
<PageHeaderWrapper content=" 这个页面只有 admin 权限才能查看">
<Card>
<Alert
message="umi ui 现已发布,欢迎使用 npm run ui 启动体验。"
type="success"
showIcon
banner
style={{
margin: -12,
marginBottom: 48,
}}
/>
<Typography.Title level={2} style={{ textAlign: 'center' }}>
<SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" />{' '}
You
</Typography.Title>
</Card>
<p style={{ textAlign: 'center', marginTop: 24 }}>
Want to add more pages? Please refer to{' '}
<a
href="https://pro.ant.design/docs/block-cn"
target="_blank"
rel="noopener noreferrer"
>
use block
</a>
</p>
</PageHeaderWrapper>
);
import React from 'react';
import {
Alert,
Card,
Typography,
} from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
import styles from './Welcome.less';
const CodePreview = ({ children }) => (
<pre className={styles.pre}>
<code>
<Typography.Text copyable>{children}</Typography.Text>
</code>
</pre>
);
export default () => (
<PageContainer>
<Card>
<Alert
message="更快更强的重型组件,已经发布。"
type="success"
showIcon
banner
style={{
margin: -12,
marginBottom: 24,
}}
/>
</Card>
</PageContainer>
);
@import '~antd/lib/style/themes/default.less';
.pre {
margin: 12px 0;
padding: 12px 20px;
background: @input-bg;
box-shadow: @card-shadow;
}
\ No newline at end of file
import React, {
useCallback,
useState,
} from 'react';
import { Spin } from 'antd';
import classNames from 'classnames';
import { connect } from 'react-redux';
import SecurityLayout from '../../layouts/SecurityLayout';
import styles from './index.less';
const industries = ['供水', '排水', '消防', '暖通', '节水', '实验室'];
const renderIndustries = (config, callback) => {
return industries.map(item => {
return (
<li
className={styles.bootPageLi}
key={item}
onClick={event => callback(event, item)}
>
<div className={styles.bootPageList}>
<div className={styles.listMain}>
<img
src={`https://panda-water.cn/web4/assets/images/bootPage/${item}.png`}
/>
<span>{item}</span>
</div>
</div>
</li>
);
});
};
const BootPage = props => {
const [loadding, setLoadding] = useState(false);
const handlePage = useCallback((event, type) => {
event.persist();
const config = props.global;
config.uiwidgets = [];
config.widgets = [];
config.allWidgets = [];
props.instance && props.instance.updateConfig(config);
props.instance && props.instance.getUserInfoAndConfig('', true, type);
}, []);
return (
<SecurityLayout>
<div className={styles.bootPage}>
<div className={styles.bootPageMain}>
<header className={styles.bootPageHead}>
<img
src={`https://panda-water.cn/web4/assets/images/bootPage/熊猫图标.png`}
/>
<div className={styles.bootPageTitle}>
<span className={styles.bootPageZh}>
熊猫智慧城市监控管理解决方案
</span>
<span className={styles.bootPageEn}>
Panda Smart City Monitoring Management Platform & Solution
</span>
</div>
</header>
<section
className={classNames(
styles.bootPageSection,
'animate__fadeInDown',
'animate__animated',
)}
>
<ul
className={classNames(styles.bootPageUl, 'animate__animated')}
style={{
transform: `scale(${window.screen.width / 1920})`,
left: '300px',
bottom: '105px',
opacity: 1,
}}
>
{renderIndustries(props.global, handlePage)}
</ul>
</section>
<Spin spinning={loadding} />
</div>
</div>
</SecurityLayout>
);
};
const mapStateToProps = state => {
return {
global: state.getIn(['global', 'globalConfig']),
instance: state.getIn(['global', 'instance']),
};
};
export default connect(
mapStateToProps,
null,
)(BootPage);
@import '~antd/es/style/themes/default.less';
.bootPage {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
background: url("https://panda-water.cn/web4/assets/images/bootPage/背景.jpg") no-repeat top center;
background-size: cover;
.bootPageMain {
display: flex;
align-items: center;
flex-direction: column;
height: 100%;
width: 100%;
.bootPageHead {
height: 150px;
display: flex;
align-items: center;
justify-content: center;
color: #ffffff;
flex:none;
padding-top: 50px;
.bootPageTitle {
display: flex;
flex-direction: column;
margin-left: 20px;
.bootPageZh, .bootPageEn {
font-weight: 500;
}
.bootPageZh {
font-size: 34px;
letter-spacing: 5px;
}
.bootPageEn {
font-size: 16px;
font-family: -webkit-body;
letter-spacing: 1px;
}
}
}
.bootPageSection {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: calc(100% - 160px);
margin: 20px 0;
overflow: auto;
&::-webkit-scrollbar {
width: 2px;
}
.bootPageUl {
display: flex;
width: 1080px;
flex-wrap: wrap;
list-style: none;
justify-content: center;
transition: all .5s ease-out;
.bootPageLi {
width: 345px;
height: 315px;
padding: 10px;
.bootPageList {
width: 100%;
height: 100%;
background: linear-gradient(to top, rgba(37, 102, 164, 0.35) 0%, rgba(16, 64, 110, 0.35) 100%);
border-radius: 4px;
transition: all .2s ease-out;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-size: 24px;
cursor: pointer;
&:hover {
background: linear-gradient(to top, rgba(41, 108, 172, 0.6) 0%, rgba(16, 64, 110, 0.6) 100%);
.listMain {
transform: scale(1.1);
}
}
span {
margin-top: 20px;
font-weight: 500;
color: #fff;
}
.listMain {
transition: all .2s ease-out;
display: flex;
align-items: center;
flex-direction: column;
}
}
}
}
}
}
}
@media screen and (max-width:1440px) {
.bootPage {
.bootPageHead {
.bootPageZh {
font-size: 26px;
}
.bootPageEn {
font-size: 12px;
}
}
}
}
@media screen and (min-width:1440px) and (max-width:1600px) {
.bootPage {
.bootPageHead {
.bootPageZh {
font-size: 30px;
}
.bootPageEn {
font-size: 14px;
}
}
}
}
\ No newline at end of file
...@@ -31,6 +31,9 @@ function () { ...@@ -31,6 +31,9 @@ function () {
this.events = window.share.event; this.events = window.share.event;
this.globalConfig = props.global; this.globalConfig = props.global;
this.updateConfig = props.updateConfig; this.updateConfig = props.updateConfig;
this.createContext = props.createContext;
this.history = props.history;
this.init();
} }
_createClass(Login, [{ _createClass(Login, [{
...@@ -40,9 +43,9 @@ function () { ...@@ -40,9 +43,9 @@ function () {
this.loginFailed = false; this.loginFailed = false;
this.guid = Math.round(Math.random() * 10000 + Date.now()).toString(16); this.guid = Math.round(Math.random() * 10000 + Date.now()).toString(16);
this.redirect_state = _jsCookie["default"].get("redirect_state"); this.redirect_state = _jsCookie["default"].get('redirect_state');
var token = this.globalConfig.initToken || _jsCookie["default"].get("token"); var token = this.globalConfig.initToken || _jsCookie["default"].get('token');
if (!!token) { if (!!token) {
this.globalConfig.token = token; this.globalConfig.token = token;
...@@ -70,17 +73,17 @@ function () { ...@@ -70,17 +73,17 @@ function () {
}, { }, {
key: "writeLogs", key: "writeLogs",
value: function writeLogs() { value: function writeLogs() {
if (this.globalConfig.userInfo.UserImge === "") { if (this.globalConfig.userInfo.UserImge === '') {
// _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png"; // _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png";
this.globalConfig.userInfo.UserImge = "https://panda-water.cn/web4/assets/images/icon/熊猫新2.png"; this.globalConfig.userInfo.UserImge = 'https://panda-water.cn/web4/assets/images/icon/熊猫新2.png';
} }
if (this.globalConfig.userInfo.site) { if (this.globalConfig.userInfo.site) {
Http.writeLogs({ Http.writeLogs({
origin: window.location.origin, origin: window.location.origin,
client: this.globalConfig.client, client: this.globalConfig.client,
site: this.globalConfig.userInfo && this.globalConfig.userInfo.site ? this.globalConfig.userInfo.site : "", site: this.globalConfig.userInfo && this.globalConfig.userInfo.site ? this.globalConfig.userInfo.site : '',
loginName: this.globalConfig.userInfo && this.globalConfig.userInfo.fullName ? this.globalConfig.userInfo.fullName : "" loginName: this.globalConfig.userInfo && this.globalConfig.userInfo.fullName ? this.globalConfig.userInfo.fullName : ''
})["catch"](function (error) { })["catch"](function (error) {
console.log(error); console.log(error);
}); });
...@@ -89,15 +92,20 @@ function () { ...@@ -89,15 +92,20 @@ function () {
}, { }, {
key: "getIndustry", key: "getIndustry",
value: function getIndustry(flag, token) { value: function getIndustry(flag, token) {
var _this3 = this;
this.globalConfig.userInfo.Industries = new Array(); this.globalConfig.userInfo.Industries = new Array();
if (this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups.length) { if (this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups.length) {
this.globalConfig.userInfo.Groups.forEach(function (group) { this.globalConfig.userInfo.Groups.forEach(function (group) {
if (group.industry && this.globalConfig.userInfo.Industries.indexOf(group.industry) < 0) this.globalConfig.userInfo.Industries.push(group.industry); if (group.industry && _this3.globalConfig.userInfo.Industries.indexOf(group.industry) < 0) _this3.globalConfig.userInfo.Industries.push(group.industry);
}); });
} }
if (!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1) { if (!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1) {
this.createContext(this); //console.log('云平台');
this.history.push('/civbase/industry');
return false; return false;
} }
...@@ -106,81 +114,94 @@ function () { ...@@ -106,81 +114,94 @@ function () {
}, { }, {
key: "getWebConfig", key: "getWebConfig",
value: function getWebConfig(token) { value: function getWebConfig(token) {
var _this3 = this; var _this4 = this;
Http.getWebSiteConfig({ Http.getWebSiteConfig({
client: this.globalConfig.client, client: this.globalConfig.client,
token: token, token: token,
'request.preventCache': Date.now() 'request.preventCache': Date.now()
}).then(function (response) { }).then(function (response) {
debugger;
if (response && response.length > 0) { if (response && response.length > 0) {
_this3.globalConfig = Object.assign(_this3.globalConfig, response.shift(), { _this4.globalConfig = Object.assign(_this4.globalConfig, response.shift(), {
theme: _this3.globalConfig.theme, theme: _this4.globalConfig.theme,
menu: _this3.globalConfig.menu, menu: _this4.globalConfig.menu,
style: _this3.globalConfig.style style: _this4.globalConfig.style
}); });
_this3.updateConfig && _this3.updateConfig(_this3.globalConfig); _this4.updateConfig && _this4.updateConfig(_this4.globalConfig);
_this3.getProjectItems().then(function (res) { _this4.getProjectItems().then(function (res) {
window.subSysCfg = {}; window.subSysCfg = {};
response.forEach(function (item) { response.forEach(function (item) {
window.subSysCfg[item.client] = item; window.subSysCfg[item.client] = item;
}); });
if (!!_this3.globalConfig.isShared) { if (!!_this4.globalConfig.isShared) {
_this3.globalConfig.mode = "single"; _this4.globalConfig.mode = 'single';
_this3.globalConfig.style = "sandbox"; _this4.globalConfig.style = 'sandbox';
_this3.globalConfig.uiwidgets = [_this3.globalConfig.shareWidget]; _this4.globalConfig.uiwidgets = [_this4.globalConfig.shareWidget];
_this3.globalConfig.widgets = []; _this4.globalConfig.widgets = [];
} } // window.share.event.removeAllListeners('loginSuccess');
if (_this3.globalConfig.userInfo.site && 0 < _this3.globalConfig.userInfo.site.length) { if (_this4.globalConfig.userInfo.site && _this4.globalConfig.userInfo.site.length > 0) {
Http.getWebSiteConfig({ Http.getWebSiteConfig({
client: _this3.globalConfig.client, client: _this4.globalConfig.client,
token: token, token: token,
'request.preventCache': Date.now() 'request.preventCache': Date.now()
}).then(function (response) { }).then(function (response) {
debugger;
if (response && response.length > 0) { if (response && response.length > 0) {
var mainConf = response.shift(); var mainConf = response.shift();
if (mainConf.homepage) _this3.globalConfig.homepage = mainConf.homepage; if (mainConf.homepage) _this4.globalConfig.homepage = mainConf.homepage;
if (mainConf.bannerLogo) _this3.globalConfig.bannerLogo = mainConf.bannerLogo; if (mainConf.bannerLogo) _this4.globalConfig.bannerLogo = mainConf.bannerLogo;
if (mainConf.logo) _this3.globalConfig.logo = mainConf.logo; if (mainConf.logo) _this4.globalConfig.logo = mainConf.logo;
if (mainConf.mdi) _this3.globalConfig.mdi = mainConf.mdi; if (mainConf.mdi) _this4.globalConfig.mdi = mainConf.mdi;
if (mainConf.menu) _this3.globalConfig.menu = mainConf.menu; if (mainConf.menu) _this4.globalConfig.menu = mainConf.menu;
if (mainConf.shortcutIcon) _this3.globalConfig.shortcutIcon = mainConf.shortcutIcon; if (mainConf.shortcutIcon) _this4.globalConfig.shortcutIcon = mainConf.shortcutIcon;
} }
_this3.updateConfig && _this3.updateConfig(_this3.globalConfig); //loginSuccess _this4.updateConfig && _this4.updateConfig(_this4.globalConfig); //loginSuccess
_this3.events.emit("loginSuccess"); debugger;
window.share.event = _this3.events; _this4.events.emit('loginSuccess');
window.share.event = _this4.events;
}); });
} else { } else {
//loginSuccess //loginSuccess
_this3.updateConfig && _this3.updateConfig(_this3.globalConfig); _this4.updateConfig && _this4.updateConfig(_this4.globalConfig);
debugger;
_this3.events.emit("loginSuccess"); _this4.events.emit('loginSuccess');
window.share.event = _this3.events; window.share.event = _this4.events;
} }
}); });
} else { } else {
if (_this3.goLogin()) { if (_this4.goLogin()) {
return false; return false;
} // this.handleLoginError() }
_this4.handleLoginError();
console.log("获取网络配置失败"); console.log('获取网络配置失败');
} }
})["catch"](function (error) { })["catch"](function (error) {
console.log(error); console.log(error);
console.log("获取网络配置失败");
_this4.handleLoginError();
console.log('获取网络配置失败');
}); });
} }
}, { }, {
key: "getProjectItems", key: "getProjectItems",
value: function getProjectItems() { value: function getProjectItems() {
debugger;
var MAX_BOTTOM = 0; var MAX_BOTTOM = 0;
var isScale = false; var isScale = false;
var widgetIndex = -1; var widgetIndex = -1;
...@@ -196,8 +217,7 @@ function () { ...@@ -196,8 +217,7 @@ function () {
if (layers.length === 0) { if (layers.length === 0) {
widgetIndex != -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1); widgetIndex != -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1);
Promise.resolve(); return Promise.resolve({});
return;
} }
var layer = layers[0]; var layer = layers[0];
...@@ -210,7 +230,7 @@ function () { ...@@ -210,7 +230,7 @@ function () {
if (layers.length > 1 && widgetIndex == -1) { if (layers.length > 1 && widgetIndex == -1) {
this.globalConfig.uiwidgets.push({ this.globalConfig.uiwidgets.push({
bottom: isScale ? maxBottom + 70 : maxBottom + 35, bottom: isScale ? MAX_BOTTOM + 70 : MAX_BOTTOM + 35,
config: '', config: '',
label: '方案切换', label: '方案切换',
right: 15, right: 15,
...@@ -230,36 +250,40 @@ function () { ...@@ -230,36 +250,40 @@ function () {
if (layer.extent) this.globalConfig.mapsettings.areasettings.extent = layer.extent; if (layer.extent) this.globalConfig.mapsettings.areasettings.extent = layer.extent;
if (layer.basemaps && layer.basemaps.length > 0) this.globalConfig.mapsettings.basemaps = layer.basemaps; if (layer.basemaps && layer.basemaps.length > 0) this.globalConfig.mapsettings.basemaps = layer.basemaps;
this.updateConfig && this.updateConfig(this.globalConfig); this.updateConfig && this.updateConfig(this.globalConfig);
return Promise.resolve(); return Promise.resolve({});
} }
}, { }, {
key: "handleLoginError", key: "handleLoginError",
value: function handleLoginError() { value: function handleLoginError() {
_jsCookie["default"].set(this.globalConfig.client, "", { _jsCookie["default"].set(this.globalConfig.client, '', {
path: '/' path: '/'
}); });
_jsCookie["default"].set("token", "", { _jsCookie["default"].set('token', '', {
path: "/" path: '/'
}); });
_jsCookie["default"].set("site", "", { _jsCookie["default"].set('site', '', {
path: "/" path: '/'
}); });
_jsCookie["default"].set("loginMode", "", { _jsCookie["default"].set('loginMode', '', {
path: "/" path: '/'
}); });
_jsCookie["default"].set("redirect_state", "", { _jsCookie["default"].set('redirect_state', '', {
path: "/" path: '/'
}); });
this.loginFailed = true;
} }
}, { }, {
key: "goLogin", key: "goLogin",
value: function goLogin() { value: function goLogin() {
if (_config.style === "ios" && _config.loginTemplate === "IOSCloud.html") { debugger;
window.location.href = window.location.origin + "/#login";
if (this.globalConfig.style === 'ios' && this.globalConfig.loginTemplate === 'IOSCloud.html') {
window.location.href = window.location.origin + '/#login';
return true; return true;
} else { } else {
return false; return false;
...@@ -273,7 +297,7 @@ function () { ...@@ -273,7 +297,7 @@ function () {
}, { }, {
key: "getLocalSiteBytoken", key: "getLocalSiteBytoken",
value: function getLocalSiteBytoken(tk) { value: function getLocalSiteBytoken(tk) {
var sStr = localStorage.getItem("loginSite"), var sStr = localStorage.getItem('loginSite'),
s = null; s = null;
if (sStr) { if (sStr) {
...@@ -289,23 +313,23 @@ function () { ...@@ -289,23 +313,23 @@ function () {
}, { }, {
key: "loginByDD", key: "loginByDD",
value: function loginByDD() { value: function loginByDD() {
var gotoUrl = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=" + encodeURIComponent(window.location.href); var gotoUrl = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' + encodeURIComponent(window.location.href);
var obj = DDLogin({ var obj = DDLogin({
id: "login_container", id: 'login_container',
"goto": encodeURIComponent(gotoUrl), "goto": encodeURIComponent(gotoUrl),
style: "border:none;background-color:#FFFFFF;", style: 'border:none;background-color:#FFFFFF;',
width: "365", width: '365',
height: "400" height: '400'
}); });
var handleMessage = function handleMessage(event) { var handleMessage = function handleMessage(event) {
var origin = event.origin; var origin = event.origin;
console.log("origin", event.origin); console.log('origin', event.origin);
if (origin == "https://login.dingtalk.com") { if (origin == 'https://login.dingtalk.com') {
//判断是否来自ddLogin扫码事件。 //判断是否来自ddLogin扫码事件。
var loginTmpCode = event.data; var loginTmpCode = event.data;
var redirectUrl = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=" + encodeURIComponent(window.location.href) + "&loginTmpCode=" + loginTmpCode; //获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了 var redirectUrl = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' + encodeURIComponent(window.location.href) + '&loginTmpCode=' + loginTmpCode; //获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了
window.location.href = redirectUrl; window.location.href = redirectUrl;
} }
...@@ -320,7 +344,7 @@ function () { ...@@ -320,7 +344,7 @@ function () {
}, { }, {
key: "ddLoginIn", key: "ddLoginIn",
value: function ddLoginIn(code) { value: function ddLoginIn(code) {
var _this4 = this; var _this5 = this;
Http.getOA({ Http.getOA({
query: { query: {
...@@ -330,41 +354,41 @@ function () { ...@@ -330,41 +354,41 @@ function () {
}).then(function (response) { }).then(function (response) {
if (response && response.data && response.data.getMe) { if (response && response.data && response.data.getMe) {
var tk = response.data.getMe[0].token; var tk = response.data.getMe[0].token;
_this4.globalConfig.token = tk; _this5.globalConfig.token = tk;
var url = window.location.href; //获取当前页面的url var url = window.location.href; //获取当前页面的url
if (url.indexOf("&code") != -1) { if (url.indexOf('&code') != -1) {
//判断是否存在参数 //判断是否存在参数
url = (_readOnlyError("url"), url.replace(/(\&code|#)[^'"]*/, '')); //去除参数 url = (_readOnlyError("url"), url.replace(/(\&code|#)[^'"]*/, '')); //去除参数
window.history.pushState({}, 0, url); window.history.pushState({}, 0, url);
} }
_this4.isSignIn = true; _this5.isSignIn = true;
_this4.getUserInfoAndConfig(); _this5.getUserInfoAndConfig();
} else { } else {
_this4.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码"); _this5.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message); // msgUtils.fault("登录失败," + error.message);
_this4.hasTry = true; //已经输错过密码 _this5.hasTry = true; //已经输错过密码
} }
}); });
} }
}, { }, {
key: "otherLoginIn", key: "otherLoginIn",
value: function otherLoginIn(usr, pwd) { value: function otherLoginIn(usr, pwd) {
var _this5 = this; var _this6 = this;
var uesrName = (0, _jsBase.decode)(usr.substring(0, usr.length - 3)), var uesrName = (0, _jsBase.decode)(usr.substring(0, usr.length - 3)),
password = (0, _jsBase.decode)(pwd.substring(0, pwd.length - 3)); password = (0, _jsBase.decode)(pwd.substring(0, pwd.length - 3));
Http.generateToken({ Http.generateToken({
query: { query: {
f: "json", f: 'json',
expiration: this.globalConfig.expiration, expiration: this.globalConfig.expiration,
//token过期时间(单位:秒) //token过期时间(单位:秒)
client: "referer", client: 'referer',
username: uesrName, username: uesrName,
password: (0, _sha["default"])(password).toUpperCase(), password: (0, _sha["default"])(password).toUpperCase(),
referer: this.globalConfig.client, referer: this.globalConfig.client,
...@@ -375,12 +399,12 @@ function () { ...@@ -375,12 +399,12 @@ function () {
if (response && response.data && response.data.token) { if (response && response.data && response.data.token) {
var tk = response.data.token; // token一天不过期 var tk = response.data.token; // token一天不过期
_this5.globalConfig.token = tk; _this6.globalConfig.token = tk;
request(userInfoUrl, { request(userInfoUrl, {
query: { query: {
token: tk, token: tk,
subOID: 'subOID', subOID: 'subOID',
site: _this5.getLocalSiteBytoken(tk) site: _this6.getLocalSiteBytoken(tk)
}, },
cacheBust: true, cacheBust: true,
ignoreSite: true ignoreSite: true
...@@ -399,7 +423,7 @@ function () { ...@@ -399,7 +423,7 @@ function () {
_this.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码"); _this.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码");
msgUtils.fault("登录失败," + error.message); msgUtils.fault('登录失败,' + error.message);
_this.hasTry = true; //已经输错过密码 _this.hasTry = true; //已经输错过密码
} }
}); });
...@@ -407,22 +431,23 @@ function () { ...@@ -407,22 +431,23 @@ function () {
}, { }, {
key: "getUserInfoAndConfig", key: "getUserInfoAndConfig",
value: function getUserInfoAndConfig(failCallback, flag, industry) { value: function getUserInfoAndConfig(failCallback, flag, industry) {
var _this6 = this; var _this7 = this;
debugger;
var token = this.globalConfig.token; var token = this.globalConfig.token;
var site = _jsCookie["default"].get("site"); var site = _jsCookie["default"].get('site');
var _industrySite = null; var _industrySite = null;
if (_industrySite) { if (industry) {
var userInfo = this.globalConfig.userInfo && this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups instanceof Array ? this.globalConfig.userInfo.Groups.find(function (enter) { var userInfo = this.globalConfig.userInfo && this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups instanceof Array ? this.globalConfig.userInfo.Groups.find(function (enter) {
return enter.industry === industry; return enter.industry === industry;
}) : null; }) : null;
if (userInfo) { if (userInfo) {
this.globalConfig.userInfo = { this.globalConfig.userInfo = {
site: _enter.site ? _enter.site : null, site: userInfo.site ? userInfo.site : null,
Groups: this.globalConfig.userInfo.Groups Groups: this.globalConfig.userInfo.Groups
}; };
_industrySite = userInfo.site ? userInfo.site : null; _industrySite = userInfo.site ? userInfo.site : null;
...@@ -445,34 +470,52 @@ function () { ...@@ -445,34 +470,52 @@ function () {
'request.preventCache': Date.now() 'request.preventCache': Date.now()
}).then(function (response) { }).then(function (response) {
try { try {
if (response && !response.errMsg) { debugger;
_this6.globalConfig.userInfo = Object.assign({}, response, _this6.globalConfig.userInfo);
_jsCookie["default"].set("site", _this6.globalConfig.userInfo.site); if (response && !response.errMsg) {
_this7.globalConfig.userInfo = Object.assign({}, response, _this7.globalConfig.userInfo); // Cookies.set('site', this.globalConfig.userInfo.site);
_this6.writeLogs(); _this7.writeLogs();
_this6.getIndustry(flag, token); _this7.getIndustry(flag, token);
} else { } else {
if (_this6.goLogin()) { if (_this7.goLogin()) {
return false; return false;
} }
_this.handleLoginError(failCallback); _this.handleLoginError(failCallback);
} }
_this6.updateConfig && _this6.updateConfig(_this6.globalConfig); _this7.updateConfig && _this7.updateConfig(_this7.globalConfig);
} catch (error) { } catch (error) {
if (_this7.goLogin()) {
return false;
}
_this7.handleLoginError(failCallback);
console.log(error); console.log(error);
} }
})["catch"](function (error) { })["catch"](function (error) {
if (_this7.goLogin()) {
return false;
}
_this7.handleLoginError(failCallback);
console.log(error); console.log(error);
}); });
} else { } else {
try { try {
this.writeLogs(); this.writeLogs();
debugger;
this.getIndustry(flag, token); this.getIndustry(flag, token);
} catch (error) { } catch (error) {
if (this.goLogin()) {
return false;
}
this.handleLoginError(failCallback);
console.log(error); console.log(error);
} }
} }
...@@ -480,13 +523,13 @@ function () { ...@@ -480,13 +523,13 @@ function () {
}, { }, {
key: "login", key: "login",
value: function login(usr, pwd, userPhone, isRememberPWD) { value: function login(usr, pwd, userPhone, isRememberPWD) {
var _this7 = this; var _this8 = this;
Http.generateToken({ Http.generateToken({
f: "json", f: 'json',
expiration: this.globalConfig.expiration, expiration: this.globalConfig.expiration,
//token过期时间(单位:秒) //token过期时间(单位:秒)
client: "referer", client: 'referer',
username: usr, username: usr,
password: (0, _sha["default"])(pwd).toUpperCase(), password: (0, _sha["default"])(pwd).toUpperCase(),
referer: this.globalConfig.client, referer: this.globalConfig.client,
...@@ -494,40 +537,41 @@ function () { ...@@ -494,40 +537,41 @@ function () {
userPhone: userPhone, userPhone: userPhone,
'request.preventCache': Date.now() 'request.preventCache': Date.now()
}).then(function (response) { }).then(function (response) {
debugger;
if (response && response.token) { if (response && response.token) {
var token = response.token; var token = response.token;
_jsCookie["default"].set("token", token); _jsCookie["default"].set('token', token);
var exp = 86400000; var exp = 86400000;
_this7.globalConfig.token = token; _this8.globalConfig.token = token;
if (isRememberPWD) { if (isRememberPWD) {
_jsCookie["default"].set(_this7.globalConfig.client, token, { _jsCookie["default"].set(_this8.globalConfig.client, token, {
expires: exp / (24 * 60 * 60 * 1000), expires: exp / (24 * 60 * 60 * 1000),
path: "/" path: '/'
}); });
_jsCookie["default"].set("token", token, { _jsCookie["default"].set('token', token, {
expires: exp / (24 * 60 * 60 * 1000), expires: exp / (24 * 60 * 60 * 1000),
path: "/" path: '/'
}); });
} }
_this7.isSignIn = true; _this8.isSignIn = true;
_this8.updateConfig && _this8.updateConfig(_this8.globalConfig);
_this7.getUserInfoAndConfig(); _this8.getUserInfoAndConfig();
_this7.updateConfig && _this7.updateConfig(_this7.globalConfig);
} else { } else {
console.log("登录失败", response.message); console.log('登录失败', response.message);
_this7.hasTry = true; _this8.hasTry = true;
} }
})["catch"](function (error) { })["catch"](function (error) {
_this7.handleLoginError(); _this8.handleLoginError();
console.log("登录失败", error.message); console.log('登录失败', error.message);
_this7.hasTry = true; _this8.hasTry = true;
}); });
} }
}]); }]);
......
...@@ -31,8 +31,6 @@ const LoginMessage = ({ content }) => ( ...@@ -31,8 +31,6 @@ const LoginMessage = ({ content }) => (
/> />
); );
const Login = props => { const Login = props => {
const { userLogin = {} } = props; const { userLogin = {} } = props;
const videoRef = useRef(); const videoRef = useRef();
...@@ -43,86 +41,139 @@ const Login = props => { ...@@ -43,86 +41,139 @@ const Login = props => {
const footerRef = useRef(); const footerRef = useRef();
const { status, type: loginType } = userLogin; const { status, type: loginType } = userLogin;
const [autoLogin, setAutoLogin] = useState(true); const [autoLogin, setAutoLogin] = useState(true);
const [submitting, setSubmitting] = useState(false) const [submitting, setSubmitting] = useState(false);
const [currentDate, setCurrentDate] = useState({}); const [currentDate, setCurrentDate] = useState({});
const [type, setType] = useState('account'); const [type, setType] = useState('account');
const handleSubmit = values => { const handleSubmit = values => {
/* eslint-disable no-console */ /* eslint-disable no-console */
let loginAction = new LoginAction(props) let loginAction = new LoginAction(props);
loginAction.login(values.userName, values.password)
setSubmitting(true) loginAction.login(values.userName, values.password);
setSubmitting(true);
debugger;
loginAction.events.on('loginSuccess', event => { loginAction.events.on('loginSuccess', event => {
setSubmitting(false) setSubmitting(false);
props.history.push(`/?client=${props.global.client}`); // window.share.event.on('updateGlobalConfig', props.global);
}) props.history.push(`/civbase/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global);
});
}; };
let loginTimeInterval = null; let loginTimeInterval = null;
useEffect(() => { useEffect(() => {
if(loginTimeInterval) (clearInterval(loginTimeInterval),loginTimeInterval = null ); if (loginTimeInterval)
clearInterval(loginTimeInterval), (loginTimeInterval = null);
loginTimeInterval = setInterval(() => { loginTimeInterval = setInterval(() => {
const date = new Date(); const date = new Date();
const weekday = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; const weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const time = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':' + (date.getMinutes() < const time =
10 ? '0' + date.getMinutes() : date.getMinutes()) + ':' + (date.getSeconds() < 10 ? '0' + (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) +
date.getSeconds() : date.getSeconds()); ':' +
(date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) +
':' +
(date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
setCurrentDate({ setCurrentDate({
time: time, time: time,
dayofweek: weekday[date.getDay()], dayofweek: weekday[date.getDay()],
date: date.pattern('yyyy/mm/dd') date: date.pattern('yyyy/mm/dd'),
}) });
}, 1000); }, 1000);
return () => { return () => {
loginTimeInterval && clearInterval(loginTimeInterval) loginTimeInterval && clearInterval(loginTimeInterval);
} };
}, []); }, []);
useEffect(() => { useEffect(() => {
if(videoRef) { if (videoRef) {
videoRef.current.addEventListener('ended', function() { videoRef.current.addEventListener('ended', function() {
dom.removeClass(loginRef.current, styles.caseHide); dom.removeClass(loginRef.current, styles.caseHide);
dom.addClass(loginRef.current, styles.loginTimeShow); dom.addClass(loginRef.current, styles.loginTimeShow);
setTimeout(() => { setTimeout(() => {
dom.removeClass(timeRef.current, styles.caseHide); dom.removeClass(timeRef.current, styles.caseHide);
dom.addClass(timeRef.current, "animate__fadeIn"); dom.addClass(timeRef.current, 'animate__fadeIn');
dom.removeClass(loginFormRef.current, styles.caseHide); dom.removeClass(loginFormRef.current, styles.caseHide);
dom.addClass(loginFormRef.current, "animate__fadeInUp"); dom.addClass(loginFormRef.current, 'animate__fadeInUp');
dom.removeClass(footerRef.current, styles.caseHide); dom.removeClass(footerRef.current, styles.caseHide);
dom.addClass(footerRef.current, "animate__slideInUp"); dom.addClass(footerRef.current, 'animate__slideInUp');
dom.removeClass(titleRef.current, styles.caseHide); dom.removeClass(titleRef.current, styles.caseHide);
dom.addClass(titleRef.current, "animte__fadeInUp"); dom.addClass(titleRef.current, 'animte__fadeInUp');
}, 500); }, 500);
}) });
} }
}, [videoRef]); }, [videoRef]);
return ( return (
<div className={styles.main}> <div className={styles.main}>
<video src="https://panda-water.cn/web4/assets/videos/beforPage.mp4" className={styles.videLayer} autoPlay="autoPlay" muted playsInline="playsinline" ref={videoRef}></video> <video
src="https://panda-water.cn/web4/assets/videos/beforPage.mp4"
className={styles.videLayer}
autoPlay="autoPlay"
muted
playsInline="playsinline"
ref={videoRef}
/>
<div className={styles.inner}> <div className={styles.inner}>
<div className={classNames(styles.loginTime, styles.caseHide)} ref={loginRef}> <div
<img role="logo" src={`https://panda-water.cn/web4/${window.globalConfig.logo}`}/> className={classNames(styles.loginTime, styles.caseHide)}
<div className={classNames(styles.titleCase, styles.caseHide, "animated")} ref={titleRef}> ref={loginRef}
>
<img
role="logo"
src={`https://panda-water.cn/web4/${window.globalConfig.logo}`}
/>
<div
className={classNames(
styles.titleCase,
styles.caseHide,
'animated',
)}
ref={titleRef}
>
<span className={styles.title}>{window.globalConfig.title}</span> <span className={styles.title}>{window.globalConfig.title}</span>
<span className={styles.subtitle}>{window.globalConfig.subtitle}</span> <span className={styles.subtitle}>
{window.globalConfig.subtitle}
</span>
</div> </div>
</div> </div>
<span className={classNames(styles.divider, styles.caseHide, "animate__animated")}></span> <span
<div className={classNames(styles.timeCase, styles.caseHide, "animate__animated")} ref={timeRef}> className={classNames(
styles.divider,
styles.caseHide,
'animate__animated',
)}
/>
<div
className={classNames(
styles.timeCase,
styles.caseHide,
'animate__animated',
)}
ref={timeRef}
>
<span className={styles.time}>{currentDate.time}</span> <span className={styles.time}>{currentDate.time}</span>
<span className={styles.dayofweek}>{currentDate.dayofweek}</span> <span className={styles.dayofweek}>{currentDate.dayofweek}</span>
<span className={styles.date}>{currentDate.date}</span> <span className={styles.date}>{currentDate.date}</span>
</div> </div>
<div className={classNames(styles['login-block'], styles.caseHide, "animate__animated")} ref={loginFormRef}> <div
className={classNames(
styles['login-block'],
styles.caseHide,
'animate__animated',
)}
ref={loginFormRef}
>
<div> <div>
<img src="https://panda-water.cn/web4/assets/images/login/dark/login.png"/> <img src="https://panda-water.cn/web4/assets/images/login/dark/login.png" />
</div> </div>
<div className={styles['login-form']}> <div className={styles['login-form']}>
<LoginForm activeKey={type} onTabChange={setType} onSubmit={handleSubmit}> <LoginForm
activeKey={type}
onTabChange={setType}
onSubmit={handleSubmit}
>
{status === 'error' && loginType === 'account' && !submitting && ( {status === 'error' && loginType === 'account' && !submitting && (
<LoginMessage content="账户或密码错误" /> <LoginMessage content="账户或密码错误" />
)} )}
...@@ -157,33 +208,48 @@ const Login = props => { ...@@ -157,33 +208,48 @@ const Login = props => {
<Submit loading={submitting}>登录</Submit> <Submit loading={submitting}>登录</Submit>
</LoginForm> </LoginForm>
</div> </div>
</div>
</div> </div>
<div className={classNames(styles.footerCase, styles.caseHide, 'animate__animated')} ref={footerRef}>
<div className={classNames("QuickMark", "QM-wrapper")}>
</div> </div>
<div
className={classNames(
styles.footerCase,
styles.caseHide,
'animate__animated',
)}
ref={footerRef}
>
<div className={classNames('QuickMark', 'QM-wrapper')} />
<span className={classNames(styles.copyright)}> <span className={classNames(styles.copyright)}>
Copyright © Copyright ©
<a target="_blank" href="https://panda-water.cn">熊猫智慧水务</a> <a target="_blank" href="https://panda-water.cn">
{new Date().getFullYear()} All Rights Reserved <a target="_blank" id="IndexCaseNumber" href="">ICP11036640-1</a> 熊猫智慧水务
</a>
{new Date().getFullYear()} All Rights Reserved{' '}
<a target="_blank" id="IndexCaseNumber" href="">
ICP11036640-1
</a>
</span> </span>
</div> </div>
</div> </div>
); );
}; };
const mapStateToProps = (state) => { const mapStateToProps = state => {
return { return {
global: state.getIn(['global', 'globalConfig']) global: state.getIn(['global', 'globalConfig']),
} };
} };
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = dispatch => {
return { return {
updateConfig(config) { updateConfig(config) {
dispatch(actionCreators.getConfig(config)) dispatch(actionCreators.getConfig(config));
} },
} createContext(data) {
} dispatch(actionCreators.createContext(data));
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Login)) },
\ No newline at end of file };
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(Login));
...@@ -4,67 +4,99 @@ import sha1 from 'sha1'; ...@@ -4,67 +4,99 @@ import sha1 from 'sha1';
class Login { class Login {
constructor(props) { constructor(props) {
console.log(props) console.log(props);
this.events = window.share.event this.events = window.share.event;
this.globalConfig = props.global this.globalConfig = props.global;
this.updateConfig = props.updateConfig this.updateConfig = props.updateConfig;
this.createContext = props.createContext;
this.history = props.history;
this.init();
} }
init() { init() {
this.loginFailed = false this.loginFailed = false;
this.guid = Math.round(Math.random() * 10000 + Date.now()).toString(16) this.guid = Math.round(Math.random() * 10000 + Date.now()).toString(16);
this.redirect_state = Cookies.get("redirect_state"); this.redirect_state = Cookies.get('redirect_state');
const token = this.globalConfig.initToken || Cookies.get("token"); const token = this.globalConfig.initToken || Cookies.get('token');
if(!!token) { if (!!token) {
this.globalConfig.token = token; this.globalConfig.token = token;
Http.getUserInfo({ Http.getUserInfo({
token: this.globalConfig.token, token: this.globalConfig.token,
subOID: 'subOID', subOID: 'subOID',
site: this.getLocalSiteBytoken(token), site: this.getLocalSiteBytoken(token),
'request.preventCache': Date.now() 'request.preventCache': Date.now(),
}).then(response => { }).then(response => {
if(response && !response.errMsg) { if (response && !response.errMsg) {
this.globalConfig.userInfo = {}; this.globalConfig.userInfo = {};
if (response.Groups && response.Groups instanceof Array && response.Groups.length) { if (
response.Groups &&
response.Groups instanceof Array &&
response.Groups.length
) {
this.globalConfig.userInfo.Groups = response.Groups; this.globalConfig.userInfo.Groups = response.Groups;
} }
this.globalConfig.userInfo = Object.assign({}, response, this.globalConfig.userInfo); this.globalConfig.userInfo = Object.assign(
this.updateConfig && this.updateConfig(this.globalConfig) {},
this.getUserInfoAndConfig() response,
this.globalConfig.userInfo,
);
this.updateConfig && this.updateConfig(this.globalConfig);
this.getUserInfoAndConfig();
} }
}) });
} }
} }
writeLogs() { writeLogs() {
if( this.globalConfig.userInfo.UserImge === "") { if (this.globalConfig.userInfo.UserImge === '') {
// _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png"; // _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png";
this.globalConfig.userInfo.UserImge = "https://panda-water.cn/web4/assets/images/icon/熊猫新2.png"; this.globalConfig.userInfo.UserImge =
'https://panda-water.cn/web4/assets/images/icon/熊猫新2.png';
} }
if(this.globalConfig.userInfo.site) { if (this.globalConfig.userInfo.site) {
Http.writeLogs({ Http.writeLogs({
origin: window.location.origin, origin: window.location.origin,
client: this.globalConfig.client, client: this.globalConfig.client,
site: (this.globalConfig.userInfo && this.globalConfig.userInfo.site) ? this.globalConfig.userInfo.site: "", site:
loginName: (this.globalConfig.userInfo && this.globalConfig.userInfo.fullName) ? this.globalConfig.userInfo.fullName: "" this.globalConfig.userInfo && this.globalConfig.userInfo.site
? this.globalConfig.userInfo.site
: '',
loginName:
this.globalConfig.userInfo && this.globalConfig.userInfo.fullName
? this.globalConfig.userInfo.fullName
: '',
}).catch(error => { }).catch(error => {
console.log(error) console.log(error);
}) });
} }
} }
getIndustry(flag, token) { getIndustry(flag, token) {
this.globalConfig.userInfo.Industries = new Array; this.globalConfig.userInfo.Industries = new Array();
if(this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups.length) { if (
this.globalConfig.userInfo.Groups.forEach(function (group) { this.globalConfig.userInfo.Groups &&
if (group.industry && this.globalConfig.userInfo.Industries.indexOf(group.industry) < 0) this.globalConfig.userInfo.Industries.push(group.industry); this.globalConfig.userInfo.Groups.length
}) ) {
this.globalConfig.userInfo.Groups.forEach(group => {
if (
group.industry &&
this.globalConfig.userInfo.Industries.indexOf(group.industry) < 0
)
this.globalConfig.userInfo.Industries.push(group.industry);
});
} }
if(!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1) { if (
return false !flag &&
this.isSignIn &&
this.globalConfig.userInfo.Industries.length &&
this.globalConfig.userInfo.Industries.length > 1
) {
this.createContext(this);
//console.log('云平台');
this.history.push('/civbase/industry');
return false;
} }
this.getWebConfig(token); this.getWebConfig(token);
} }
...@@ -73,148 +105,179 @@ class Login { ...@@ -73,148 +105,179 @@ class Login {
Http.getWebSiteConfig({ Http.getWebSiteConfig({
client: this.globalConfig.client, client: this.globalConfig.client,
token: token, token: token,
'request.preventCache': Date.now() 'request.preventCache': Date.now(),
}).then((response) => { })
if(response && response.length > 0) { .then(response => {
this.globalConfig = Object.assign(this.globalConfig, response.shift(), { debugger;
if (response && response.length > 0) {
this.globalConfig = Object.assign(
this.globalConfig,
response.shift(),
{
theme: this.globalConfig.theme, theme: this.globalConfig.theme,
menu: this.globalConfig.menu, menu: this.globalConfig.menu,
style: this.globalConfig.style style: this.globalConfig.style,
}) },
);
this.updateConfig && this.updateConfig(this.globalConfig) this.updateConfig && this.updateConfig(this.globalConfig);
this.getProjectItems().then(res => { this.getProjectItems().then(res => {
window.subSysCfg = {}; window.subSysCfg = {};
response.forEach(item => { response.forEach(item => {
window.subSysCfg[item.client] = item; window.subSysCfg[item.client] = item;
}) });
if(!!this.globalConfig.isShared) {
this.globalConfig.mode = "single";
this.globalConfig.style= "sandbox";
this.globalConfig.uiwidgets= [this.globalConfig.shareWidget];
this.globalConfig.widgets = []
}
if(this.globalConfig.userInfo.site && 0 < this.globalConfig.userInfo.site.length) { if (!!this.globalConfig.isShared) {
this.globalConfig.mode = 'single';
this.globalConfig.style = 'sandbox';
this.globalConfig.uiwidgets = [this.globalConfig.shareWidget];
this.globalConfig.widgets = [];
}
// window.share.event.removeAllListeners('loginSuccess');
if (
this.globalConfig.userInfo.site &&
this.globalConfig.userInfo.site.length > 0
) {
Http.getWebSiteConfig({ Http.getWebSiteConfig({
client: this.globalConfig.client, client: this.globalConfig.client,
token: token, token: token,
'request.preventCache': Date.now() 'request.preventCache': Date.now(),
}).then((response) => { }).then(response => {
debugger;
if (response && response.length > 0) { if (response && response.length > 0) {
var mainConf = response.shift(); var mainConf = response.shift();
if (mainConf.homepage) this.globalConfig.homepage = mainConf.homepage; if (mainConf.homepage)
if (mainConf.bannerLogo) this.globalConfig.bannerLogo = mainConf.bannerLogo; this.globalConfig.homepage = mainConf.homepage;
if (mainConf.bannerLogo)
this.globalConfig.bannerLogo = mainConf.bannerLogo;
if (mainConf.logo) this.globalConfig.logo = mainConf.logo; if (mainConf.logo) this.globalConfig.logo = mainConf.logo;
if (mainConf.mdi) this.globalConfig.mdi = mainConf.mdi; if (mainConf.mdi) this.globalConfig.mdi = mainConf.mdi;
if (mainConf.menu) this.globalConfig.menu = mainConf.menu; if (mainConf.menu) this.globalConfig.menu = mainConf.menu;
if (mainConf.shortcutIcon) this.globalConfig.shortcutIcon = mainConf.shortcutIcon; if (mainConf.shortcutIcon)
this.globalConfig.shortcutIcon = mainConf.shortcutIcon;
} }
this.updateConfig && this.updateConfig(this.globalConfig) this.updateConfig && this.updateConfig(this.globalConfig);
//loginSuccess //loginSuccess
this.events.emit("loginSuccess") debugger;
window.share.event = this.events this.events.emit('loginSuccess');
}) window.share.event = this.events;
});
} else { } else {
//loginSuccess //loginSuccess
this.updateConfig && this.updateConfig(this.globalConfig) this.updateConfig && this.updateConfig(this.globalConfig);
this.events.emit("loginSuccess") debugger;
window.share.event = this.events this.events.emit('loginSuccess');
window.share.event = this.events;
} }
}) });
} else { } else {
if(this.goLogin()) { if (this.goLogin()) {
return false return false;
} }
// this.handleLoginError() this.handleLoginError();
console.log("获取网络配置失败") console.log('获取网络配置失败');
} }
}).catch(error => {
console.log(error)
console.log("获取网络配置失败")
}) })
.catch(error => {
console.log(error);
this.handleLoginError();
console.log('获取网络配置失败');
});
} }
getProjectItems() { getProjectItems() {
debugger;
let MAX_BOTTOM = 0; let MAX_BOTTOM = 0;
let isScale = false; let isScale = false;
let widgetIndex = -1; let widgetIndex = -1;
this.globalConfig.uiwidgets.map((item, index) => { this.globalConfig.uiwidgets.map((item, index) => {
if(parseInt(item['bottom']) > MAX_BOTTOM) { if (parseInt(item['bottom']) > MAX_BOTTOM) {
MAX_BOTTOM = parseInt(item['bottom']) MAX_BOTTOM = parseInt(item['bottom']);
} }
if (!isScale && (item.url).toLowerCase().indexOf('widgets/zoom') > -1) if (!isScale && item.url.toLowerCase().indexOf('widgets/zoom') > -1)
isScale = true; isScale = true;
if(widgetIndex == -1 && item.url.indexOf('ToggleProject/ToggleProject')>-1) widgetIndex = index; if (
widgetIndex == -1 &&
item.url.indexOf('ToggleProject/ToggleProject') > -1
)
widgetIndex = index;
}); });
const layers = this.globalConfig.mapsettings.layers const layers = this.globalConfig.mapsettings.layers;
if(layers.length === 0) { if (layers.length === 0) {
widgetIndex != -1 && this.globalConfig.uiwidgets.splice(widgetIndex , 1); widgetIndex != -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1);
Promise.resolve() return Promise.resolve({});
return
} }
let layer = layers[0]; let layer = layers[0];
if(!layer.id) { if (!layer.id) {
layer.layerType = 'dynamic' layer.layerType = 'dynamic';
}else { } else {
layer.layerType = 'PipenetLayer' layer.layerType = 'PipenetLayer';
} }
if(layers.length >1 && widgetIndex == -1){ if (layers.length > 1 && widgetIndex == -1) {
this.globalConfig.uiwidgets.push({ this.globalConfig.uiwidgets.push({
bottom: isScale ? maxBottom + 70 : maxBottom + 35, bottom: isScale ? MAX_BOTTOM + 70 : MAX_BOTTOM + 35,
config: '', config: '',
label: '方案切换', label: '方案切换',
right: 15, right: 15,
url: 'product/webgisPanda/ToggleProject/ToggleProject' url: 'product/webgisPanda/ToggleProject/ToggleProject',
}); });
} }
if(layer.areaName) this.globalConfig.mapsettings.areasettings.areaName = layer.areaName; if (layer.areaName)
if(layer.backgroundColor) this.globalConfig.mapsettings.areasettings.backgroundColor = layer.backgroundColor; this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
if(layer.boundColor) this.globalConfig.mapsettings.areasettings.boundColor = layer.boundColor; if (layer.backgroundColor)
if(layer.boundWidth) this.globalConfig.mapsettings.areasettings.boundWidth = layer.boundWidth; this.globalConfig.mapsettings.areasettings.backgroundColor =
if(Number.isInteger(parseInt(layer.backgroundOpacity))){ layer.backgroundColor;
this.globalConfig.mapsettings.areasettings.backgroundOpacity = layer.backgroundOpacity if (layer.boundColor)
this.globalConfig.mapsettings.areasettings.boundColor = layer.boundColor;
if (layer.boundWidth)
this.globalConfig.mapsettings.areasettings.boundWidth = layer.boundWidth;
if (Number.isInteger(parseInt(layer.backgroundOpacity))) {
this.globalConfig.mapsettings.areasettings.backgroundOpacity =
layer.backgroundOpacity;
} }
if(layer.extent) this.globalConfig.mapsettings.areasettings.extent = layer.extent; if (layer.extent)
if(layer.basemaps && layer.basemaps.length>0) this.globalConfig.mapsettings.basemaps = layer.basemaps; this.globalConfig.mapsettings.areasettings.extent = layer.extent;
this.updateConfig && this.updateConfig(this.globalConfig) if (layer.basemaps && layer.basemaps.length > 0)
return Promise.resolve(); this.globalConfig.mapsettings.basemaps = layer.basemaps;
this.updateConfig && this.updateConfig(this.globalConfig);
return Promise.resolve({});
} }
handleLoginError() { handleLoginError() {
Cookies.set(this.globalConfig.client, "", { Cookies.set(this.globalConfig.client, '', {
path: '/' path: '/',
}) });
Cookies.set("token", "", { Cookies.set('token', '', {
path: "/" path: '/',
}); });
Cookies.set("site", "", { Cookies.set('site', '', {
path: "/" path: '/',
}); });
Cookies.set("loginMode", "", { Cookies.set('loginMode', '', {
path: "/" path: '/',
}); });
Cookies.set("redirect_state", "", { Cookies.set('redirect_state', '', {
path: "/" path: '/',
}); });
this.loginFailed = true;
} }
goLogin() { goLogin() {
if (_config.style === "ios" && _config.loginTemplate === "IOSCloud.html") { debugger;
window.location.href = window.location.origin + "/#login"; if (
this.globalConfig.style === 'ios' &&
this.globalConfig.loginTemplate === 'IOSCloud.html'
) {
window.location.href = window.location.origin + '/#login';
return true; return true;
} else { } else {
return false; return false;
...@@ -222,11 +285,12 @@ class Login { ...@@ -222,11 +285,12 @@ class Login {
} }
isRememberPWD(status) { isRememberPWD(status) {
this.isRememberPWD = status this.isRememberPWD = status;
} }
getLocalSiteBytoken(tk) { getLocalSiteBytoken(tk) {
let sStr = localStorage.getItem("loginSite"), s = null; let sStr = localStorage.getItem('loginSite'),
s = null;
if (sStr) { if (sStr) {
const sObj = JSON.parse(sStr); const sObj = JSON.parse(sStr);
if (sObj && sObj[tk]) { if (sObj && sObj[tk]) {
...@@ -237,21 +301,28 @@ class Login { ...@@ -237,21 +301,28 @@ class Login {
} }
loginByDD() { loginByDD() {
const gotoUrl="https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+encodeURIComponent(window.location.href); const gotoUrl =
'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' +
encodeURIComponent(window.location.href);
const obj = DDLogin({ const obj = DDLogin({
id: "login_container", id: 'login_container',
goto: encodeURIComponent(gotoUrl), goto: encodeURIComponent(gotoUrl),
style: "border:none;background-color:#FFFFFF;", style: 'border:none;background-color:#FFFFFF;',
width: "365", width: '365',
height: "400" height: '400',
}); });
const handleMessage = function (event) { const handleMessage = function(event) {
const origin = event.origin; const origin = event.origin;
console.log("origin", event.origin); console.log('origin', event.origin);
if (origin == "https://login.dingtalk.com") { //判断是否来自ddLogin扫码事件。 if (origin == 'https://login.dingtalk.com') {
//判断是否来自ddLogin扫码事件。
const loginTmpCode = event.data; const loginTmpCode = event.data;
const redirectUrl="https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+encodeURIComponent(window.location.href)+"&loginTmpCode="+loginTmpCode; const redirectUrl =
'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' +
encodeURIComponent(window.location.href) +
'&loginTmpCode=' +
loginTmpCode;
//获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了 //获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了
window.location.href = redirectUrl; window.location.href = redirectUrl;
} }
...@@ -266,17 +337,18 @@ class Login { ...@@ -266,17 +337,18 @@ class Login {
ddLoginIn(code) { ddLoginIn(code) {
Http.getOA({ Http.getOA({
query: { query: {
TmpAuthCode: code TmpAuthCode: code,
}, },
cacheBust: true cacheBust: true,
}).then((response) => { }).then(response => {
if (response && response.data && response.data.getMe) { if (response && response.data && response.data.getMe) {
const tk = response.data.getMe[0].token; const tk = response.data.getMe[0].token;
this.globalConfig.token = tk; this.globalConfig.token = tk;
const url=window.location.href; //获取当前页面的url const url = window.location.href; //获取当前页面的url
if(url.indexOf("&code")!=-1){ //判断是否存在参数 if (url.indexOf('&code') != -1) {
//判断是否存在参数
url = url.replace(/(\&code|#)[^'"]*/, ''); //去除参数 url = url.replace(/(\&code|#)[^'"]*/, ''); //去除参数
window.history.pushState({},0,url); window.history.pushState({}, 0, url);
} }
this.isSignIn = true; this.isSignIn = true;
this.getUserInfoAndConfig(); this.getUserInfoAndConfig();
...@@ -284,9 +356,9 @@ class Login { ...@@ -284,9 +356,9 @@ class Login {
this.handleLoginError(); this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码"); // msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message); // msgUtils.fault("登录失败," + error.message);
this.hasTry = true //已经输错过密码 this.hasTry = true; //已经输错过密码
} }
}) });
} }
otherLoginIn(usr, pwd) { otherLoginIn(usr, pwd) {
...@@ -294,15 +366,15 @@ class Login { ...@@ -294,15 +366,15 @@ class Login {
password = decode(pwd.substring(0, pwd.length - 3)); password = decode(pwd.substring(0, pwd.length - 3));
Http.generateToken({ Http.generateToken({
query: { query: {
f: "json", f: 'json',
expiration: this.globalConfig.expiration, //token过期时间(单位:秒) expiration: this.globalConfig.expiration, //token过期时间(单位:秒)
client: "referer", client: 'referer',
username: uesrName, username: uesrName,
password: sha1(password).toUpperCase(), password: sha1(password).toUpperCase(),
referer: this.globalConfig.client, referer: this.globalConfig.client,
skipMenuTest: 1 skipMenuTest: 1,
}, },
cacheBust: true cacheBust: true,
}).then(response => { }).then(response => {
if (response && response.data && response.data.token) { if (response && response.data && response.data.token) {
const tk = response.data.token; // token一天不过期 const tk = response.data.token; // token一天不过期
...@@ -311,14 +383,18 @@ class Login { ...@@ -311,14 +383,18 @@ class Login {
query: { query: {
token: tk, token: tk,
subOID: 'subOID', subOID: 'subOID',
site: this.getLocalSiteBytoken(tk) site: this.getLocalSiteBytoken(tk),
}, },
cacheBust: true, cacheBust: true,
ignoreSite: true ignoreSite: true,
}).then(function (response) { }).then(function(response) {
if (response && response.data && response.data.errMsg) { if (response && response.data && response.data.errMsg) {
this.globalConfig.userInfo = {}; this.globalConfig.userInfo = {};
if (response.data.Groups && response.data.Groups instanceof Array && response.data.Groups.length) { if (
response.data.Groups &&
response.data.Groups instanceof Array &&
response.data.Groups.length
) {
this.globalConfig.userInfo.Groups = response.data.Groups; this.globalConfig.userInfo.Groups = response.data.Groups;
} }
this.getUserInfoAndConfig(); this.getUserInfoAndConfig();
...@@ -327,119 +403,149 @@ class Login { ...@@ -327,119 +403,149 @@ class Login {
} else { } else {
_this.handleLoginError(); _this.handleLoginError();
// msgUtils.fault("登录失败,请检查用户名或密码"); // msgUtils.fault("登录失败,请检查用户名或密码");
msgUtils.fault("登录失败," + error.message); msgUtils.fault('登录失败,' + error.message);
_this.hasTry = true //已经输错过密码 _this.hasTry = true; //已经输错过密码
} }
}) });
} }
getUserInfoAndConfig(failCallback, flag, industry) { getUserInfoAndConfig(failCallback, flag, industry) {
debugger;
const token = this.globalConfig.token; const token = this.globalConfig.token;
const site = Cookies.get("site") const site = Cookies.get('site');
let _industrySite = null; let _industrySite = null;
if(_industrySite) { if (industry) {
let userInfo = this.globalConfig.userInfo && this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups instanceof Array ? this.globalConfig.userInfo.Groups.find(enter => { let userInfo =
this.globalConfig.userInfo &&
this.globalConfig.userInfo.Groups &&
this.globalConfig.userInfo.Groups instanceof Array
? this.globalConfig.userInfo.Groups.find(enter => {
return enter.industry === industry; return enter.industry === industry;
}) : null; })
: null;
if(userInfo) { if (userInfo) {
this.globalConfig.userInfo = { this.globalConfig.userInfo = {
site: _enter.site ? _enter.site : null, site: userInfo.site ? userInfo.site : null,
Groups: this.globalConfig.userInfo.Groups Groups: this.globalConfig.userInfo.Groups,
}; };
_industrySite = userInfo.site ? userInfo.site : null; _industrySite = userInfo.site ? userInfo.site : null;
} }
} else if(!!site && this.isSignIn) { } else if (!!site && this.isSignIn) {
this.globalConfig.userInfo = { this.globalConfig.userInfo = {
site: decodeURIComponent(decode(site)), site: decodeURIComponent(decode(site)),
Groups: this.globalConfig.userInfo && this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups instanceof Array ? this.globalConfig.userInfo.Groups : null Groups:
this.globalConfig.userInfo &&
this.globalConfig.userInfo.Groups &&
this.globalConfig.userInfo.Groups instanceof Array
? this.globalConfig.userInfo.Groups
: null,
}; };
} }
this.updateConfig && this.updateConfig(this.globalConfig) this.updateConfig && this.updateConfig(this.globalConfig);
if(this.isSignIn || !!industry) { if (this.isSignIn || !!industry) {
Http.getUserInfo({ Http.getUserInfo({
token: token, token: token,
subOID: 'subOID', subOID: 'subOID',
industry: industry, industry: industry,
site: _industrySite ? _industrySite : this.getLocalSiteBytoken(token), site: _industrySite ? _industrySite : this.getLocalSiteBytoken(token),
'request.preventCache': Date.now() 'request.preventCache': Date.now(),
}).then(response => { })
.then(response => {
try { try {
debugger;
if (response && !response.errMsg) { if (response && !response.errMsg) {
this.globalConfig.userInfo = Object.assign({}, response, this.globalConfig.userInfo); this.globalConfig.userInfo = Object.assign(
Cookies.set("site", this.globalConfig.userInfo.site) {},
response,
this.globalConfig.userInfo,
);
// Cookies.set('site', this.globalConfig.userInfo.site);
this.writeLogs(); this.writeLogs();
this.getIndustry(flag, token); this.getIndustry(flag, token);
} else { } else {
if (this.goLogin()) { if (this.goLogin()) {
return false; return false;
} }
_this.handleLoginError(failCallback); _this.handleLoginError(failCallback);
} }
this.updateConfig && this.updateConfig(this.globalConfig) this.updateConfig && this.updateConfig(this.globalConfig);
}catch(error) { } catch (error) {
console.log(error) if (this.goLogin()) {
return false;
}
this.handleLoginError(failCallback);
console.log(error);
} }
}).catch(error => {
console.log(error)
}) })
.catch(error => {
if (this.goLogin()) {
return false;
}
this.handleLoginError(failCallback);
console.log(error);
});
} else { } else {
try { try {
this.writeLogs() this.writeLogs();
this.getIndustry(flag, token) debugger;
}catch(error) { this.getIndustry(flag, token);
console.log(error) } catch (error) {
if (this.goLogin()) {
return false;
}
this.handleLoginError(failCallback);
console.log(error);
} }
} }
} }
login(usr, pwd, userPhone, isRememberPWD) { login(usr, pwd, userPhone, isRememberPWD) {
Http.generateToken({ Http.generateToken({
f: "json", f: 'json',
expiration: this.globalConfig.expiration, //token过期时间(单位:秒) expiration: this.globalConfig.expiration, //token过期时间(单位:秒)
client: "referer", client: 'referer',
username: usr, username: usr,
password: sha1(pwd).toUpperCase(), password: sha1(pwd).toUpperCase(),
referer: this.globalConfig.client, referer: this.globalConfig.client,
skipMenuTest: 1, skipMenuTest: 1,
userPhone: userPhone, userPhone: userPhone,
'request.preventCache': Date.now() 'request.preventCache': Date.now(),
}).then(response => { })
if(response && response.token) { .then(response => {
const token = response.token debugger;
Cookies.set("token", token); if (response && response.token) {
const exp = 86400000 const token = response.token;
this.globalConfig.token = token Cookies.set('token', token);
if(isRememberPWD) { const exp = 86400000;
this.globalConfig.token = token;
if (isRememberPWD) {
Cookies.set(this.globalConfig.client, token, { Cookies.set(this.globalConfig.client, token, {
expires: exp / (24 * 60 * 60 * 1000), expires: exp / (24 * 60 * 60 * 1000),
path: "/" path: '/',
}) });
Cookies.set("token", token, { Cookies.set('token', token, {
expires: exp / (24 * 60 * 60 * 1000), expires: exp / (24 * 60 * 60 * 1000),
path: "/" path: '/',
}) });
} }
this.isSignIn = true this.isSignIn = true;
this.getUserInfoAndConfig() this.updateConfig && this.updateConfig(this.globalConfig);
this.updateConfig && this.updateConfig(this.globalConfig) this.getUserInfoAndConfig();
} else { } else {
console.log("登录失败", response.message) console.log('登录失败', response.message);
this.hasTry = true this.hasTry = true;
} }
}).catch(error => {
this.handleLoginError()
console.log("登录失败", error.message)
this.hasTry = true
}) })
.catch(error => {
this.handleLoginError();
console.log('登录失败', error.message);
this.hasTry = true;
});
} }
} }
export default Login; export default Login;
import BasicLayout from '../layouts/BasicLayout'; import BasicLayout from '../layouts/BasicLayout';
import UserLayout from '../layouts/UserLayout'; import UserLayout from '../layouts/UserLayout';
import BootPage from '../pages/bootpage';
import Login from '../pages/user/login'; import Login from '../pages/user/login';
import Welcome from '../pages/Welcome';
export default { export const dyRoutes = routes => {
const dyRoutes = routes;
return {
routes: [ routes: [
{ {
path: '/user', path: '/civbase/user',
component: UserLayout, component: UserLayout,
routes: [ routes: [
{ {
name: 'login', name: 'login',
path: '/user/login', path: '/civbase/user/login',
component: Login, component: Login,
}, },
], ],
}, },
{
// path: '/web5/?client=city',
path: '/',
component: BasicLayout,
routes: [
{ {
path: '/Welcome/1', path: '/civbase/industry',
name: 'blank', component: BootPage,
component: Welcome,
}, },
], {
path: '/civbase',
component: BasicLayout,
routes: [...dyRoutes],
}, },
// ...routes
], ],
};
}; };
...@@ -3,37 +3,46 @@ ...@@ -3,37 +3,46 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports["default"] = void 0; exports.dyRoutes = void 0;
var _BasicLayout = _interopRequireDefault(require("../layouts/BasicLayout")); var _BasicLayout = _interopRequireDefault(require("../layouts/BasicLayout"));
var _UserLayout = _interopRequireDefault(require("../layouts/UserLayout")); var _UserLayout = _interopRequireDefault(require("../layouts/UserLayout"));
var _login = _interopRequireDefault(require("../pages/user/login")); var _bootpage = _interopRequireDefault(require("../pages/bootpage"));
var _Welcome = _interopRequireDefault(require("../pages/Welcome")); var _login = _interopRequireDefault(require("../pages/user/login"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = { function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var dyRoutes = function dyRoutes(routes) {
var dyRoutes = routes;
return {
routes: [{ routes: [{
path: '/user', path: '/civbase/user',
component: _UserLayout["default"], component: _UserLayout["default"],
routes: [{ routes: [{
name: 'login', name: 'login',
path: '/user/login', path: '/civbase/user/login',
component: _login["default"] component: _login["default"]
}] }]
}, { }, {
// path: '/web5/?client=city', path: '/civbase/industry',
path: '/', component: _bootpage["default"]
}, {
path: '/civbase',
component: _BasicLayout["default"], component: _BasicLayout["default"],
routes: [{ routes: _toConsumableArray(dyRoutes)
path: '/Welcome/1',
name: 'blank',
component: _Welcome["default"]
}] }]
} // ...routes };
]
}; };
exports["default"] = _default;
\ No newline at end of file exports.dyRoutes = dyRoutes;
\ No newline at end of file
// const mockRoutes = [
// {
// label: '运营总览',
// shortName: 'BI',
// icon: 'assets/images/menuNew/02二级图标/运营总览.svg',
// url:
// 'productex/water/IOTPump/RunOverView/RunOverView|BIZoom=14&userAccess=true',
// config: '',
// },
// {
// widgets: [
// {
// label: '泵房监控',
// shortName: '泵房',
// icon: 'assets/images/menuNew/02二级图标/泵房监控.svg',
// url:
// 'productex/water/IOTMonitor/DeviceMonitorPump/DeviceMonitorPump|device=二供泵房-二供机组&pageSize=20&showLegend=true',
// config: '',
// },
// {
// label: '泵房分布',
// shortName: '地图',
// icon: 'assets/images/menuNew/02二级图标/地图监控.svg',
// url:
// 'productex/water/IOTMonitor/MapMonitor/MapMonitor|scales=10,14,15&device=二供泵房&zoom=11',
// config: '',
// },
// {
// label: '实时数据',
// shortName: '实时',
// icon: 'assets/images/menuNew/02二级图标/数据监控.svg',
// url:
// 'productex/water/IOTMonitor/DataMonitor/DataMonitor|device=二供泵房-二供机组',
// config: '',
// },
// {
// label: '历史数据',
// shortName: '日志',
// icon: 'assets/images/menuNew/02二级图标/运行日志.svg',
// url:
// 'productex/water/IOTMonitor/RunLogHistory/RunLogHistory|device=二供泵房-二供机组',
// config: '',
// },
// ],
// label: '数据监控',
// shortName: '数据',
// icon: 'assets/images/menuNew/02二级图标/经济性分析.svg',
// },
// {
// widgets: [
// {
// label: '视频监控',
// shortName: '视频',
// icon: 'assets/images/menuNew/02二级图标/视频监控.svg',
// url:
// 'product/oms/VideoListAll/VideoListAll|device=二供泵房&project=panda_egbf&control=true',
// config: '',
// },
// {
// label: '门禁监控',
// shortName: '门禁',
// icon: 'assets/images/menuNew/02二级图标/门禁监控.svg',
// url:
// 'productex/water/IOTMonitor/SafetyMonitor/devicedoor/devicedoor|device=二供泵房',
// config: '',
// },
// {
// label: '红外监控',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/报警监控.svg',
// url:
// 'product/maintenance/AccountManage/AccountManage|name=红外监控&state=scan',
// config: '',
// },
// ],
// label: '安防监控',
// shortName: '安防',
// icon: 'assets/images/menuNew/02二级图标/安防监控.svg',
// },
// {
// widgets: [
// {
// label: '泵房全景',
// shortName: '全景',
// icon: 'assets/images/menuNew/02二级图标/二供工艺.svg',
// url: 'productex/water/IOTMonitor/panoramaMonitor/panoramaMonitor',
// config: '',
// },
// {
// label: '三维展示',
// shortName: '三维',
// icon: 'assets/images/menu/ps/监控管理.png',
// url: 'threedimensional/product/ShowPumpGL/ShowPumpGL',
// config: '',
// },
// {
// label: '工艺绘制',
// shortName: '组态',
// icon: 'assets/images/menu/webgis/二级菜单/normal/大口径管段展示.png',
// url: 'configuration/ConfigurationsSageView/ConfigurationsSageView',
// config: '',
// },
// ],
// label: '三维全景',
// shortName: '全景',
// icon: 'assets/images/menuNew/02二级图标/水源井巡视.svg',
// },
// {
// widgets: [
// {
// label: '智能巡检',
// shortName: '智检',
// icon: 'assets/images/menu/webgis/二级菜单/功能窗口/条件查询.png',
// url: 'productex/water/IOTPump/PumpPatrol/PumpPatrol',
// config: '',
// },
// {
// label: '异常诊断',
// shortName: '报警',
// icon: 'assets/images/menuNew/02二级图标/安防监控.svg',
// url:
// 'productex/water/IOTMonitor/RealTimeAlarm/RealTimeAlarm|device=二供:二供泵房-二供机组',
// config: '',
// },
// {
// label: '报警记录',
// shortName: '记录',
// icon: 'assets/images/menuNew/02二级图标/台账管理.svg',
// url:
// 'productex/water/IOTMonitor/AlarmRecord/AlarmRecord|device=二供:二供泵房-二供机组&dataDictionary=报警监控筛选条件',
// config: '',
// },
// {
// label: '报警方案',
// shortName: '方案',
// icon: 'assets/images/menuNew/02二级图标/工艺监控.svg',
// url:
// 'productex/water/IOTMonitor/AlertInfoManage/AlertInfoManage|isDemo=true',
// config: '',
// },
// {
// label: '报警分析',
// shortName: '分析',
// icon: 'assets/images/menuNew/02二级图标/运行状态.svg',
// url: 'product/bi/DemoWidget/DemoView|imgName=报警分析.png',
// config: '',
// },
// ],
// label: '故障诊断',
// shortName: '报警',
// icon: 'assets/images/menuNew/02二级图标/报警监控.svg',
// },
// {
// widgets: [
// {
// label: '维保标准',
// shortName: '标准',
// icon: 'assets/images/menuNew/02二级图标/维保管理.svg',
// url:
// 'product/introduction/deviceIntroduction/introductionFile|accountName=泵房维保标准表&nodeName=阀门,仪器仪表,控制柜,机组,其他设施&titleName=熊猫泵房维保标准',
// config: '',
// },
// {
// label: '管理制度',
// shortName: '制度',
// icon: 'assets/images/menu/合同管理.png',
// url: 'product/pumpManageV3/BusinessManage/PumpRules/PumpRules',
// config: '',
// },
// {
// label: '维保日历',
// shortName: '日历',
// icon: 'assets/images/menuNew/02二级图标/调度日志.svg',
// url: 'productex/water/IOTPump/MaintenanceCalendar/MaintenanceCalendar',
// config: '',
// },
// {
// label: '维保反馈',
// shortName: '维保',
// icon: 'assets/images/menuNew/02二级图标/维保管理.svg',
// url:
// 'productex/water/IOTMonitor/BusinessManage/BusinessManage|device=二供泵房&plate=巡检:二供巡检,保养:二供维保,维修:二供维修,水箱清洗:二供水箱清洗',
// config: '',
// },
// {
// label: '业务总览',
// shortName: '总览',
// icon: 'assets/images/menuNew/02二级图标/运营总览.svg',
// url:
// 'productex/water/IOTPump/BusinessOverview/BusinessOverview|businessType=',
// config: '',
// },
// {
// label: '生命周期',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/运行状态.svg',
// url: 'productex/water/IOTPump/MaintenanceRecords/MaintenanceRecords',
// config: '',
// },
// ],
// label: '生命周期',
// shortName: '生命',
// icon: 'assets/images/menuNew/OA/业绩总览.svg',
// },
// {
// widgets: [
// {
// label: '维保总览',
// shortName: '',
// icon: 'assets/images/menu/统计3.0.png',
// url: 'product/devicePlan/BusinessOverview/BusinessOverview',
// config: '',
// },
// {
// label: '维保模板',
// shortName: '模板',
// icon: 'assets/images/menu/工程管理.png',
// url:
// 'product/devicePlan/TemplatesManage/TemplatesManage|businessType=&businessName=',
// config: '',
// },
// {
// label: '维保计划',
// shortName: '计划',
// icon: 'assets/images/menu/签证管理.png',
// url: 'product/devicePlan/PlanManage/PlanManage',
// config: '',
// },
// {
// label: '维保任务',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/水源井巡视.svg',
// url:
// 'product/devicePlan/TaskOverview/TaskOverview|businessType=&businessName=',
// config: '',
// },
// {
// label: '维保轨迹',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/地图监控.svg',
// url: 'product/patrol/PatrolTrace/PatrolTrace',
// config: '',
// },
// ],
// label: '泵房维保',
// shortName: '维保',
// icon: 'assets/images/menuNew/02二级图标/报警方案.svg',
// },
// {
// widgets: [
// {
// label: '专家方案库',
// shortName: '方案库',
// icon: 'assets/images/menuNew/02二级图标/设备管理.svg',
// url: 'project/water/pandaDemo/ExpertPlanOverview/ExpertPlanOverview',
// config: '',
// },
// {
// label: '方案管理',
// shortName: '管理',
// icon: 'assets/images/menuNew/02二级图标/维保管理.svg',
// url: 'project/water/pandaDemo/ProjectManageDemo/ProjectManageDemo',
// config: '',
// },
// {
// label: '抢维修总览',
// shortName: '',
// icon: 'assets/images/menu/工程查询.png',
// url: 'Product/Maintenance/HomePage/HomePageCloud',
// config: '',
// },
// {
// label: '报警上报',
// shortName: '',
// icon: 'assets/images/menu/日志3.0.png',
// url:
// 'product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=系统报警',
// config: '',
// },
// {
// label: '抢修上报',
// shortName: '',
// icon: 'assets/images/menu/变更管理.png',
// url:
// 'product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=抢修上报',
// config: '',
// },
// {
// label: '检修上报',
// shortName: '',
// icon: 'assets/images/menu/监控3.0.png',
// url:
// 'product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=检修上报',
// config: '',
// },
// {
// label: '工单办理',
// shortName: '',
// icon: 'assets/images/menu/工程管理.png',
// url:
// 'product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0',
// config: '',
// },
// {
// label: '工单总览',
// shortName: '',
// icon: 'assets/images/menu/合同管理.png',
// url: 'product/maintenance/CaseManage/CaseOverviewBox/CaseOverviewBox',
// config: '',
// },
// {
// label: '事件总览',
// shortName: '',
// icon: 'assets/images/menu/任务管理.png',
// url:
// 'product/maintenance/EventManage/EventOverviewBox/EventOverviewListView',
// config: '',
// },
// ],
// label: '泵房维修',
// shortName: '工单',
// icon: 'assets/images/menuNew/02二级图标/调度监控.svg',
// },
// {
// widgets: [
// {
// label: '能耗统计',
// shortName: '能耗',
// icon: 'assets/images/menuNew/02二级图标/能耗分析.svg',
// url:
// 'productex/water/IOTMonitor/EnergyAnalysis/EnergyAnalysis|device=二供泵房-二供机组&targetName=出水累计流量,累计电量',
// config: '',
// },
// {
// label: '运行评价',
// shortName: '评价',
// icon: 'assets/images/menuNew/02二级图标/运行评价.svg',
// url:
// 'productex/water/IOTMonitor/OperationAnalysis/OperationAnalysis|device=二供泵房&deviceType=二供泵房&targetName=出水累计流量,累计电量&intervals=0,0.3,0.6,1.2',
// config: '',
// },
// {
// label: '比泵分析',
// shortName: '比泵',
// icon: 'assets/images/menuNew/02二级图标/经济性分析.svg',
// url:
// 'productex/water/IOTRawWater/PumpEconomicAnalysis/PumpEconomicAnalysis|device=二供泵房&targetName=累计电量,出水累计流量&price=0.7&water=200',
// config: '',
// },
// {
// label: '运行概况',
// shortName: '概况',
// icon: 'assets/images/menuNew/02二级图标/运行概况.svg',
// url:
// 'productex/water/IOTMonitor/RunStatus/RunStatus|device=二供泵房&targetName=出水累计流量,累计电量',
// config: '',
// },
// {
// label: '供水分析',
// shortName: '供水',
// icon: 'assets/images/menuNew/02二级图标/运行分析.svg',
// url:
// 'productex/water/IOTMonitor/TrafficAnalysis/TrafficAnalysis|device=二供泵房&targetName=出水累计流量_供水量:Sub',
// config: '',
// },
// {
// label: '用电分析',
// shortName: '用电',
// icon: 'assets/images/menuNew/02二级图标/运行分析.svg',
// url:
// 'productex/water/IOTMonitor/TrafficAnalysis/TrafficAnalysis|device=二供泵房&targetName=累计电量_用电量:Sub',
// config: '',
// },
// ],
// label: '能耗分析',
// shortName: '能耗',
// icon: 'assets/images/menuNew/02二级图标/能耗分析.svg',
// },
// {
// widgets: [
// {
// label: '夜间小流量',
// shortName: '小流量',
// icon: 'assets/images/menuNew/02二级图标/运行日志.svg',
// url:
// 'productex/water/IOTPump/NightLowFlow/NightLowFlow|device=二供泵房&flowName=出水瞬时流量',
// config: '',
// },
// {
// label: '漏损排行榜',
// shortName: '漏损',
// icon: 'assets/images/menuNew/02二级图标/运行状态.svg',
// url:
// 'productex/water/IOTPump/LeakageAnalysis/LeakageAnalysis|device=二供泵房&flowName1=出水累计流量&flowName2=出水瞬时流量&leakRate=20&timeType=day',
// config: '',
// },
// {
// label: '等水压分布',
// shortName: '水压',
// icon: 'assets/images/menuNew/02二级图标/调度方案.svg',
// url: 'project/water/qingpu/EquiscalarLine/EquiscalarLine',
// config: '等水压线分布',
// },
// ],
// label: '漏损分析',
// shortName: '漏损',
// icon: 'assets/images/menuNew/02二级图标/能耗分析.svg',
// },
// {
// widgets: [
// {
// label: '泵房信息',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/台账管理.svg',
// url: 'product/maintenance/AccountManage/AccountManage|name=二供泵房',
// config: '',
// },
// {
// label: '机组信息',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/台账管理.svg',
// url: 'product/maintenance/AccountManage/AccountManage|name=二供机组',
// config: '',
// },
// {
// label: '门禁台账',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/台账管理.svg',
// url: 'product/maintenance/AccountManage/AccountManage|name=二供门禁',
// config: '',
// },
// {
// label: '维保标准',
// shortName: '',
// icon: 'assets/images/menuNew/02二级图标/台账管理.svg',
// url:
// 'product/maintenance/AccountManage/AccountManage|name=泵房维保标准表',
// config: '',
// },
// ],
// label: '设施管理',
// shortName: '资产',
// icon: 'assets/images/menuNew/02二级图标/设备管理.svg',
// },
// {
// widgets: [
// {
// label: '设备分组',
// shortName: '分组',
// icon: 'assets/images/menu/专项养护管理.png',
// url: 'product/oms/deviceGroup/deviceGroup',
// config: '',
// },
// {
// label: '控制权限',
// shortName: '控制',
// icon: 'assets/images/menu/检漏计划.png',
// url:
// 'product/pumpManageV3/MemberTaskStatistic/AuthorityConfig/AuthorityConfig',
// config: '',
// },
// {
// label: '展示配置',
// shortName: '展示',
// icon: 'assets/images/menu/工程管理.png',
// url: 'productex/water/IOTConfSetting/EditMenu/EditMenu',
// config: '',
// },
// {
// label: '权限配置',
// shortName: '权限',
// icon: 'assets/images/menu/default.png',
// url: 'product/oms/deviceGroup/deviceGroup',
// config: '',
// },
// {
// label: '视频配置',
// shortName: '视频',
// icon: 'assets/images/menu/监控3.0.png',
// url: 'product/oms/VideoConfig/VideoConfig',
// config: '',
// },
// ],
// label: '系统设置',
// shortName: '设置',
// icon: 'assets/images/menu/巡检设置.png',
// },
// ];
const mockRoutes = [
{
"widgets":[
{
"label":"运营总览",
"shortName":"BI",
"icon":"assets/images/menuNew/02二级图标/运营总览.svg",
"url":"productex/water/IOTPump/RunOverView/RunOverView|BIZoom=14&userAccess=true",
"config":""
},
{
"widgets":[
{
"label":"泵房监控",
"shortName":"泵房",
"icon":"assets/images/menuNew/02二级图标/泵房监控.svg",
"url":"productex/water/IOTMonitor/DeviceMonitorPump/DeviceMonitorPump|device=二供泵房-二供机组&pageSize=20&showLegend=true",
"config":""
},
{
"label":"泵房分布",
"shortName":"地图",
"icon":"assets/images/menuNew/02二级图标/地图监控.svg",
"url":"productex/water/IOTMonitor/MapMonitor/MapMonitor|scales=10,14,15&device=二供泵房&zoom=11",
"config":""
},
{
"label":"实时数据",
"shortName":"实时",
"icon":"assets/images/menuNew/02二级图标/数据监控.svg",
"url":"productex/water/IOTMonitor/DataMonitor/DataMonitor|device=二供泵房-二供机组",
"config":""
},
{
"label":"历史数据",
"shortName":"日志",
"icon":"assets/images/menuNew/02二级图标/运行日志.svg",
"url":"productex/water/IOTMonitor/RunLogHistory/RunLogHistory|device=二供泵房-二供机组",
"config":""
}
],
"label":"数据监控",
"shortName":"数据",
"icon":"assets/images/menuNew/02二级图标/经济性分析.svg"
},
{
"widgets":[
{
"label":"视频监控",
"shortName":"视频",
"icon":"assets/images/menuNew/02二级图标/视频监控.svg",
"url":"product/oms/VideoListAll/VideoListAll|device=二供泵房&project=panda_egbf&control=true",
"config":""
},
{
"label":"门禁监控",
"shortName":"门禁",
"icon":"assets/images/menuNew/02二级图标/门禁监控.svg",
"url":"productex/water/IOTMonitor/SafetyMonitor/devicedoor/devicedoor|device=二供泵房",
"config":""
},
{
"label":"红外监控",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/报警监控.svg",
"url":"product/maintenance/AccountManage/AccountManage|name=红外监控&state=scan",
"config":""
}
],
"label":"安防监控",
"shortName":"安防",
"icon":"assets/images/menuNew/02二级图标/安防监控.svg"
},
{
"widgets":[
{
"label":"泵房全景",
"shortName":"全景",
"icon":"assets/images/menuNew/02二级图标/二供工艺.svg",
"url":"productex/water/IOTMonitor/panoramaMonitor/panoramaMonitor",
"config":""
},
{
"label":"三维展示",
"shortName":"三维",
"icon":"assets/images/menu/ps/监控管理.png",
"url":"threedimensional/product/ShowPumpGL/ShowPumpGL",
"config":""
},
{
"label":"工艺绘制",
"shortName":"组态",
"icon":"assets/images/menu/webgis/二级菜单/normal/大口径管段展示.png",
"url":"configuration/ConfigurationsSageView/ConfigurationsSageView",
"config":""
}
],
"label":"三维全景",
"shortName":"全景",
"icon":"assets/images/menuNew/02二级图标/水源井巡视.svg"
},
{
"widgets":[
{
"label":"智能巡检",
"shortName":"智检",
"icon":"assets/images/menu/webgis/二级菜单/功能窗口/条件查询.png",
"url":"productex/water/IOTPump/PumpPatrol/PumpPatrol",
"config":""
},
{
"label":"异常诊断",
"shortName":"报警",
"icon":"assets/images/menuNew/02二级图标/安防监控.svg",
"url":"productex/water/IOTMonitor/RealTimeAlarm/RealTimeAlarm|device=二供:二供泵房-二供机组",
"config":""
},
{
"label":"报警记录",
"shortName":"记录",
"icon":"assets/images/menuNew/02二级图标/台账管理.svg",
"url":"productex/water/IOTMonitor/AlarmRecord/AlarmRecord|device=二供:二供泵房-二供机组&dataDictionary=报警监控筛选条件",
"config":""
},
{
"label":"报警方案",
"shortName":"方案",
"icon":"assets/images/menuNew/02二级图标/工艺监控.svg",
"url":"productex/water/IOTMonitor/AlertInfoManage/AlertInfoManage|isDemo=true",
"config":""
},
{
"label":"报警分析",
"shortName":"分析",
"icon":"assets/images/menuNew/02二级图标/运行状态.svg",
"url":"product/bi/DemoWidget/DemoView|imgName=报警分析.png",
"config":""
}
],
"label":"故障诊断",
"shortName":"报警",
"icon":"assets/images/menuNew/02二级图标/报警监控.svg"
},
{
"widgets":[
{
"label":"维保标准",
"shortName":"标准",
"icon":"assets/images/menuNew/02二级图标/维保管理.svg",
"url":"product/introduction/deviceIntroduction/introductionFile|accountName=泵房维保标准表&nodeName=阀门,仪器仪表,控制柜,机组,其他设施&titleName=熊猫泵房维保标准",
"config":""
},
{
"label":"管理制度",
"shortName":"制度",
"icon":"assets/images/menu/合同管理.png",
"url":"product/pumpManageV3/BusinessManage/PumpRules/PumpRules",
"config":""
},
{
"label":"维保日历",
"shortName":"日历",
"icon":"assets/images/menuNew/02二级图标/调度日志.svg",
"url":"productex/water/IOTPump/MaintenanceCalendar/MaintenanceCalendar",
"config":""
},
{
"label":"维保反馈",
"shortName":"维保",
"icon":"assets/images/menuNew/02二级图标/维保管理.svg",
"url":"productex/water/IOTMonitor/BusinessManage/BusinessManage|device=二供泵房&plate=巡检:二供巡检,保养:二供维保,维修:二供维修,水箱清洗:二供水箱清洗",
"config":""
},
{
"label":"业务总览",
"shortName":"总览",
"icon":"assets/images/menuNew/02二级图标/运营总览.svg",
"url":"productex/water/IOTPump/BusinessOverview/BusinessOverview|businessType=",
"config":""
},
{
"label":"生命周期",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/运行状态.svg",
"url":"productex/water/IOTPump/MaintenanceRecords/MaintenanceRecords",
"config":""
}
],
"label":"生命周期",
"shortName":"生命",
"icon":"assets/images/menuNew/OA/业绩总览.svg"
},
{
"widgets":[
{
"label":"维保总览",
"shortName":"",
"icon":"assets/images/menu/统计3.0.png",
"url":"product/devicePlan/BusinessOverview/BusinessOverview",
"config":""
},
{
"label":"维保模板",
"shortName":"模板",
"icon":"assets/images/menu/工程管理.png",
"url":"product/devicePlan/TemplatesManage/TemplatesManage|businessType=&businessName=",
"config":""
},
{
"label":"维保计划",
"shortName":"计划",
"icon":"assets/images/menu/签证管理.png",
"url":"product/devicePlan/PlanManage/PlanManage",
"config":""
},
{
"label":"维保任务",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/水源井巡视.svg",
"url":"product/devicePlan/TaskOverview/TaskOverview|businessType=&businessName=",
"config":""
},
{
"label":"维保轨迹",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/地图监控.svg",
"url":"product/patrol/PatrolTrace/PatrolTrace",
"config":""
}
],
"label":"泵房维保",
"shortName":"维保",
"icon":"assets/images/menuNew/02二级图标/报警方案.svg"
},
{
"widgets":[
{
"label":"专家方案库",
"shortName":"方案库",
"icon":"assets/images/menuNew/02二级图标/设备管理.svg",
"url":"project/water/pandaDemo/ExpertPlanOverview/ExpertPlanOverview",
"config":""
},
{
"label":"方案管理",
"shortName":"管理",
"icon":"assets/images/menuNew/02二级图标/维保管理.svg",
"url":"project/water/pandaDemo/ProjectManageDemo/ProjectManageDemo",
"config":""
},
{
"label":"抢维修总览",
"shortName":"",
"icon":"assets/images/menu/工程查询.png",
"url":"Product/Maintenance/HomePage/HomePageCloud",
"config":""
},
{
"label":"报警上报",
"shortName":"",
"icon":"assets/images/menu/日志3.0.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=系统报警",
"config":""
},
{
"label":"抢修上报",
"shortName":"",
"icon":"assets/images/menu/变更管理.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=抢修上报",
"config":""
},
{
"label":"检修上报",
"shortName":"",
"icon":"assets/images/menu/监控3.0.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=检修上报",
"config":""
},
{
"label":"工单办理",
"shortName":"",
"icon":"assets/images/menu/工程管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0",
"config":""
},
{
"label":"工单总览",
"shortName":"",
"icon":"assets/images/menu/合同管理.png",
"url":"product/maintenance/CaseManage/CaseOverviewBox/CaseOverviewBox",
"config":""
},
{
"label":"事件总览",
"shortName":"",
"icon":"assets/images/menu/任务管理.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView",
"config":""
},
{
"label":"水箱清洗",
"shortName":"",
"icon":"assets/images/menuNew/DMA图标/02二级菜单/6-3漏点修复.svg",
"url":"project/water/wenzhou/tankDetergent/tankDetergent",
"config":""
}
],
"label":"泵房维修",
"shortName":"工单",
"icon":"assets/images/menuNew/02二级图标/调度监控.svg"
},
{
"widgets":[
{
"label":"能耗统计",
"shortName":"能耗",
"icon":"assets/images/menuNew/02二级图标/能耗分析.svg",
"url":"productex/water/IOTMonitor/EnergyAnalysis/EnergyAnalysis|device=二供泵房-二供机组&targetName=出水累计流量,累计电量",
"config":""
},
{
"label":"运行评价",
"shortName":"评价",
"icon":"assets/images/menuNew/02二级图标/运行评价.svg",
"url":"productex/water/IOTMonitor/OperationAnalysis/OperationAnalysis|device=二供泵房&deviceType=二供泵房&targetName=出水累计流量,累计电量&intervals=0,0.3,0.6,1.2",
"config":""
},
{
"label":"比泵分析",
"shortName":"比泵",
"icon":"assets/images/menuNew/02二级图标/经济性分析.svg",
"url":"productex/water/IOTRawWater/PumpEconomicAnalysis/PumpEconomicAnalysis|device=二供泵房&targetName=累计电量,出水累计流量&price=0.7&water=200",
"config":""
},
{
"label":"运行概况",
"shortName":"概况",
"icon":"assets/images/menuNew/02二级图标/运行概况.svg",
"url":"productex/water/IOTMonitor/RunStatus/RunStatus|device=二供泵房&targetName=出水累计流量,累计电量",
"config":""
},
{
"label":"供水分析",
"shortName":"供水",
"icon":"assets/images/menuNew/02二级图标/运行分析.svg",
"url":"productex/water/IOTMonitor/TrafficAnalysis/TrafficAnalysis|device=二供泵房&targetName=出水累计流量_供水量:Sub",
"config":""
},
{
"label":"用电分析",
"shortName":"用电",
"icon":"assets/images/menuNew/02二级图标/运行分析.svg",
"url":"productex/water/IOTMonitor/TrafficAnalysis/TrafficAnalysis|device=二供泵房&targetName=累计电量_用电量:Sub",
"config":""
}
],
"label":"能耗分析",
"shortName":"能耗",
"icon":"assets/images/menuNew/02二级图标/能耗分析.svg"
},
{
"widgets":[
{
"label":"夜间小流量",
"shortName":"小流量",
"icon":"assets/images/menuNew/02二级图标/运行日志.svg",
"url":"productex/water/IOTPump/NightLowFlow/NightLowFlow|device=二供泵房&flowName=出水瞬时流量",
"config":""
},
{
"label":"漏损排行榜",
"shortName":"漏损",
"icon":"assets/images/menuNew/02二级图标/运行状态.svg",
"url":"productex/water/IOTPump/LeakageAnalysis/LeakageAnalysis|device=二供泵房&flowName1=出水累计流量&flowName2=出水瞬时流量&leakRate=20&timeType=day",
"config":""
},
{
"label":"等水压分布",
"shortName":"水压",
"icon":"assets/images/menuNew/02二级图标/调度方案.svg",
"url":"project/water/qingpu/EquiscalarLine/EquiscalarLine",
"config":"等水压线分布"
}
],
"label":"漏损分析",
"shortName":"漏损",
"icon":"assets/images/menuNew/02二级图标/能耗分析.svg"
},
{
"widgets":[
{
"label":"泵房信息",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/台账管理.svg",
"url":"product/maintenance/AccountManage/AccountManage|name=二供泵房",
"config":""
},
{
"label":"机组信息",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/台账管理.svg",
"url":"product/maintenance/AccountManage/AccountManage|name=二供机组",
"config":""
},
{
"label":"门禁台账",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/台账管理.svg",
"url":"product/maintenance/AccountManage/AccountManage|name=二供门禁",
"config":""
},
{
"label":"维保标准",
"shortName":"",
"icon":"assets/images/menuNew/02二级图标/台账管理.svg",
"url":"product/maintenance/AccountManage/AccountManage|name=泵房维保标准表",
"config":""
}
],
"label":"设施管理",
"shortName":"资产",
"icon":"assets/images/menuNew/02二级图标/设备管理.svg"
},
{
"widgets":[
{
"label":"设备分组",
"shortName":"分组",
"icon":"assets/images/menu/专项养护管理.png",
"url":"product/oms/deviceGroup/deviceGroup",
"config":""
},
{
"label":"控制权限",
"shortName":"控制",
"icon":"assets/images/menu/检漏计划.png",
"url":"product/pumpManageV3/MemberTaskStatistic/AuthorityConfig/AuthorityConfig",
"config":""
},
{
"label":"展示配置",
"shortName":"展示",
"icon":"assets/images/menu/工程管理.png",
"url":"productex/water/IOTConfSetting/EditMenu/EditMenu",
"config":""
},
{
"label":"权限配置",
"shortName":"权限",
"icon":"assets/images/menu/default.png",
"url":"product/oms/deviceGroup/deviceGroup",
"config":""
},
{
"label":"视频配置",
"shortName":"视频",
"icon":"assets/images/menu/监控3.0.png",
"url":"product/oms/VideoConfig/VideoConfig",
"config":""
}
],
"label":"系统设置",
"shortName":"设置",
"icon":"assets/images/menu/巡检设置.png"
}
],
"label":"二供管理",
"shortName":"二供",
"icon":"assets/images/menuNew/01一级图标/泵房监控.svg"
},
{
"widgets":[
{
"label":"业务总览",
"shortName":"总览",
"icon":"assets/images/menu/统计3.0.png",
"url":"product/devicePlan/BusinessOverview/BusinessOverview",
"config":""
},
{
"label":"维保模板",
"shortName":"模板",
"icon":"assets/images/menu/工程管理.png",
"url":"product/devicePlan/TemplatesManage/TemplatesManage|businessType=&businessName=",
"config":""
},
{
"label":"维保计划",
"shortName":"计划",
"icon":"assets/images/menu/签证管理.png",
"url":"product/devicePlan/PlanManage/PlanManage",
"config":""
},
{
"label":"巡检任务",
"shortName":"巡检",
"icon":"assets/images/menu/流程管理.png",
"url":"product/devicePlan/TaskManage/TaskManage|businessType=巡检&businessName=",
"config":""
},
{
"label":"维保任务",
"shortName":"任务",
"icon":"assets/images/menu/查询管理.png",
"url":"product/devicePlan/TaskOverview/TaskOverview|businessType=&businessName=",
"config":""
},
{
"label":"任务审核",
"shortName":"审核",
"icon":"assets/images/menu/计划审核.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0&flowName=计划任务送审",
"config":""
},
{
"label":"送审记录",
"shortName":"记录",
"icon":"assets/images/menu/工地建档管理.png",
"url":"product/maintenance/CaseManage/CaseDoneBox/CaseDoneBox|flowName=计划任务送审",
"config":""
},
{
"label":"维保轨迹",
"shortName":"轨迹",
"icon":"assets/images/menu/巡检监控.png",
"url":"product/patrol/PatrolTrace/PatrolTrace",
"config":""
}
],
"label":"维保计划",
"shortName":"维保",
"icon":"assets/images/menu/竞赛管理.png"
},
{
"widgets":[
{
"label":"总览",
"shortName":"总览",
"icon":"assets/images/menu/工程查询.png",
"url":"Product/Maintenance/HomePage/HomePageCloud",
"config":""
},
{
"label":"事件总览",
"shortName":"",
"icon":"assets/images/menu/任务管理.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView",
"config":""
},
{
"label":"工单总览",
"shortName":"",
"icon":"assets/images/menu/合同管理.png",
"url":"product/maintenance/CaseManage/CaseOverviewBox/CaseOverviewBox",
"config":""
},
{
"label":"工单办理",
"shortName":"",
"icon":"assets/images/menu/工程管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0",
"config":""
},
{
"label":"工单日志",
"shortName":"",
"icon":"assets/images/menu/巡检计划.png",
"url":"product/maintenance/CaseManage/CaseDoneBox/CaseDoneBox",
"config":""
},
{
"label":"事件调度",
"shortName":"",
"icon":"assets/images/menu/工程管理.png",
"url":"product/maintenance/EventManage/EventDispatchBox/EventDispatchBoxList",
"config":""
},
{
"widgets":[
{
"label":"报警上报",
"shortName":"报警事件",
"icon":"assets/images/menu/日志3.0.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=系统报警",
"config":""
},
{
"label":"事件总览",
"shortName":"",
"icon":"assets/images/menu/监控3.0.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView|eventType=系统报警",
"config":""
},
{
"label":"工单办理",
"shortName":"",
"icon":"assets/images/menu/工程管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0&flowName=报警处理流程",
"config":""
}
],
"label":"报警事件",
"shortName":"报警事件",
"icon":"assets/images/menu/问题上报.png"
},
{
"widgets":[
{
"label":"事件上报",
"shortName":"事件上报",
"icon":"assets/images/menu/变更管理.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=抢修上报",
"config":""
},
{
"label":"事件总览",
"shortName":"抢修事件",
"icon":"assets/images/menu/检漏计划.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView|eventType=抢修上报",
"config":""
},
{
"label":"工单办理",
"shortName":"工单办理",
"icon":"assets/images/menu/专项养护管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0&flowName=抢修处理流程",
"config":""
}
],
"label":"抢修事件",
"shortName":"抢修事件",
"icon":"assets/images/menu/接送气.png"
},
{
"widgets":[
{
"label":"事件上报",
"shortName":"事件上报",
"icon":"assets/images/menu/监控3.0.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=检修上报",
"config":""
},
{
"label":"事件总览",
"shortName":"事件总览",
"icon":"assets/images/menu/管网管理.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView|eventType=检修上报",
"config":""
},
{
"label":"工单办理",
"shortName":"工单办理",
"icon":"assets/images/menu/合同管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=0&flowName=检修处理流程",
"config":""
}
],
"label":"检修事件",
"shortName":"检修事件",
"icon":"assets/images/menu/工程施工.png"
}
],
"label":"维修管理",
"shortName":"",
"icon":"assets/images/menu/ios/巡检养护.png"
},
{
"widgets":[
{
"label":"调峰监控",
"shortName":"设备",
"icon":"assets/images/menu/pumpcare/一级菜单白色/6-远程监控.png",
"url":"productex/water/IOTMonitor/DeviceMonitor/DeviceMonitor|device=调峰泵站-调峰机组",
"config":""
},
{
"label":"远程控制*",
"shortName":"控制",
"icon":"assets/images/menu/dark/7-综合调度.png",
"url":"productex/water/IOTPump/PeakLoadMonitor/PeakLoadMonitor",
"config":""
},
{
"label":"地图监控",
"shortName":"",
"icon":"assets/images/menu/dark/9-管网GIS.png",
"url":"productex/water/IOTMonitor/MapMonitor/MapMonitor|scales=1,2,4,8&device=调峰泵站",
"config":""
},
{
"label":"数据监控",
"shortName":"数据",
"icon":"assets/images/menu/统计3.0.png",
"url":"productex/water/IOTMonitor/DataMonitor/DataMonitor|device=调峰泵站",
"config":""
},
{
"label":"视频监控",
"shortName":"product/oms/VideoListAll/VideoListAll|project=panda_egbf&deviceType=调峰泵站&control=true",
"icon":"assets/images/menu/pumpcare/一级菜单白色/1-视频监控.png",
"url":"product/oms/VideoListAll/VideoListAll|device=调峰泵站&project=panda_egbf&control=true",
"config":""
},
{
"label":"门禁监控",
"shortName":"门禁",
"icon":"assets/images/menu/default.png",
"url":"productex/water/IOTMonitor/SafetyMonitor/devicedoor/devicedoor|device=调峰泵站",
"config":""
},
{
"label":"能耗分析",
"shortName":"",
"icon":"assets/images/menu/pumpcare/一级菜单白色/4-数据分析.png",
"url":"productex/water/IOTMonitor/EnergyAnalysis/EnergyAnalysis|accountName=调峰泵站&targetName=出水累计流量,累计电量",
"config":""
},
{
"label":"运行评价",
"shortName":"",
"icon":"assets/images/menu/统计分析.png",
"url":"productex/water/IOTMonitor/OperationAnalysis/OperationAnalysis|deviceType=调峰泵站&targetName=出水累计流量,累计电量",
"config":""
},
{
"label":"运行概况",
"shortName":"",
"icon":"assets/images/menu/SCADA/一级菜单白色/报表统计.png",
"url":"productex/water/IOTMonitor/RunStatus/RunStatus|deviceType=调峰泵站",
"config":""
},
{
"label":"运行时报",
"shortName":"",
"icon":"assets/images/menu/计划上报.png",
"url":"productex/water/IOTMonitor/DataReportForHour/DataReportForHour|names=调峰机组;Max:出水实际压力",
"config":""
},
{
"label":"运行日志",
"shortName":"",
"icon":"assets/images/menu/工单3.0.png",
"url":"productex/water/IOTMonitor/RunLogHistory/RunLogHistory|name=调峰泵站",
"config":""
},
{
"widgets":[
{
"label":"调峰信息",
"shortName":"泵站",
"icon":"assets/images/menu/webgis/二级菜单/功能窗口/事件展示.png",
"url":"product/maintenance/AccountManage/AccountManage|name=调峰泵站",
"config":""
},
{
"label":"机组信息",
"shortName":"机组",
"icon":"assets/images/menu/webgis/二级菜单/功能窗口/事件展示.png",
"url":"product/maintenance/AccountManage/AccountManage|name=调峰机组",
"config":""
}
],
"label":"台账管理",
"shortName":"台账",
"icon":"assets/images/menu/巡检计划.png"
}
],
"label":"调峰监控",
"shortName":"调峰",
"icon":"assets/images/menu/dark/4-泵房监控.png"
},
{
"widgets":[
{
"label":"维修上报",
"shortName":"维修",
"icon":"assets/images/menu/查询管理.png",
"url":"product/maintenance/EventManage/EventReport/MenuEventReportView|eventType=二供泵房维修",
"config":""
},
{
"label":"事件办理",
"shortName":"维修",
"icon":"assets/images/menu/合同管理.png",
"url":"product/maintenance/EventManage/EventDispatchBox/EventDispatchBoxList|eventType=二供泵房维修",
"config":""
},
{
"label":"工单办理",
"shortName":"维修",
"icon":"assets/images/menu/工程管理.png",
"url":"product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=1&flowName=二供泵房维修",
"config":""
},
{
"label":"事件总览",
"shortName":"维修",
"icon":"assets/images/menu/dark/7-综合调度.png",
"url":"product/maintenance/EventManage/EventOverviewBox/EventOverviewListView|eventType=二供泵房维修",
"config":""
},
{
"label":"工单总览",
"shortName":"维修",
"icon":"assets/images/menu/统计3.0.png",
"url":"product/maintenance/CaseManage/CaseOverviewBox/CaseOverviewBox|flowName=二供泵房维修",
"config":""
},
{
"label":"事件上报历史",
"shortName":"维修",
"icon":"assets/images/menu/webgis/二级菜单/功能窗口/错误属性上报.png",
"url":"product/maintenance/EventManage/EventReportHistory/EventReportHistory|isMe=1&eventType=二供泵房维修",
"config":""
},
{
"label":"工单办理日志",
"shortName":"维修",
"icon":"assets/images/menu/webgis/二级菜单/功能窗口/事件展示.png",
"url":"product/maintenance/CaseManage/CaseDoneBox/CaseDoneBox|flowName=二供泵房维修",
"config":""
}
],
"label":"维修管理旧",
"shortName":"维修",
"icon":"assets/images/menu/工程施工.png"
},
{
"widgets":[
{
"label":"组态绘制",
"shortName":"",
"icon":"assets/images/menuNew/01一级图标/物联组态.svg",
"url":"configuration/ConfigurationsSageView/ConfigurationsSageView",
"config":""
},
{
"label":"组态预览",
"shortName":"",
"icon":"assets/images/menuNew/一级/流程管理.svg",
"url":"configuration/ConfigurationsInterface/ConfigurationsInterfaceView|title=二供泵房_箱式1_4_3&name=二供泵房_箱式1_4_3&devices=EGJZ00000001",
"config":""
}
],
"label":"泵房工艺",
"shortName":"泵房工艺",
"icon":"assets/images/menuNew/02二级图标/二供工艺.svg"
}
]
let timestamp = new Date().getTime()
const guid = function(prefix) {
prefix = prefix || '';
return prefix + (timestamp++).toString(36);
}
const generRotes = data => {
let ret = [];
data.forEach(item => {
if (item.hasOwnProperty('widgets')) {
ret.push({
name: item.label,
path: `/web4/${guid('web_console')}`,
component: 'BasicLayout',
routes: generRotes(item.widgets),
extData: {...item}
});
} else {
ret.push({
name: item.label,
component: 'BasicLayout',
path: item.hasOwnProperty('url') ? `/web4/${item.url}`: guid('web_console'),
extData: {...item}
});
}
});
return ret;
};
const routes = generRotes(mockRoutes)
export default routes;
\ No newline at end of file
import RenderAuthorize from '../components/Authorized';
import { getAuthority } from './authority';
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable import/no-mutable-exports */
let Authorized = RenderAuthorize(getAuthority());
// Reload the rights component
const reloadAuthorized = () => {
Authorized = RenderAuthorize(getAuthority());
};
window.reloadAuthorized = reloadAuthorized;
export { reloadAuthorized };
export default Authorized;
import { reloadAuthorized } from './Authorized';
export function getAuthority(str) {
const authorityString =
typeof str === 'undefined' && localStorage
? localStorage.getItem('antd-pro-authority')
: str;
let authority;
try {
if (authorityString) {
authority = JSON.parse(authorityString);
}
} catch (e) {
authority = authorityString;
}
if (typeof authority === 'string') {
return [authority];
}
return authority;
}
export function setAuthority(authority) {
const proAuthority = typeof authority === 'string' ? [authority] : authority;
localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
reloadAuthorized();
}
export const RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount'; export const RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount';
export const DAEMON = '@@saga-injector/daemon'; export const DAEMON = '@@saga-injector/daemon';
export const ONCE_TILL_UNMOUNT = '@@saga-injector/once-till-unmount'; export const ONCE_TILL_UNMOUNT = '@@saga-injector/once-till-unmount';
export const FILTER_FOLER = [
'configs',
'configuration',
'framework',
'iframe',
'product',
'productex',
'project',
'qrcode',
'threedimensional',
'video',
'widgetconfigs',
];
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.reloadAuthorized = void 0;
var _Authorized = _interopRequireDefault(require("../components/Authorized"));
var _authority = require("./authority");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable import/no-mutable-exports */
var Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)()); // Reload the rights component
var reloadAuthorized = function reloadAuthorized() {
Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)());
};
exports.reloadAuthorized = reloadAuthorized;
window.reloadAuthorized = reloadAuthorized;
var _default = Authorized;
exports["default"] = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAuthority = getAuthority;
exports.setAuthority = setAuthority;
var _Authorized = require("./Authorized");
function getAuthority(str) {
var authorityString = typeof str === 'undefined' && localStorage ? localStorage.getItem('antd-pro-authority') : str;
var authority;
try {
if (authorityString) {
authority = JSON.parse(authorityString);
}
} catch (e) {
authority = authorityString;
}
if (typeof authority === 'string') {
return [authority];
}
return authority;
}
function setAuthority(authority) {
var proAuthority = typeof authority === 'string' ? [authority] : authority;
localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
(0, _Authorized.reloadAuthorized)();
}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FILTER_FOLER = exports.ONCE_TILL_UNMOUNT = exports.DAEMON = exports.RESTART_ON_REMOUNT = void 0;
var RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount';
exports.RESTART_ON_REMOUNT = RESTART_ON_REMOUNT;
var DAEMON = '@@saga-injector/daemon';
exports.DAEMON = DAEMON;
var ONCE_TILL_UNMOUNT = '@@saga-injector/once-till-unmount';
exports.ONCE_TILL_UNMOUNT = ONCE_TILL_UNMOUNT;
var FILTER_FOLER = ['configs', 'configuration', 'framework', 'iframe', 'product', 'productex', 'project', 'qrcode', 'threedimensional', 'video', 'widgetconfigs'];
exports.FILTER_FOLER = FILTER_FOLER;
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports["default"] = void 0; exports["default"] = exports.guid = void 0;
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
...@@ -18,13 +18,15 @@ var guid = function guid(prefix) { ...@@ -18,13 +18,15 @@ var guid = function guid(prefix) {
return prefix + (timestamp++).toString(36); return prefix + (timestamp++).toString(36);
}; };
exports.guid = guid;
var generRotes = function generRotes(data) { var generRotes = function generRotes(data) {
var ret = []; var ret = [];
data.forEach(function (item) { data.forEach(function (item) {
if (item.hasOwnProperty('widgets')) { if (item.hasOwnProperty('widgets')) {
ret.push({ ret.push({
name: item.label, name: item.label,
path: "/web4/".concat(guid('web_console')), path: "/civbase/civweb4/".concat(guid('web_console')),
component: 'BasicLayout', component: 'BasicLayout',
routes: generRotes(item.widgets), routes: generRotes(item.widgets),
extData: _objectSpread({}, item) extData: _objectSpread({}, item)
...@@ -33,7 +35,7 @@ var generRotes = function generRotes(data) { ...@@ -33,7 +35,7 @@ var generRotes = function generRotes(data) {
ret.push({ ret.push({
name: item.label, name: item.label,
component: 'BasicLayout', component: 'BasicLayout',
path: item.hasOwnProperty('url') ? "/web4/".concat(item.url) : guid('web_console'), path: item.hasOwnProperty('url') ? "/civbase/civweb4/".concat(item.url) + (item.url.indexOf('?') < 0 ? '?' : '&') + "key=".concat(guid()) : guid('web_console'),
extData: _objectSpread({}, item) extData: _objectSpread({}, item)
}); });
} }
......
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isPromise = isPromise;
exports.getRouteAuthority = exports.getAuthorityFromRouter = exports.getPageQuery = exports.isUrl = void 0;
var _pathToRegexp = _interopRequireDefault(require("path-to-regexp"));
var _querystring = require("querystring");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
var isUrl = function isUrl(path) {
return reg.test(path);
};
exports.isUrl = isUrl;
var getPageQuery = function getPageQuery() {
return (0, _querystring.parse)(window.location.href.split('?')[1]);
};
exports.getPageQuery = getPageQuery;
var getAuthorityFromRouter = function getAuthorityFromRouter(router, pathname) {
debugger;
var authority = router.find(function (_ref) {
var routes = _ref.routes,
_ref$path = _ref.path,
path = _ref$path === void 0 ? '/' : _ref$path,
_ref$target = _ref.target,
target = _ref$target === void 0 ? '_self' : _ref$target;
return path && target !== '_blank' && (0, _pathToRegexp["default"])(path).exec(pathname) || routes && getAuthorityFromRouter(routes, pathname);
});
if (authority) return authority;
return undefined;
};
exports.getAuthorityFromRouter = getAuthorityFromRouter;
var getRouteAuthority = function getRouteAuthority(path, routeData) {
debugger;
var authorities;
routeData.forEach(function (route) {
if ((0, _pathToRegexp["default"])("".concat(route.path, "/(.*)")).test("".concat(path, "/"))) {
if (route.authority) {
authorities = route.authority;
}
if (route.path === path) {
authorities = route.authority || authorities;
}
if (route.routes) {
authorities = getRouteAuthority(path, route.routes) || authorities;
}
}
});
return authorities;
};
exports.getRouteAuthority = getRouteAuthority;
function isPromise(obj) {
return !!obj && ( //有实际含义的变量才执行方法,变量null,undefined和''空串都为false
_typeof(obj) === 'object' || typeof obj === 'function') && // 初始promise 或 promise.then返回的
typeof obj.then === 'function';
}
\ No newline at end of file
let timestamp = new Date().getTime() let timestamp = new Date().getTime();
const guid = function(prefix) { export const guid = function(prefix) {
prefix = prefix || ''; prefix = prefix || '';
return prefix + (timestamp++).toString(36); return prefix + (timestamp++).toString(36);
} };
const generRotes = data => { const generRotes = data => {
let ret = []; let ret = [];
data.forEach(item => { data.forEach(item => {
if (item.hasOwnProperty('widgets')) { if (item.hasOwnProperty('widgets')) {
ret.push({ ret.push({
name: item.label, name: item.label,
path: `/web4/${guid('web_console')}`, path: `/civbase/civweb4/${guid('web_console')}`,
component: 'BasicLayout', component: 'BasicLayout',
routes: generRotes(item.widgets), routes: generRotes(item.widgets),
extData: {...item} extData: { ...item },
}); });
} else { } else {
ret.push({ ret.push({
name: item.label, name: item.label,
component: 'BasicLayout', component: 'BasicLayout',
path: item.hasOwnProperty('url') ? `/web4/${item.url}`: guid('web_console'), path: item.hasOwnProperty('url')
extData: {...item} ? `/civbase/civweb4/${item.url}` +
(item.url.indexOf('?') < 0 ? '?' : '&') +
`key=${guid()}`
: guid('web_console'),
extData: { ...item },
}); });
} }
}); });
......
import pathRegexp from 'path-to-regexp';
import { parse } from 'querystring';
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
export const isUrl = path => reg.test(path);
export const getPageQuery = () => parse(window.location.href.split('?')[1]);
export const getAuthorityFromRouter = (router, pathname) => {
debugger;
const authority = router.find(
({ routes, path = '/', target = '_self' }) =>
(path && target !== '_blank' && pathRegexp(path).exec(pathname)) ||
(routes && getAuthorityFromRouter(routes, pathname)),
);
if (authority) return authority;
return undefined;
};
export const getRouteAuthority = (path, routeData) => {
debugger;
let authorities;
routeData.forEach(route => {
if (pathRegexp(`${route.path}/(.*)`).test(`${path}/`)) {
if (route.authority) {
authorities = route.authority;
}
if (route.path === path) {
authorities = route.authority || authorities;
}
if (route.routes) {
authorities = getRouteAuthority(path, route.routes) || authorities;
}
}
});
return authorities;
};
export function isPromise(obj) {
return (
!!obj && //有实际含义的变量才执行方法,变量null,undefined和''空串都为false
(typeof obj === 'object' || typeof obj === 'function') && // 初始promise 或 promise.then返回的
typeof obj.then === 'function'
);
}
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