diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js
index 1c00233..56b58ba 100644
--- a/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js
+++ b/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js
@@ -46,8 +46,12 @@ async function edit (ctx, next) {
async function get (ctx) {
const models = ctx.fs.dc.models;
try {
- const { limit, offset, orderBy, orderDirection } = ctx.query
+ const { limit, page, orderBy, orderDirection } = ctx.query
let findOption = {
+ attributes: { exclude: ['delete'] },
+ where: {
+ delete: false,
+ },
order: [
[orderBy || 'id', orderDirection || 'DESC']
]
@@ -55,8 +59,8 @@ async function get (ctx) {
if (limit) {
findOption.limit = limit
}
- if (offset) {
- findOption.offset = offset
+ if (page && limit) {
+ findOption.offset = page * limit
}
const res = await models.Nvr.findAll(findOption)
diff --git a/code/VideoAccess-VCMP/api/app/lib/index.js b/code/VideoAccess-VCMP/api/app/lib/index.js
index d5668f6..96b161e 100644
--- a/code/VideoAccess-VCMP/api/app/lib/index.js
+++ b/code/VideoAccess-VCMP/api/app/lib/index.js
@@ -2,30 +2,34 @@
const routes = require('./routes');
const redisConnect = require('./service/redis')
+const socketConect = require('./service/socket')
const authenticator = require('./middlewares/authenticator');
// const apiLog = require('./middlewares/api-log');
const businessRest = require('./middlewares/business-rest');
module.exports.entry = function (app, router, opts) {
- app.fs.logger.log('info', '[FS-AUTH]', 'Inject auth and api mv into router.');
+ app.fs.logger.log('info', '[FS-AUTH]', 'Inject auth and api mv into router.');
- app.fs.api = app.fs.api || {};
- app.fs.api.authAttr = app.fs.api.authAttr || {};
- app.fs.api.logAttr = app.fs.api.logAttr || {};
+ app.fs.api = app.fs.api || {};
+ app.fs.api.authAttr = app.fs.api.authAttr || {};
+ app.fs.api.logAttr = app.fs.api.logAttr || {};
- redisConnect(app, opts)
-
- router.use(authenticator(app, opts));
- // router.use(businessRest(app, router, opts));
- // router.use(apiLog(app, opts));
+ // 顺序固定 ↓
+ redisConnect(app, opts)
+ socketConect(app, opts)
- router = routes(app, router, opts);
+ router.use(authenticator(app, opts));
+ // router.use(businessRest(app, router, opts));
+ // router.use(apiLog(app, opts));
+
+ router = routes(app, router, opts);
};
module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Sequelize, models: {} }
- require('./models/camera_ability')(dc);
- require('./models/camera_kind')(dc);
- require('./models/camera')(dc);
- require('./models/nvr')(dc);
- require('./models/vender')(dc);
+ require('./models/camera_ability')(dc);
+ require('./models/camera_kind')(dc);
+ require('./models/camera')(dc);
+ require('./models/nvr')(dc);
+ require('./models/vender')(dc);
+ require('./models/ax_project')(dc);
};
diff --git a/code/VideoAccess-VCMP/api/app/lib/models/ax_project.js b/code/VideoAccess-VCMP/api/app/lib/models/ax_project.js
new file mode 100644
index 0000000..b8e8844
--- /dev/null
+++ b/code/VideoAccess-VCMP/api/app/lib/models/ax_project.js
@@ -0,0 +1,40 @@
+/* eslint-disable*/
+'use strict';
+
+module.exports = dc => {
+ const DataTypes = dc.ORM;
+ const sequelize = dc.orm;
+ const AxProject = sequelize.define("axProject", {
+ id: {
+ type: DataTypes.INTEGER,
+ allowNull: false,
+ defaultValue: null,
+ comment: null,
+ primaryKey: true,
+ field: "id",
+ autoIncrement: false,
+ unique: "ax_project_id_uindex"
+ },
+ name: {
+ type: DataTypes.STRING,
+ allowNull: false,
+ defaultValue: null,
+ comment: null,
+ primaryKey: false,
+ field: "name",
+ autoIncrement: false
+ }
+ }, {
+ tableName: "ax_project",
+ comment: "",
+ indexes: []
+ });
+
+ const Nvr = dc.models.Nvr;
+
+ // Nvr.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
+ // User.hasMany(Nvr, { foreignKey: 'userId', sourceKey: 'id' });
+
+ dc.models.AxProject = AxProject;
+ return AxProject;
+};
\ No newline at end of file
diff --git a/code/VideoAccess-VCMP/api/app/lib/service/socket.js b/code/VideoAccess-VCMP/api/app/lib/service/socket.js
new file mode 100644
index 0000000..e15f6ef
--- /dev/null
+++ b/code/VideoAccess-VCMP/api/app/lib/service/socket.js
@@ -0,0 +1,25 @@
+'use strict';
+
+module.exports = async function factory (app, opts) {
+
+ app.socket.on('connection', async (socket) => {
+ console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已连接:' + socket.id);
+ socket.on('disconnecting', async (reason) => {
+ console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已断开连接:' + reason);
+ })
+ })
+
+ // 使用测试 保持链接
+ // setInterval(async () => {
+ // // const { connected } = app.socket.sockets
+ // // const roomId = 'ROOM_' + Math.random()
+ // // if (connected) {
+ // // for (let c in connected) {
+ // // connected[c].join(roomId)
+ // // }
+ // // app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
+ // // }
+
+ // app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', })
+ // }, 1000)
+}
diff --git a/code/VideoAccess-VCMP/web/client/assets/images/background/loginBackground.png b/code/VideoAccess-VCMP/web/client/assets/images/background/loginBackground.png
new file mode 100644
index 0000000..39946d7
Binary files /dev/null and b/code/VideoAccess-VCMP/web/client/assets/images/background/loginBackground.png differ
diff --git a/code/VideoAccess-VCMP/web/client/assets/images/background/loginbg.png b/code/VideoAccess-VCMP/web/client/assets/images/background/loginbg.png
new file mode 100644
index 0000000..4713d09
Binary files /dev/null and b/code/VideoAccess-VCMP/web/client/assets/images/background/loginbg.png differ
diff --git a/code/VideoAccess-VCMP/web/client/assets/images/background/password.png b/code/VideoAccess-VCMP/web/client/assets/images/background/password.png
new file mode 100644
index 0000000..9b3d8a8
Binary files /dev/null and b/code/VideoAccess-VCMP/web/client/assets/images/background/password.png differ
diff --git a/code/VideoAccess-VCMP/web/client/assets/images/background/username.png b/code/VideoAccess-VCMP/web/client/assets/images/background/username.png
new file mode 100644
index 0000000..d29c1c2
Binary files /dev/null and b/code/VideoAccess-VCMP/web/client/assets/images/background/username.png differ
diff --git a/code/VideoAccess-VCMP/web/client/src/app.jsx b/code/VideoAccess-VCMP/web/client/src/app.jsx
index dfd09e7..f6d9bb7 100644
--- a/code/VideoAccess-VCMP/web/client/src/app.jsx
+++ b/code/VideoAccess-VCMP/web/client/src/app.jsx
@@ -3,7 +3,7 @@
import React, { useEffect } from 'react';
import Layout from './layout';
import Auth from './sections/auth';
-// import Example from './sections/example';
+import Example from './sections/example';
import EquipmentWarehouse from './sections/equipmentWarehouse';
const App = props => {
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 71b5c97..0548a95 100644
--- a/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js
+++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/global.js
@@ -2,8 +2,6 @@
import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils'
-// import io from 'socket.io-client';
-
export const INIT_LAYOUT = 'INIT_LAYOUT';
export function initLayout (title, copyright, sections, actions) {
return {
@@ -35,9 +33,6 @@ export function initApiRoot () {
return dispatch => {
RouteRequest.get(RouteTable.apiRoot).then(res => {
localStorage.setItem('apiRoot', res.root);
-
- // const socket = io('ws://127.0.0.1:4000', () => { });
-
dispatch({
type: INIT_API_ROOT,
payload: {
diff --git a/code/VideoAccess-VCMP/web/client/src/layout/actions/index.js b/code/VideoAccess-VCMP/web/client/src/layout/actions/index.js
new file mode 100644
index 0000000..4e98b4d
--- /dev/null
+++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/index.js
@@ -0,0 +1,9 @@
+'use strict';
+
+import * as global from './global'
+import * as socket from './webSocket';
+
+export default {
+ ...global,
+ ...socket,
+};
\ No newline at end of file
diff --git a/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js
new file mode 100644
index 0000000..fa1a321
--- /dev/null
+++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js
@@ -0,0 +1,33 @@
+'use strict';
+import io from 'socket.io-client';
+
+export const INIT_WEB_SOCKET = 'INIT_WEB_SOCKET'
+export function initWebSocket ({ ioUrl, token }) {
+ if (!ioUrl) {
+ ioUrl = localStorage.getItem('apiRoot')
+ }
+ if (!token) {
+ const user = sessionStorage.getItem('user')
+ if (user) {
+ token = JSON.parse(user).token
+ }
+ }
+ if (!ioUrl || !token) {
+ return {
+ type: '',
+ }
+ }
+ return dispatch => {
+ const socket = io(ioUrl, {
+ query: {
+ token: token
+ },
+ });
+ dispatch({
+ type: INIT_WEB_SOCKET,
+ payload: {
+ socket: socket
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx b/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx
index 2954b53..457c815 100644
--- a/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx
+++ b/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { Nav } from '@douyinfe/semi-ui';
const Header = props => {
- const { dispatch, history, user, actions } = props
+ const { dispatch, history, user, actions, socket } = props
return (
@@ -20,6 +20,9 @@ const Header = props => {