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. 29
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  5. 10
      code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js
  6. 20
      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 }) const playUrlRes = await getYingshiPlayUrl({ deviceSerial: d.deviceSerial, token: tokenYingshi })
storageD.playUrl = playUrlRes 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) const yingshiRes = await models.GbCamera.create(storageD)
await models.Camera.update({ await models.Camera.update({
gbId: yingshiRes.id gbId: yingshiRes.id

5
code/VideoAccess-VCMP/web/client/src/layout/actions/global.js

@ -1,6 +1,7 @@
'use strict'; 'use strict';
import { RouteRequest } from '@peace/utils'; // import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils'
import { RouteTable, RouteRequest } from '$utils'
export const INIT_LAYOUT = 'INIT_LAYOUT'; export const INIT_LAYOUT = 'INIT_LAYOUT';
export function initLayout (title, copyright, sections, actions) { 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 ioUrl = JSON.parse(ioUrl).root
} }
if (!token) { if (!token) {
const user = sessionStorage.getItem('user') const user = sessionStorage.getItem('vcmpUser')
if (user) { if (user) {
token = JSON.parse(user).token token = JSON.parse(user).token
} }

29
code/VideoAccess-VCMP/web/client/src/layout/index.jsx

@ -171,21 +171,22 @@ const Root = props => {
// setAuthCrossLoading(false) // setAuthCrossLoading(false)
// MicroApp // MicroApp
const microAppListen = async (data) => { // const microAppListen = async (data) => {
console.log('xxxx', data); // console.log('xxxx', data);
if (data.action == 'initMicro') { // if (data.action == 'initMicro') {
await store.dispatch(push('/noMatch')); // await store.dispatch(push('/noMatch'));
setMicroAppWaiting(false) // setMicroAppWaiting(false)
} // }
} // }
if (window.__MICRO_APP_ENVIRONMENT__) { // if (window.__MICRO_APP_ENVIRONMENT__) {
console.info('MicroApp') // console.info('MicroApp')
setAuthCrossLoading(false) // setAuthCrossLoading(false)
window.microApp.addDataListener(microAppListen, true) // window.microApp.addDataListener(microAppListen, true)
} else { // } else {
console.info('NOT MicroApp') // console.info('NOT MicroApp')
// setMicroAppWaiting(false)
// }
setMicroAppWaiting(false) setMicroAppWaiting(false)
}
}, []) }, [])
return ( 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 const INIT_AUTH = 'INIT_AUTH';
export function initAuth (userData) { export function initAuth (userData) {
const sessionUser = JSON.parse(sessionStorage.getItem('user')) const sessionUser = JSON.parse(sessionStorage.getItem('vcmpUser'))
const user = userData || sessionUser || {}; const user = userData || sessionUser || {};
if (user.authorized && !sessionUser) { if (user.authorized && !sessionUser) {
sessionStorage.setItem('user', JSON.stringify(user)) sessionStorage.setItem('vcmpUser', JSON.stringify(user))
} }
return { return {
type: INIT_AUTH, type: INIT_AUTH,
@ -44,7 +44,7 @@ export function login (username, password) {
return AxyRequest.post(ApiTable.login, { username, password, domain: 'anxinyun' }) return AxyRequest.post(ApiTable.login, { username, password, domain: 'anxinyun' })
.then(user => { .then(user => {
sessionStorage.setItem('user', JSON.stringify(user)); sessionStorage.setItem('vcmpUser', JSON.stringify(user));
return dispatch({ return dispatch({
type: LOGIN_SUCCESS, type: LOGIN_SUCCESS,
payload: { user: user }, payload: { user: user },
@ -63,12 +63,12 @@ export function login (username, password) {
export const LOGOUT = 'LOGOUT'; export const LOGOUT = 'LOGOUT';
export function logout () { export function logout () {
const user = JSON.parse(sessionStorage.getItem('user')) const user = JSON.parse(sessionStorage.getItem('vcmpUser'))
user && user.token ? user && user.token ?
AxyRequest.post(ApiTable.logout, { AxyRequest.post(ApiTable.logout, {
token: user.token token: user.token
}) : null; }) : null;
sessionStorage.removeItem('user'); sessionStorage.removeItem('vcmpUser');
return { return {
type: LOGOUT type: LOGOUT
}; };

20
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js

@ -1,9 +1,9 @@
"use strict"; "use strict";
import { basicAction } from "@peace/utils"; // import { basicAction } from "@peace/utils";
import { ApiTable } from "$utils"; import { ApiTable, basicAction } from "$utils";
export function getMembers(orgId) { export function getMembers (orgId) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "get", type: "get",
@ -15,7 +15,7 @@ export function getMembers(orgId) {
}); });
} }
export function getNvr(query) { export function getNvr (query) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "get", type: "get",
@ -28,7 +28,7 @@ export function getNvr(query) {
}); });
} }
export function getNvrDetails(orgId) { export function getNvrDetails (orgId) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "get", type: "get",
@ -39,7 +39,7 @@ export function getNvrDetails(orgId) {
reducer: { name: "nvrDetails" }, reducer: { name: "nvrDetails" },
}); });
} }
export function delNvr(orgId) { export function delNvr (orgId) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "del", type: "del",
@ -53,7 +53,7 @@ export function delNvr(orgId) {
reducer: { name: "" }, reducer: { name: "" },
}); });
} }
export function addchangeNvr(data) { export function addchangeNvr (data) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "post", type: "post",
@ -65,7 +65,7 @@ export function addchangeNvr(data) {
}); });
} }
export function getVender() { export function getVender () {
//获取设备厂商 //获取设备厂商
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
@ -78,7 +78,7 @@ export function getVender() {
}); });
} }
export function getExport() { export function getExport () {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "get", type: "get",
@ -91,7 +91,7 @@ export function getExport() {
} }
export function getCheck(data) { export function getCheck (data) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "post", type: "post",

2
code/VideoAccess-VCMP/web/client/src/utils/func.js

@ -2,7 +2,7 @@
export const isAuthorized = (authcode) => { export const isAuthorized = (authcode) => {
if (JSON.parse(sessionStorage.getItem('user'))) { if (JSON.parse(sessionStorage.getItem('user'))) {
const { resources } = JSON.parse(sessionStorage.getItem('user')); const { resources } = JSON.parse(sessionStorage.getItem('vcmpUser'));
return resources.includes(authcode); return resources.includes(authcode);
} else { } else {
return false; return false;

5
code/VideoAccess-VCMP/web/client/src/utils/index.js

@ -4,7 +4,8 @@ import { AuthorizationCode } from './authCode';
import { import {
ApiTable, VideoServeApi, ApiTable, VideoServeApi,
RouteTable, RouteTable,
AuthRequest, AxyRequest, IotVideoServerRequest, YingshiRequest AuthRequest, AxyRequest, IotVideoServerRequest, YingshiRequest,
basicAction,RouteRequest
} from './webapi' } from './webapi'
import { import {
YS_PTZ_DIRECTION, ysptz, YS_PTZ_DIRECTION, ysptz,
@ -26,6 +27,8 @@ export {
AxyRequest, AxyRequest,
IotVideoServerRequest, IotVideoServerRequest,
YingshiRequest, YingshiRequest,
basicAction,
RouteRequest,
YS_PTZ_DIRECTION, YS_PTZ_DIRECTION,
ysptz, ysptz,

11
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -1,11 +1,20 @@
"use strict"; "use strict";
import { ProxyRequest } from "@peace/utils"; import { ProxyRequest, customWebUtils } from "@peace/utils";
export const AuthRequest = new ProxyRequest("_auth"); export const AuthRequest = new ProxyRequest("_auth");
export const AxyRequest = new ProxyRequest("_axy"); export const AxyRequest = new ProxyRequest("_axy");
export const IotVideoServerRequest = new ProxyRequest("_vs"); export const IotVideoServerRequest = new ProxyRequest("_vs");
export const YingshiRequest = new ProxyRequest("_yingshi"); 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 = { export const ApiTable = {
login: "login", login: "login",
logout: "logout", logout: "logout",

3
code/VideoAccess-VCMP/web/package.json

@ -51,8 +51,7 @@
"@douyinfe/semi-webpack-plugin": "^2.13.0", "@douyinfe/semi-webpack-plugin": "^2.13.0",
"@fs/attachment": "^1.0.0", "@fs/attachment": "^1.0.0",
"@micro-zoe/micro-app": "^1.0.0-alpha.1", "@micro-zoe/micro-app": "^1.0.0-alpha.1",
"@peace/components": "0.0.35", "@peace/utils": "0.0.64",
"@peace/utils": "0.0.53",
"@semi-bot/semi-theme-fscamera": "^1.0.0", "@semi-bot/semi-theme-fscamera": "^1.0.0",
"@vitejs/plugin-react": "^1.3.1", "@vitejs/plugin-react": "^1.3.1",
"@vitejs/plugin-react-refresh": "^1.3.6", "@vitejs/plugin-react-refresh": "^1.3.6",

Loading…
Cancel
Save