diff --git a/code/VideoAccess-VCMP/api/app/lib/index.js b/code/VideoAccess-VCMP/api/app/lib/index.js index c135a43..96b161e 100644 --- a/code/VideoAccess-VCMP/api/app/lib/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/index.js @@ -8,27 +8,28 @@ const authenticator = require('./middlewares/authenticator'); 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) - socketConect(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/web/client/src/layout/actions/webSocket.js b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js index 8a5fe12..b93b78a 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js +++ b/code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js @@ -3,29 +3,31 @@ 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') - 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 - } - }) - } + 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/package.json b/code/VideoAccess-VCMP/web/package.json index 36aeda8..aa18208 100644 --- a/code/VideoAccess-VCMP/web/package.json +++ b/code/VideoAccess-VCMP/web/package.json @@ -44,10 +44,12 @@ "redux": "^4.0.5", "redux-thunk": "^2.3.0", "style-loader": "^2.0.0", + "vite": "^2.9.5", "webpack": "^5.3.2", "webpack-bundle-analyzer": "^4.1.0", "webpack-cli": "^4.2.0", "webpack-dev-middleware": "^4.0.2", + "webpack-dev-server": "^3.11.2", "webpack-hot-middleware": "^2.25.0" }, "dependencies": { @@ -66,8 +68,8 @@ "moment": "^2.22.0", "npm": "^7.20.6", "perfect-scrollbar": "^1.5.5", - "superagent": "^6.1.0", - "vite": "^2.9.5", - "webpack-dev-server": "^3.11.2" + "socket.io-client": "^4.5.0", + "socket.io-parser": "^4.2.0", + "superagent": "^6.1.0" } }