Browse Source

删除多余参数

master
巴林闲侠 2 years ago
parent
commit
d4f02b514c
  1. 27
      api/.vscode/launch.json
  2. 26
      api/app/lib/index.js
  3. 14
      api/app/lib/middlewares/duration-calc.js
  4. 20
      api/app/lib/service/kafka.js
  5. 23
      api/app/lib/service/mqttServer.js
  6. 173
      api/app/lib/utils/dataRange.js
  7. 21
      api/app/lib/utils/kafkaSend.js
  8. 30
      api/app/lib/utils/vcmpAuth.js
  9. 118
      api/config.js
  10. 4
      web/client/index.ejs
  11. 35
      web/client/index.html
  12. 2
      web/client/src/index.jsx
  13. 1
      web/client/src/layout/actions/global.js
  14. 4
      web/client/src/layout/containers/layout/index.jsx
  15. 2
      web/client/src/layout/index.jsx
  16. 2
      web/client/src/layout/reducers/global.js
  17. 29
      web/config.js
  18. 4
      web/middlewares/vite-dev.js
  19. 8
      web/middlewares/webpack-dev.js
  20. 4
      web/package.json
  21. 3
      web/routes/attachment/index.js
  22. 2
      web/webpack.config.js

27
api/.vscode/launch.json

@ -13,25 +13,15 @@
"NODE_ENV": "development"
},
"args": [
"-p 4600",
"-f http://localhost:4600",
"-p 4700",
"-f http://localhost:4700",
//
// "-g postgres://postgres:123@10.8.30.32:5432/orational_service",
//
"-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS",
"-k node35:6667,node36:6667,node37:6667",
"--iotaProxy http://10.8.30.157:17007",
"-g postgres://postgres:123@10.8.30.32:5432/orational_service",
"--redisHost 10.8.30.112",
"--redisPort 6379",
"--axyApiUrl http://127.0.0.1:4100",
// "--apiEmisUrl http://10.8.30.112:14000",
//
"--apiEmisUrl http://10.8.30.161:1111",
"--apiVcmpUrl http://localhost:4000",
"--apiIotAuth http://localhost:4200",
"--godUrl https://restapi.amap.com/v3",
"--godKey 21c2d970e1646bb9a795900dd00093ce",
"--mqttVideoServer mqtt://10.8.30.71:30883",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa",
"--qnbkt dev-operational-service",
@ -49,22 +39,11 @@
// "--clickHousePassword ",
//
// "--clickHouseAnxincloud anxinyun",
// "--clickHousePepEmis pepca",
// "--clickHouseProjectManage peppm",
// "--clickHouseVcmp video_accrss1",
// "--clickHouseDataAlarm default",
//
"--clickHouseAnxincloud Anxinyun13",
"--clickHousePepEmis pepca8",
"--clickHouseProjectManage peppm8",
"--clickHouseVcmp video_access_dev",
"--clickHouseDataAlarm default",
"--confirmAlarmAnxinUserId 1",
"--vcmpAppId 5048b08d-c449-4d7f-b1ec-f741012aefe8",
"--vcmpAppSecret 5ba8c0ab-9fbd-4f07-9817-c48017c3cbad",
]
},
{

26
api/app/lib/index.js

@ -6,11 +6,9 @@ const utils = require('./utils')
const routes = require('./routes');
const redisConnect = require('./service/redis')
const socketConect = require('./service/socket')
const mqttVideoServer = require('./service/mqttServer')
const paasRequest = require('./service/paasRequest');
const authenticator = require('./middlewares/authenticator');
const clickHouseClient = require('./service/clickHouseClient')
const kafka = require('./service/kafka')
const schedule = require('./schedule')
// const apiLog = require('./middlewares/api-log');
@ -25,13 +23,10 @@ module.exports.entry = function (app, router, opts) {
// 顺序固定 ↓
redisConnect(app, opts)
socketConect(app, opts)
mqttVideoServer(app, opts)
// 实例其他平台请求方法
paasRequest(app, opts)
kafka(app, opts)
// clickHouse 数据库 client
clickHouseClient(app, opts)
@ -57,23 +52,8 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
require(`./models/${filename}`)(dc)
});
// const {
// AppInspection, ProjectApp, ProjectCorrelation, AppAlarm, App
// } = dc.models;
// AppInspection.belongsTo(App, { foreignKey: 'projectAppId', targetKey: 'id' });
// App.hasMany(AppInspection, { foreignKey: 'projectAppId', sourceKey: 'id' });
// ProjectApp.belongsTo(ProjectCorrelation, { foreignKey: 'projectId', targetKey: 'id' });
// ProjectCorrelation.hasMany(ProjectApp, { foreignKey: 'projectId', sourceKey: 'id' });
// ProjectApp.belongsTo(App, { foreignKey: 'appId', targetKey: 'id' });
// App.hasMany(ProjectApp, { foreignKey: 'appId', sourceKey: 'id' });
// ProjectCorrelation.belongsToMany(App, { through: ProjectApp, foreignKey: 'projectId', otherKey: 'appId' });
// App.belongsToMany(ProjectCorrelation, { through: ProjectApp, foreignKey: 'appId', otherKey: 'projectId' });
const {
} = dc.models;
// AppAlarm.belongsTo(App, { foreignKey: 'projectAppId', targetKey: 'id' });
// App.hasMany(AppAlarm, { foreignKey: 'projectAppId', sourceKey: 'id' });
};

