26 changed files with 262 additions and 72 deletions
@ -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; |
|||
}; |
@ -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)
|
|||
} |
After Width: | Height: | Size: 1.9 MiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 549 B |
@ -0,0 +1,9 @@ |
|||
'use strict'; |
|||
|
|||
import * as global from './global' |
|||
import * as socket from './webSocket'; |
|||
|
|||
export default { |
|||
...global, |
|||
...socket, |
|||
}; |
@ -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 |
|||
} |
|||
}) |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
'use strict'; |
|||
import * as actionTypes from '../actions/webSocket'; |
|||
import Immutable from 'immutable'; |
|||
|
|||
const initState = { |
|||
socket: null, |
|||
}; |
|||
|
|||
function webSocket (state = initState, action) { |
|||
const payload = action.payload; |
|||
switch (action.type) { |
|||
case actionTypes.INIT_WEB_SOCKET: |
|||
return Immutable.fromJS(state).merge({ |
|||
socket: payload.socket, |
|||
}).toJS(); |
|||
default: |
|||
return state; |
|||
} |
|||
} |
|||
|
|||
export default webSocket; |
@ -0,0 +1,7 @@ |
|||
input:-webkit-autofill{ |
|||
-webkit-text-fill-color:black !important; |
|||
-webkit-box-shadow: 0 0 0px 1000px transparent inset !important; |
|||
box-shadow: 0 0 0px 1000px transparent inset !important; |
|||
background-color:transparent; |
|||
transition: background-color 50000s ease-in-out 0s; |
|||
} |
Loading…
Reference in new issue