Browse Source

user -vcmpUser

release_1.3.0
巴林闲侠 3 years ago
parent
commit
00f4ca57ec
  1. 7
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js
  2. 5
      code/VideoAccess-VCMP/web/client/src/layout/actions/global.js
  3. 2
      code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js
  4. 31
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  5. 10
      code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js
  6. 176
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js
  7. 2
      code/VideoAccess-VCMP/web/client/src/utils/func.js
  8. 5
      code/VideoAccess-VCMP/web/client/src/utils/index.js
  9. 11
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js
  10. 3
      code/VideoAccess-VCMP/web/package.json

7
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

5
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) {

2
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
}

31
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 (

10
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
};

176
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: "" },
});
}

2
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;

5
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,

11
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",

3
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",

Loading…
Cancel
Save