14
api/app/lib/middlewares/duration-calc.js

@ -1,14 +0,0 @@
'use strict';
const moment = require('moment');
async function factory (ctx, next) {
try {
const start = moment()
await next()
ctx.fs.logger.log(`DurationCalc: ${ctx.path} 用时 ${moment().diff(start, 'milliseconds')}`);
} catch (error) {
ctx.fs.logger.error(`DurationCalc, error: ${error}`);
}
}
module.exports = factory;

20
api/app/lib/service/kafka.js

@ -1,20 +0,0 @@
'use strict';
const Kafka = require('kafka-node');
module.exports = async function factory (app, opts) {
const client = new Kafka.KafkaClient({ kafkaHost: opts.kafka.rootURL });
const producer = new Kafka.HighLevelProducer(client);
producer.on('error', function (err) {
app.fs.logger.log('error', "[FS-KAFKA]", err);
});
const kafka = {
producer: producer,
configUpdateMessage: opts.configUpdateMessage || {}
};
app.fs.kafka = kafka;
app.fs.logger.log('debug', "[FS-KAFKA]", "Init.Success");
}

23
api/app/lib/service/mqttServer.js

@ -1,23 +0,0 @@
'use strict';
const mqtt = require('mqtt');
module.exports = async function factory (app, opts) {
// console.info(`mqtt connecting ${opts.mqtt.mqttVideoServer}`);
// const client = mqtt.connect(opts.mqtt.mqttVideoServer);
// client.on('connect', function () {
// console.info(`mqtt connect success ${opts.mqtt.mqttVideoServer}`);
// client.subscribe('topic/test', { qos: 0 });//订阅主题为test的消息
// })
// client.on('error', function (e) {
// console.error(`mqtt connect failed ${opts.mqtt.mqttVideoServer}`);
// app.fs.logger.error('info', '[FS-AUTH-MQTT]', `mqtt connect failed ${opts.mqtt.mqttVideoServer}`);
// })
// client.on('message', async (top, message) => {
// });
// app.mqttVideoServer = client
}

173
api/app/lib/utils/dataRange.js

