From 00f4ca57ecf96ae2e746bfaa0f64b8c220a8a697 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 22 Aug 2022 10:35:51 +0800 Subject: [PATCH] user -vcmpUser --- .../api/app/lib/schedule/freshYingshiMsg.js | 7 + .../web/client/src/layout/actions/global.js | 5 +- .../client/src/layout/actions/webSocket.js | 2 +- .../web/client/src/layout/index.jsx | 31 +-- .../client/src/sections/auth/actions/auth.js | 10 +- .../equipmentWarehouse/actions/nvr.js | 176 +++++++++--------- .../web/client/src/utils/func.js | 2 +- .../web/client/src/utils/index.js | 5 +- .../web/client/src/utils/webapi.js | 11 +- code/VideoAccess-VCMP/web/package.json | 3 +- 10 files changed, 136 insertions(+), 116 deletions(-) diff --git a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js index 7f10c11..382b57e 100644 --- a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js +++ b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js @@ -91,6 +91,13 @@ module.exports = function (app, opts) { // 播放地址更新 const playUrlRes = await getYingshiPlayUrl({ deviceSerial: d.deviceSerial, token: tokenYingshi }) storageD.playUrl = playUrlRes + // 生成 did + const yingshiCount = await models.GbCamera.count({ + where: { + type: 'yingshi' + } + }) + storageD.did = 'SE' + 'Dvs' + 'Y02' + 'T' + moment().format('YYMMDD') + (yingshiCount + 1) + Math.ceil(Math.random() * 99) const yingshiRes = await models.GbCamera.create(storageD) await models.Camera.update({ gbId: yingshiRes.id diff --git a/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js b/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js index 4facaa8..fa2a4cc 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js +++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js @@ -1,6 +1,7 @@ 'use strict'; -import { RouteRequest } from '@peace/utils'; -import { RouteTable } from '$utils' +// import { RouteRequest } from '@peace/utils'; + +import { RouteTable, RouteRequest } from '$utils' export const INIT_LAYOUT = 'INIT_LAYOUT'; export function initLayout (title, copyright, sections, actions) { diff --git a/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js index 2ad53a0..2d6a40b 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js +++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js @@ -8,7 +8,7 @@ export function initWebSocket ({ ioUrl, token }) { ioUrl = JSON.parse(ioUrl).root } if (!token) { - const user = sessionStorage.getItem('user') + const user = sessionStorage.getItem('vcmpUser') if (user) { token = JSON.parse(user).token } diff --git a/code/VideoAccess-VCMP/web/client/src/layout/index.jsx b/code/VideoAccess-VCMP/web/client/src/layout/index.jsx index 5f72fb8..f3de91c 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/index.jsx +++ b/code/VideoAccess-VCMP/web/client/src/layout/index.jsx @@ -171,21 +171,22 @@ const Root = props => { // setAuthCrossLoading(false) // MicroApp - const microAppListen = async (data) => { - console.log('xxxx', data); - if (data.action == 'initMicro') { - await store.dispatch(push('/noMatch')); - setMicroAppWaiting(false) - } - } - if (window.__MICRO_APP_ENVIRONMENT__) { - console.info('MicroApp') - setAuthCrossLoading(false) - window.microApp.addDataListener(microAppListen, true) - } else { - console.info('NOT MicroApp') - setMicroAppWaiting(false) - } + // const microAppListen = async (data) => { + // console.log('xxxx', data); + // if (data.action == 'initMicro') { + // await store.dispatch(push('/noMatch')); + // setMicroAppWaiting(false) + // } + // } + // if (window.__MICRO_APP_ENVIRONMENT__) { + // console.info('MicroApp') + // setAuthCrossLoading(false) + // window.microApp.addDataListener(microAppListen, true) + // } else { + // console.info('NOT MicroApp') + // setMicroAppWaiting(false) + // } + setMicroAppWaiting(false) }, []) return ( diff --git a/code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js b/code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js index c60b211..ac276b6 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js +++ b/code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js @@ -4,10 +4,10 @@ import { ApiTable, AxyRequest } from '$utils' export const INIT_AUTH = 'INIT_AUTH'; export function initAuth (userData) { - const sessionUser = JSON.parse(sessionStorage.getItem('user')) + const sessionUser = JSON.parse(sessionStorage.getItem('vcmpUser')) const user = userData || sessionUser || {}; if (user.authorized && !sessionUser) { - sessionStorage.setItem('user', JSON.stringify(user)) + sessionStorage.setItem('vcmpUser', JSON.stringify(user)) } return { type: INIT_AUTH, @@ -44,7 +44,7 @@ export function login (username, password) { return AxyRequest.post(ApiTable.login, { username, password, domain: 'anxinyun' }) .then(user => { - sessionStorage.setItem('user', JSON.stringify(user)); + sessionStorage.setItem('vcmpUser', JSON.stringify(user)); return dispatch({ type: LOGIN_SUCCESS, payload: { user: user }, @@ -63,12 +63,12 @@ export function login (username, password) { export const LOGOUT = 'LOGOUT'; export function logout () { - const user = JSON.parse(sessionStorage.getItem('user')) + const user = JSON.parse(sessionStorage.getItem('vcmpUser')) user && user.token ? AxyRequest.post(ApiTable.logout, { token: user.token }) : null; - sessionStorage.removeItem('user'); + sessionStorage.removeItem('vcmpUser'); return { type: LOGOUT }; diff --git a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js index 618dd0c..f247276 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js +++ b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js @@ -1,105 +1,105 @@ "use strict"; -import { basicAction } from "@peace/utils"; -import { ApiTable } from "$utils"; +// import { basicAction } from "@peace/utils"; +import { ApiTable, basicAction } from "$utils"; -export function getMembers(orgId) { - return (dispatch) => - basicAction({ - type: "get", - dispatch: dispatch, - actionType: "GET_MEMBERS", - url: `${ApiTable.getEnterprisesMembers.replace("{enterpriseId}", orgId)}`, - msg: { error: "获取用户列表失败" }, - reducer: { name: "members" }, - }); +export function getMembers (orgId) { + return (dispatch) => + basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_MEMBERS", + url: `${ApiTable.getEnterprisesMembers.replace("{enterpriseId}", orgId)}`, + msg: { error: "获取用户列表失败" }, + reducer: { name: "members" }, + }); } -export function getNvr(query) { - return (dispatch) => - basicAction({ - type: "get", - dispatch: dispatch, - actionType: "GET_NVR", - query: query, - url: `${ApiTable.getNvr}`, - msg: { option: "获取nvr列表信息" }, - reducer: { name: "equipmentWarehouseNvr", params: { noClear: true } }, - }); +export function getNvr (query) { + return (dispatch) => + basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_NVR", + query: query, + url: `${ApiTable.getNvr}`, + msg: { option: "获取nvr列表信息" }, + reducer: { name: "equipmentWarehouseNvr", params: { noClear: true } }, + }); } -export function getNvrDetails(orgId) { - return (dispatch) => - basicAction({ - type: "get", - dispatch: dispatch, - actionType: "GET_NVR_DETAILS", - url: `${ApiTable.getNvrDetails.replace("{nvrId}", orgId)}`, - msg: { option: "" }, //获取nvr详情 - reducer: { name: "nvrDetails" }, - }); +export function getNvrDetails (orgId) { + return (dispatch) => + basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_NVR_DETAILS", + url: `${ApiTable.getNvrDetails.replace("{nvrId}", orgId)}`, + msg: { option: "" }, //获取nvr详情 + reducer: { name: "nvrDetails" }, + }); } -export function delNvr(orgId) { - return (dispatch) => - basicAction({ - type: "del", - dispatch: dispatch, - actionType: "DEL_NVR", - url: `${ApiTable.delNvr.replace("{nvrId}", orgId)}`, - msg: { - option: - "设备会被存放在“设备回收站”中,删除", - }, - reducer: { name: "" }, - }); +export function delNvr (orgId) { + return (dispatch) => + basicAction({ + type: "del", + dispatch: dispatch, + actionType: "DEL_NVR", + url: `${ApiTable.delNvr.replace("{nvrId}", orgId)}`, + msg: { + option: + "设备会被存放在“设备回收站”中,删除", + }, + reducer: { name: "" }, + }); } -export function addchangeNvr(data) { - return (dispatch) => - basicAction({ - type: "post", - dispatch: dispatch, - data, - actionType: "ADD_CHANGE_NVR", - msg: { option: "添加/修改" }, - url: `${ApiTable.nvr}`, - }); +export function addchangeNvr (data) { + return (dispatch) => + basicAction({ + type: "post", + dispatch: dispatch, + data, + actionType: "ADD_CHANGE_NVR", + msg: { option: "添加/修改" }, + url: `${ApiTable.nvr}`, + }); } -export function getVender() { - //获取设备厂商 - return (dispatch) => - basicAction({ - type: "get", - dispatch: dispatch, - actionType: "GET_VENDER", - url: `${ApiTable.getVender}`, - msg: { error: "获取设备厂商失败" }, - reducer: { name: "vender" }, - }); +export function getVender () { + //获取设备厂商 + return (dispatch) => + basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_VENDER", + url: `${ApiTable.getVender}`, + msg: { error: "获取设备厂商失败" }, + reducer: { name: "vender" }, + }); } -export function getExport() { - return (dispatch) => - basicAction({ - type: "get", - dispatch: dispatch, - actionType: "GET_EXPORT", - url: `${ApiTable.getExport}`, - msg: { option: "导出" }, //导出 - reducer: { name: "" }, - }); +export function getExport () { + return (dispatch) => + basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_EXPORT", + url: `${ApiTable.getExport}`, + msg: { option: "导出" }, //导出 + reducer: { name: "" }, + }); } -export function getCheck(data) { - return (dispatch) => - basicAction({ - type: "post", - dispatch: dispatch, - data, - actionType: "GET_CHECK", - url: `${ApiTable.getCheck}`, - msg: { option: "" }, //校验nvr信息 - reducer: { name: "" }, - }); +export function getCheck (data) { + return (dispatch) => + basicAction({ + type: "post", + dispatch: dispatch, + data, + actionType: "GET_CHECK", + url: `${ApiTable.getCheck}`, + msg: { option: "" }, //校验nvr信息 + reducer: { name: "" }, + }); } \ No newline at end of file diff --git a/code/VideoAccess-VCMP/web/client/src/utils/func.js b/code/VideoAccess-VCMP/web/client/src/utils/func.js index b2a2180..c2b1bda 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/func.js +++ b/code/VideoAccess-VCMP/web/client/src/utils/func.js @@ -2,7 +2,7 @@ export const isAuthorized = (authcode) => { if (JSON.parse(sessionStorage.getItem('user'))) { - const { resources } = JSON.parse(sessionStorage.getItem('user')); + const { resources } = JSON.parse(sessionStorage.getItem('vcmpUser')); return resources.includes(authcode); } else { return false; diff --git a/code/VideoAccess-VCMP/web/client/src/utils/index.js b/code/VideoAccess-VCMP/web/client/src/utils/index.js index b9a0f94..c22e62e 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/index.js +++ b/code/VideoAccess-VCMP/web/client/src/utils/index.js @@ -4,7 +4,8 @@ import { AuthorizationCode } from './authCode'; import { ApiTable, VideoServeApi, RouteTable, - AuthRequest, AxyRequest, IotVideoServerRequest, YingshiRequest + AuthRequest, AxyRequest, IotVideoServerRequest, YingshiRequest, + basicAction,RouteRequest } from './webapi' import { YS_PTZ_DIRECTION, ysptz, @@ -26,6 +27,8 @@ export { AxyRequest, IotVideoServerRequest, YingshiRequest, + basicAction, + RouteRequest, YS_PTZ_DIRECTION, ysptz, diff --git a/code/VideoAccess-VCMP/web/client/src/utils/webapi.js b/code/VideoAccess-VCMP/web/client/src/utils/webapi.js index af5543e..d61ac2b 100644 --- a/code/VideoAccess-VCMP/web/client/src/utils/webapi.js +++ b/code/VideoAccess-VCMP/web/client/src/utils/webapi.js @@ -1,11 +1,20 @@ "use strict"; -import { ProxyRequest } from "@peace/utils"; +import { ProxyRequest, customWebUtils } from "@peace/utils"; export const AuthRequest = new ProxyRequest("_auth"); export const AxyRequest = new ProxyRequest("_axy"); export const IotVideoServerRequest = new ProxyRequest("_vs"); export const YingshiRequest = new ProxyRequest("_yingshi"); +export const webUtils = new customWebUtils({ + userKey: 'vcmpUser' +}); +const { basicAction, RouteRequest } = webUtils +export { + basicAction, RouteRequest +} +console.log(basicAction, RouteRequest); + export const ApiTable = { login: "login", logout: "logout", diff --git a/code/VideoAccess-VCMP/web/package.json b/code/VideoAccess-VCMP/web/package.json index e26013d..aa1f07a 100644 --- a/code/VideoAccess-VCMP/web/package.json +++ b/code/VideoAccess-VCMP/web/package.json @@ -51,8 +51,7 @@ "@douyinfe/semi-webpack-plugin": "^2.13.0", "@fs/attachment": "^1.0.0", "@micro-zoe/micro-app": "^1.0.0-alpha.1", - "@peace/components": "0.0.35", - "@peace/utils": "0.0.53", + "@peace/utils": "0.0.64", "@semi-bot/semi-theme-fscamera": "^1.0.0", "@vitejs/plugin-react": "^1.3.1", "@vitejs/plugin-react-refresh": "^1.3.6",