diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 2995642..8b41ecf 100644 --- a/api/.vscode/launch.json +++ b/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", ] }, { diff --git a/api/app/lib/index.js b/api/app/lib/index.js index dd3661c..87abdb9 100644 --- a/api/app/lib/index.js +++ b/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' }); }; diff --git a/api/app/lib/middlewares/duration-calc.js b/api/app/lib/middlewares/duration-calc.js deleted file mode 100644 index bd338c0..0000000 --- a/api/app/lib/middlewares/duration-calc.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/api/app/lib/service/kafka.js b/api/app/lib/service/kafka.js deleted file mode 100644 index f164eee..0000000 --- a/api/app/lib/service/kafka.js +++ /dev/null @@ -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"); -} \ No newline at end of file diff --git a/api/app/lib/service/mqttServer.js b/api/app/lib/service/mqttServer.js deleted file mode 100644 index c09a62a..0000000 --- a/api/app/lib/service/mqttServer.js +++ /dev/null @@ -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 -} diff --git a/api/app/lib/utils/dataRange.js b/api/app/lib/utils/dataRange.js deleted file mode 100644 index a50c886..0000000 --- a/api/app/lib/utils/dataRange.js +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/api/app/lib/utils/kafkaSend.js b/api/app/lib/utils/kafkaSend.js deleted file mode 100644 index 2956b8a..0000000 --- a/api/app/lib/utils/kafkaSend.js +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/api/app/lib/utils/vcmpAuth.js b/api/app/lib/utils/vcmpAuth.js deleted file mode 100644 index f8b0c2a..0000000 --- a/api/app/lib/utils/vcmpAuth.js +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/api/config.js b/api/config.js index a7badf7..c8c7345 100644 --- a/api/config.js +++ b/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 } ] } diff --git a/web/client/index.ejs b/web/client/index.ejs index 9cbe876..54e5c56 100644 --- a/web/client/index.ejs +++ b/web/client/index.ejs @@ -8,14 +8,12 @@ - - -
+
\ No newline at end of file diff --git a/web/client/index.html b/web/client/index.html index 162fe74..b4cac35 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -2,27 +2,24 @@ - - + + - + - - + + - - + +
- -
+ + - - - - - + - + - + \ No newline at end of file diff --git a/web/client/src/index.jsx b/web/client/src/index.jsx index 030a629..eae1b2a 100644 --- a/web/client/src/index.jsx +++ b/web/client/src/index.jsx @@ -6,4 +6,4 @@ import { render } from 'react-dom'; import App from './app'; import './index.less'; -render((), document.getElementById('PomsApp')); \ No newline at end of file +render((), document.getElementById('HrApp')); \ No newline at end of file diff --git a/web/client/src/layout/actions/global.js b/web/client/src/layout/actions/global.js index a33064a..4d019aa 100644 --- a/web/client/src/layout/actions/global.js +++ b/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, } }) }); diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 28a7f90..c02c8d3 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/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) {//深拷贝 diff --git a/web/client/src/layout/index.jsx b/web/client/src/layout/index.jsx index 00ae89b..bb67a21 100644 --- a/web/client/src/layout/index.jsx +++ b/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({})) diff --git a/web/client/src/layout/reducers/global.js b/web/client/src/layout/reducers/global.js index 600c572..8187eb7 100644 --- a/web/client/src/layout/reducers/global.js +++ b/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; diff --git a/web/config.js b/web/config.js index 2ee97e6..bdb1a46 100644 --- a/web/config.js +++ b/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', diff --git a/web/middlewares/vite-dev.js b/web/middlewares/vite-dev.js index 6259d42..107cc19 100644 --- a/web/middlewares/vite-dev.js +++ b/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'); } }; diff --git a/web/middlewares/webpack-dev.js b/web/middlewares/webpack-dev.js index 398953c..4e4260a 100644 --- a/web/middlewares/webpack-dev.js +++ b/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`); } }) } diff --git a/web/package.json b/web/package.json index 621c73b..c4885e0 100644 --- a/web/package.json +++ b/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" } -} \ No newline at end of file +} diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index 18621d8..22ffbcd 100644 --- a/web/routes/attachment/index.js +++ b/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, }; }; diff --git a/web/webpack.config.js b/web/webpack.config.js index b0c7f90..4af99e2 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -36,7 +36,7 @@ module.exports = { plugins: [ new webpack.HotModuleReplacementPlugin(), new BundleAnalyzerPlugin({ - analyzerPort: 8600, + analyzerPort: 8700, }), new SemiWebpackPlugin({ theme: {