@ -1,173 +0,0 @@
'use strict';
const fs = require('fs');
const moment = require('moment')
module.exports = function (app, opts) {
function judgeSuper (ctx) {
try {
const { userInfo = {} } = ctx.fs.api || {};
const { role = [] } = userInfo
return role.some(r => r == 'SuperAdmin' || r == 'admin')
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
}
}
async function anxinStrucIdRange ({ ctx, pepProjectId, keywordTarget, keyword }) {
const { models } = ctx.fs.dc;
const { userInfo = {} } = ctx.fs.api || {};
const { clickHouse } = ctx.app.fs
const { correlationProject = [] } = userInfo
const isSuper = judgeSuper(ctx)
let findOption = {
where: {
del: false
}
}
if (pepProjectId) {
// 有 特定的项目id 就按此查询
findOption.where.pepProjectId = pepProjectId
} else if (!isSuper) {
// 还不是超管或管理员就按关联的项目id的数据范围查
findOption.where.id = { $in: correlationProject }
}
let pepProjectWhereOptions = []
if (keywordTarget == 'pepProject' && keyword) {
pepProjectWhereOptions.push(`t_pim_project.project_name LIKE '%${keyword}%'`)
findOption.where.name = {
$or: [{
$eq: null
}, {
$like: `%${keyword}%`
}]
}
}
// TODO 这儿也许需要判断传进来的 pepProjectId 在不在当前用户的关注范围内
// 根据 poms 的项目绑定关系查相关联的项企项目、安心云项目id信息
const bindRes = await models.ProjectCorrelation.findAll(findOption)
// 获取不重复的 项企项目id
let pepProjectIds = []
for (let b of bindRes) {
if (b.pepProjectId) {
pepProjectIds.push(b.pepProjectId)
}
}
// 查询项企项目的信息
const pepProjectRes = pepProjectIds.length ?
await clickHouse.projectManage.query(
`
SELECT
t_pim_project.id AS id,
t_pim_project.project_name AS projectName,
t_pim_project.isdelete AS isdelete,
t_pim_project_construction.construction_status_id AS constructionStatusId,
t_pim_project_state.construction_status AS constructionStatus
FROM
t_pim_project
LEFT JOIN t_pim_project_construction
ON t_pim_project.id = t_pim_project_construction.project_id
LEFT JOIN t_pim_project_state
ON t_pim_project_construction.construction_status_id = t_pim_project_state.id
WHERE
id IN (${pepProjectIds.join(',')})
${pepProjectWhereOptions.length ? `AND ${pepProjectWhereOptions.join(' AND ')}`
: ''}
`
).toPromise() :
[]
// 获取不重复的 安心云项目 id
const anxinProjectIds = [
...(
keywordTarget == 'pepProject' && keyword ?
bindRes.filter(b => b.name || pepProjectRes.some(pp => pp.id == b.pepProjectId)) :
bindRes
).reduce(
(arr, b) => {
for (let sid of b.anxinProjectId) {
arr.add(sid);
}
return arr;
},
new Set()
)
]
// 查询安心云项目及结构物信息
let undelStrucWhereOptions = []
if (keywordTarget && keyword) {
if (keywordTarget == 'struc') {
undelStrucWhereOptions.push(`t_structure.name LIKE '%${keyword}%'`)
}
}
const undelStrucRes = anxinProjectIds.length ?
await clickHouse.anxinyun.query(
`
SELECT
t_project.id AS projectId,
t_structure.id AS strucId,
t_structure.name AS strucName,
project_state
FROM
t_project
LEFT JOIN
t_project_structure
ON t_project_structure.project = t_project.id
LEFT JOIN
t_project_structuregroup
ON t_project_structuregroup.project = t_project.id
LEFT JOIN
t_structuregroup_structure
ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup
RIGHT JOIN
t_structure
ON t_structure.id = t_project_structure.structure
OR t_structure.id = t_structuregroup_structure.structure
WHERE
project_state != -1
AND
t_project.id IN (${anxinProjectIds.join(',')})
${undelStrucWhereOptions.length ? `AND ${undelStrucWhereOptions.join(' AND ')}` : ''}
`
).toPromise() :
[]
// 构建安心云结构物和项企项目的关系
// 并保存信息至数据
let undelStruc = []
for (let s of undelStrucRes) {
if (!undelStruc.some(us => us.strucId == s.strucId)) {
let pomsProject = []
for (let { dataValues: br } of bindRes) {
if (br.anxinProjectId.some(braId => braId == s.projectId)) {
let corPepProject = pepProjectRes.find(pp => pp.id == br.pepProjectId)
pomsProject.push({
...br,
pepProject: corPepProject
})
}
}
undelStruc.push({
strucId: s.strucId,
strucName: s.strucName,
// projectId: s.projectId,
pomsProject: pomsProject
})
}
}
return undelStruc
}
return {
judgeSuper,
anxinStrucIdRange
}
}

21
api/app/lib/utils/kafkaSend.js

@ -1,21 +0,0 @@
'use strict';
module.exports = function (app, opts) {
async function kfkSendAsync (payloads) {
const { producer } = app.fs.kafka
return new Promise((resolve, reject) => {
producer.send(payloads, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
})
}
return {
kfkSendAsync
}
}

30
api/app/lib/utils/vcmpAuth.js

@ -1,30 +0,0 @@
'use strict';
const moment = require('moment')
module.exports = function (app, opts) {
async function vcmpAuth () {
const { vcmp: { app: vcApp } } = opts
const vcmpAuth = await app.redis.hgetall('vcmpAuth');
if (vcmpAuth.token && moment().isBefore(moment(vcmpAuth.expires))) {
return vcmpAuth.token
} else {
let res = await app.fs.iotAuthRequest.post('oauth2/token', {
data: {
grant_type: 'client_credentials'
},
header: {
Authorization: `Basic ${Buffer.from(`${encodeURIComponent(vcApp.id)}:${encodeURIComponent(vcApp.secret)}`).toString('base64')}`
}
})
await app.redis.hmset('vcmpAuth', {
...res
});
return res.token
}
}
return {
vcmpAuth
}
}

118
api/config.js

@ -11,23 +11,12 @@ const dev = process.env.NODE_ENV == 'development';
args.option(['p', 'port'], '启动端口');
args.option(['g', 'pg'], 'postgre 服务 URL');
args.option(['f', 'fileHost'], '文件中心本地化存储: WebApi 服务器地址(必填), 该服务器提供文件上传Web服务');
args.option(['k', 'kafka'], 'kafka 服务 URL');
args.option('iotaProxy', '以太代理')
args.option('redisHost', 'redisHost');
args.option('redisPort', 'redisPort');
args.option('redisPswd', 'redisPassword');
args.option('axyApiUrl', '安心云 api');
args.option('apiEmisUrl', '企业管理 api');
args.option('apiVcmpUrl', '视频平台 api');
args.option('apiIotAuth', 'IOT 鉴权平台')
args.option('godUrl', '高德地图API请求地址');
args.option('godKey', '高德地图API key');
args.option('mqttVideoServer', '视频后台 mqtt 服务 URL');
// 七牛云存储参数
args.option('qnak', 'qiniuAccessKey');
@ -38,49 +27,20 @@ args.option('qndmn', 'qiniuDomain');
// clickHouse
args.option('clickHouseUrl', 'clickHouse Url');
args.option('clickHousePort', 'clickHouse Port');
args.option('clickHouseAnxincloud', 'clickHouse 安心云数据库名称');
args.option('clickHousePepEmis', 'clickHouse 项企数据库名称');
args.option('clickHouseProjectManage', 'clickHouse 项目管理数据库名称');
args.option('clickHouseVcmp', 'clickHouse 视频平台数据库名称');
args.option('clickHouseDataAlarm', 'clickHouse 视频平台数据告警库名称');
args.option('confirmAlarmAnxinUserId', '确认告警时保存到 ES 的安心云的用户的 id');
// 视频应用秘钥
args.option('vcmpAppId', '视频平台 应用 id')
args.option('vcmpAppSecret', '视频平台 应用秘钥')
const flags = args.parse(process.argv);
const POMS_DB = process.env.POMS_DB || flags.pg;
const LOCAL_SVR_ORIGIN = process.env.LOCAL_SVR_ORIGIN || flags.fileHost;
// kafka
const ANXINCLOUD_KAFKA_BROKERS = process.env.ANXINCLOUD_KAFKA_BROKERS || flags.kafka;
// 以太代理
const IOT_PROXY = process.env.IOT_PROXY || flags.iotaProxy;
// Redis 参数
const IOTA_REDIS_SERVER_HOST = process.env.IOTA_REDIS_SERVER_HOST || flags.redisHost || "localhost";//redis IP
const IOTA_REDIS_SERVER_PORT = process.env.IOTA_REDIS_SERVER_PORT || flags.redisPort || "6379";//redis 端口
const IOTA_REDIS_SERVER_PWD = process.env.IOTA_REDIS_SERVER_PWD || flags.redisPswd || "";//redis 密码
// 安心云api
const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.axyApiUrl;
// 企业管理 api
const API_EMIS_URL = process.env.API_EMIS_URL || flags.apiEmisUrl;
// 视频平台 api
const API_VCMP_URL = process.env.API_VCMP_URL || flags.apiVcmpUrl;
// iot鉴权平台 api
const API_IOT_AUTH = process.env.API_IOT_AUTH || flags.apiIotAuth;
// 高德地图的参数
const GOD_URL = process.env.GOD_URL || flags.godUrl || 'https://restapi.amap.com/v3';
const GOD_KEY = process.env.GOD_KEY || flags.godKey;
// 视频后台 mqtt 信息推送地址
const MQTT_VIDEO_SERVER = process.env.MQTT_VIDEO_SERVER || flags.mqttVideoServer;
// 七牛云存储参数
const QINIU_DOMAIN_QNDMN_RESOURCE = process.env.ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE || flags.qndmn;
@ -93,34 +53,15 @@ const CLICKHOUST_URL = process.env.CLICKHOUST_URL || flags.clickHouseUrl
const CLICKHOUST_PORT = process.env.CLICKHOUST_PORT || flags.clickHousePort
const CLICKHOUST_USER = process.env.CLICKHOUST_USER || flags.clickHouseUser
const CLICKHOUST_PASSWORD = process.env.CLICKHOUST_PASSWORD || flags.clickHousePassword
const CLICKHOUST_ANXINCLOUD = process.env.CLICKHOUST_ANXINCLOUD || flags.clickHouseAnxincloud
const CLICKHOUST_PEP_EMIS = process.env.CLICKHOUST_PEP_EMIS || flags.clickHousePepEmis
const CLICKHOUST_PROJECT_MANAGE = process.env.CLICKHOUST_PROJECT_MANAGE || flags.clickHouseProjectManage
const CLICKHOUST_VCMP = process.env.CLICKHOUST_VCMP || flags.clickHouseVcmp
const CLICKHOUST_DATA_ALARM = process.env.CLICKHOUST_DATA_ALARM || flags.clickHouseDataAlarm
const CONFIRM_ALARM_ANXIN_USER_ID = process.env.CONFIRM_ALARM_ANXIN_USER_ID || flags.confirmAlarmAnxinUserId
const PLATFORM_NAME = process.env.PLATFORM_NAME || flags.platformName || 'anxinyun';
// 视频平台应用秘钥
const VCMP_APP_ID = process.env.VCMP_APP_ID || flags.vcmpAppId
const VCMP_APP_SECRET = process.env.VCMP_APP_SECRET || flags.vcmpAppSecret
if (
!POMS_DB
|| !IOTA_REDIS_SERVER_HOST || !IOTA_REDIS_SERVER_PORT
|| !ANXINCLOUD_KAFKA_BROKERS
|| !GOD_KEY
|| !API_ANXINYUN_URL
|| !API_EMIS_URL
|| !API_VCMP_URL
|| !API_IOT_AUTH
|| !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK
|| !CLICKHOUST_URL || !CLICKHOUST_PORT
|| !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE || !CLICKHOUST_VCMP || !CLICKHOUST_DATA_ALARM
|| !CONFIRM_ALARM_ANXIN_USER_ID
|| !VCMP_APP_ID || !VCMP_APP_SECRET
|| !CLICKHOUST_PEP_EMIS
) {
console.log('缺少启动参数,异常退出');
args.showHelp();
@ -147,32 +88,13 @@ const product = {
opts: {
dev,
exclude: [
{ p: '/attachments/:p', o: 'POST' },
{ p: '/alarm/application/inspection', o: 'POST' },
{ p: '/project/app_list', o: 'GET' },
{ p: '/alarm/application/api', o: 'POST' }
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由
anxinCloud: {
confirmAlarmAnxinUserId: CONFIRM_ALARM_ANXIN_USER_ID
},
vcmp: {
app: {
id: VCMP_APP_ID,
secret: VCMP_APP_SECRET
}
},
kafka: {
rootURL: ANXINCLOUD_KAFKA_BROKERS,
topicPrefix: PLATFORM_NAME
},
redis: {
host: IOTA_REDIS_SERVER_HOST,
port: IOTA_REDIS_SERVER_PORT,
pwd: IOTA_REDIS_SERVER_PWD
},
mqtt: {
mqttVideoServer: MQTT_VIDEO_SERVER,
},
sms: {
///阿里云-安心云
accessKey: 'LTAI5tAFdjz7j38aNF2C9Qe8',
@ -183,34 +105,14 @@ const product = {
host: 'smtp.exmail.qq.com',
port: 465,
sender: {
name: '运维服务',
name: '人资服务',
address: 'fsiot@free-sun.com.cn',
password: 'Fs2689'
}
},
pssaRequest: [{// name 会作为一个 request 出现在 ctx.app.fs
name: 'axyRequest',
root: API_ANXINYUN_URL
}, {
pssaRequest: [{
name: 'emisRequest',
root: API_EMIS_URL
}, {
name: 'vcmpRequest',
root: API_VCMP_URL
}, {
name: 'iotAuthRequest',
root: API_IOT_AUTH
}, {
name: 'iotRequest',
root: IOT_PROXY + '/_iota_api'
}, {
name: 'godRequest',
root: GOD_URL,
params: {
query: {
key: GOD_KEY
}
}
},],
clickHouse: {
url: CLICKHOUST_URL,
@ -219,20 +121,8 @@ const product = {
password: CLICKHOUST_PASSWORD,
db: [
{
name: 'anxinyun',
db: CLICKHOUST_ANXINCLOUD
}, {
name: 'pepEmis',
db: CLICKHOUST_PEP_EMIS
}, {
name: 'projectManage',
db: CLICKHOUST_PROJECT_MANAGE
}, {
name: 'vcmp',
db: CLICKHOUST_VCMP
}, {
name: 'dataAlarm',
db: CLICKHOUST_DATA_ALARM
}
]
}

4
web/client/index.ejs

@ -8,14 +8,12 @@
<!-- <meta content="upgrade-insecure-requests" http-equiv="Content-Security-Policy"> -->
<link rel="shortcut icon" href="/assets/images/favicon.ico">
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({ id: "Jo4eTlZVqgx3uwqm", ck: "Jo4eTlZVqgx3uwqm" })</script>
<script src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_19077_10.1efd80a22a5e53e48737fd5ab150ffd2.es5.js"></script>
</head>
<body>
<div id='PomsApp' style="height: 100%;"></div>
<div id='HrApp' style="height: 100%;"></div>
</body>
</html>

35
web/client/index.html

@ -2,27 +2,24 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<meta charset="UTF-8">
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<link rel="shortcut icon" href="/assets/images/favicon.ico">
<link rel="shortcut icon" href="/assets/images/favicon.ico">
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({ id: "Jo4eTlZVqgx3uwqm", ck: "Jo4eTlZVqgx3uwqm" })</script>
<script
src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_19077_11.27aacefc59cea1cbc86236576463a6d2.es5.js"></script>
</head>
<script
src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_19077_11.27aacefc59cea1cbc86236576463a6d2.es5.js"></script>
</head >
<body>
<div id='HrApp' style="height: 100%;"></div>
<body>
<div id='PomsApp' style="height: 100%;"></div>
<!-- Webpack -->
<script type="text/javascript" src="http://localhost:5701/client/build/app.js"></script>
<!-- Webpack -->
<script type="text/javascript" src="http://localhost:5601/client/build/app.js"></script>
<!-- Vite -->
<!-- <script type="module">
import RefreshRuntime from "http://localhost:5602/@react-refresh"
<!-- Vite -->
<!-- <script type="module">
import RefreshRuntime from "http://localhost:5702/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => { }
window.$RefreshSig$ = () => (type) => type
@ -30,9 +27,9 @@
const global = window
</script>
<script type="module" src="http://localhost:5002/src/index.jsx"></script> -->
<!-- Vite End -->
<!-- Vite End -->
<script>
<script>
//过滤掉一些无用的警告、没有价值的报错
//代理console.warn方法
@ -48,7 +45,7 @@
// _consoleWarn(...rest);
// }
// };
</script>
</script>
</body>
</html>

2
web/client/src/index.jsx

@ -6,4 +6,4 @@ import { render } from 'react-dom';
import App from './app';
import './index.less';
render((<App projectName="运维服务" />), document.getElementById('PomsApp'));
render((<App projectName="运维服务" />), document.getElementById('HrApp'));

1
web/client/src/layout/actions/global.js

@ -38,7 +38,6 @@ export function initApiRoot () {
type: INIT_API_ROOT,
payload: {
apiRoot: res.root,
iotVcmpWeb:res.iotVcmpWeb,
}
})
});

4
web/client/src/layout/containers/layout/index.jsx

@ -35,8 +35,8 @@ const LayoutContainer = props => {
const resize_ = () => {
dispatch(resize(
document.getElementById('PomsApp').clientHeight,
document.getElementById('PomsApp').clientWidth - (collapsed ? 120 : 240)
document.getElementById('HrApp').clientHeight,
document.getElementById('HrApp').clientWidth - (collapsed ? 120 : 240)
));
}
function deepCopy (data) {//

2
web/client/src/layout/index.jsx

@ -124,7 +124,7 @@ const Root = props => {
let store = configStore(reducers, history);
store.dispatch(initLayout(title, copyright, sections, actions));
// store.dispatch(resize(document.body.clientHeight, document.body.clientWidth));
store.dispatch(resize(document.getElementById('PomsApp').clientHeight, document.getElementById('PomsApp').clientWidth));
store.dispatch(resize(document.getElementById('HrApp').clientHeight, document.getElementById('HrApp').clientWidth));
store.dispatch(actions.auth.initAuth());
const resourceRoot = await store.dispatch(initApiRoot())
store.dispatch(initWebSocket({}))

2
web/client/src/layout/reducers/global.js

@ -11,7 +11,6 @@ function global (state = {
clientHeight: 768,
clientWidth: 1024,
apiRoot: '',
iotVcmpWeb: '',
}, action) {
const payload = action.payload;
switch (action.type) {
@ -31,7 +30,6 @@ function global (state = {
case INIT_API_ROOT:
return Immutable.fromJS(state).merge({
apiRoot: payload.apiRoot,
iotVcmpWeb: payload.iotVcmpWeb
}).toJS();
default:
return state;

29
web/config.js

@ -12,10 +12,7 @@ dev && console.log('\x1B[33m%s\x1b[0m', '请遵循并及时更新 readme.md,
// // 启动参数
args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL');
args.option('apiPomsUrl', 'webapi的URL 外网可访问');
args.option('apiAnxinyunUrl', '安心云 api');
args.option('apiEmisUrl', '企业管理 api');
args.option('iotVcmpWeb', 'IOT 视频服务');
args.option('apiHrUrl', 'webapi的URL 外网可访问');
// 七牛
args.option('qnak', 'qiniuAccessKey');
@ -26,10 +23,7 @@ args.option('qndmn', 'qiniuDomain');
const flags = args.parse(process.argv);
const API_URL = process.env.API_URL || flags.apiUrl;
const API_POMS_URL = process.env.API_POMS_URL || flags.apiPomsUrl;
const API_EMIS_URL = process.env.API_EMIS_URL || flags.apiEmisUrl;
const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.apiAnxinyunUrl;
const IOT_VIDEO_WEB = process.env.IOT_VIDEO_WEB || flags.iotVcmpWeb;
const API_HR_URL = process.env.API_HR_URL || flags.apiHrUrl;
// 七牛
const ANXINCLOUD_QINIU_AK = process.env.ANXINCLOUD_QINIU_ACCESSKEY || flags.qnak;
@ -40,8 +34,8 @@ const ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE = process.env.ANXINCLOUD_QINIU_DOMA
if (
!API_URL
|| !API_ANXINYUN_URL
|| !ANXINCLOUD_QINIU_AK || !ANXINCLOUD_QINIU_SK || !ANXINCLOUD_QINIU_BUCKET_RESOURCE || !ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE || !IOT_VIDEO_WEB) {
|| !ANXINCLOUD_QINIU_AK || !ANXINCLOUD_QINIU_SK || !ANXINCLOUD_QINIU_BUCKET_RESOURCE || !ANXINCLOUD_QINIU_DOMAIN_QNDMN_RESOURCE
) {
console.log('缺少启动参数,异常退出');
args.showHelp();
process.exit(-1);
@ -56,12 +50,6 @@ const product = {
host: API_URL,
match: /^\/_api\//,
}
}, {
entry: require('./middlewares/proxy').entry,
opts: {
host: API_ANXINYUN_URL,
match: /^\/_axy\//,
}
}, {
entry: require('./middlewares/attachment').entry,
opts: {
@ -74,17 +62,10 @@ const product = {
maxSize: 20971520, // 20M
uploadPath: 'other'
}
}, {
entry: require('./middlewares/proxy').entry,
opts: {
host: API_EMIS_URL,
match: /^\/_emis\//,
}
}, {
entry: require('./routes').entry,
opts: {
apiUrl: API_POMS_URL,
iotVcmpWeb: IOT_VIDEO_WEB,
apiUrl: API_HR_URL,
staticRoot: './client',
qiniu: {
fetchUrl: '/_file-server',

4
web/middlewares/vite-dev.js

@ -19,7 +19,7 @@ module.exports = {
// 因为 Vite 自会接管
})
server.listen(5602)
console.info('vite server.listen 5602');
server.listen(5702)
console.info('vite server.listen 5702');
}
};

8
web/middlewares/webpack-dev.js

@ -10,7 +10,7 @@ const compiler = webpack(devConfig);
module.exports = {
entry: function (app, router, opts) {
app.use(proxy('http://localhost:5601', {
app.use(proxy('http://localhost:5701', {
filter: function (ctx) {
return /\/build/.test(url.parse(ctx.url).path);
},
@ -19,7 +19,7 @@ module.exports = {
}
}));
app.use(proxy('http://localhost:5601', {
app.use(proxy('http://localhost:5701', {
filter: function (ctx) {
return /\/$/.test(url.parse(ctx.url).path);
},
@ -46,11 +46,11 @@ module.exports = {
});
server.use(middleware(compiler));
server.listen('5601', function (err) {
server.listen('5701', function (err) {
if (err) {
console.error(err);
} else {
console.info(`webpack-dev listen 5601`);
console.info(`webpack-dev listen 5701`);
}
})
}

4
web/package.json

@ -7,7 +7,7 @@
"test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5600 -u http://localhost:4600 --apiPomsUrl http://localhost:4600 --apiAnxinyunUrl http://10.8.30.112:4100 --apiEmisUrl http://10.8.30.112:14000 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-highways4good --qndmn http://rhvqdivo5.hn-bkt.clouddn.com --iotVcmpWeb https://mediaconsole.ngaiot.com",
"start-params": "node server -p 5700 -u http://localhost:4700 --apiHrUrl http://localhost:4700 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-highways4good --qndmn http://rhvqdivo5.hn-bkt.clouddn.com",
"deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js",
"build": "cross-env NODE_ENV=production&&webpack --config webpack.config.prod.js"
@ -81,4 +81,4 @@
"webpack-dev-server": "^3.11.2",
"webpack-hot-middleware": "^2.25.0"
}
}
}

3
web/routes/attachment/index.js

@ -19,12 +19,11 @@ module.exports = {
entry: function (app, router, opts) {
const getApiRoot = async function (ctx) {
const { apiUrl, iotVcmpWeb } = opts;
const { apiUrl } = opts;
ctx.status = 200;
ctx.body = {
root: apiUrl,
iotVcmpWeb: iotVcmpWeb,
};
};

2
web/webpack.config.js

@ -36,7 +36,7 @@ module.exports = {
plugins: [
new webpack.HotModuleReplacementPlugin(),
new BundleAnalyzerPlugin({
analyzerPort: 8600,
analyzerPort: 8700,
}),
new SemiWebpackPlugin({
theme: {

Loading…
Cancel
Save