wenlele 2 years ago
parent
commit
981b25f0c2
  1. 71
      api/app/lib/index.js
  2. 3
      api/config.js
  3. 3
      web/client/index.ejs
  4. 6
      web/client/index.html
  5. 3
      web/client/src/app.jsx
  6. 42
      web/client/src/layout/components/header/index.jsx
  7. 11
      web/client/src/layout/components/header/index.less
  8. 15
      web/client/src/layout/components/sider/index.jsx
  9. 3
      web/client/src/layout/components/sider/index.less
  10. 35
      web/client/src/layout/containers/layout/index.jsx
  11. 14
      web/client/src/sections/console/actions/console.js
  12. 7
      web/client/src/sections/console/actions/index.js
  13. 49
      web/client/src/sections/console/containers/console.jsx
  14. 5
      web/client/src/sections/console/containers/index.js
  15. 15
      web/client/src/sections/console/index.js
  16. 15
      web/client/src/sections/console/nav-item.jsx
  17. 5
      web/client/src/sections/console/reducers/index.js
  18. 13
      web/client/src/sections/console/routes.js
  19. 7
      web/client/src/sections/console/style.less
  20. 3
      web/client/src/sections/example/nav-item.jsx
  21. 4
      web/client/src/sections/example1/nav-item.jsx

71
api/app/lib/index.js

@ -44,8 +44,6 @@ module.exports.entry = function (app, router, opts) {
};
module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Sequelize, models: {} }
// 加载定义模型 历史写法
// require('./models/nvr')(dc);
// 模型关系摘出来 初始化之后再定义关系才行
fs.readdirSync(path.join(__dirname, '/models')).forEach((filename) => {
@ -53,74 +51,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
});
const {
Nvr, Camera, CameraAbility, CameraAbilityBind, CameraKind, CameraRemark,
GbCamera, SecretYingshi, Vender, CameraStatus, CameraStatusResolve, CameraStatusLog,
CameraStatusPushConfig, CameraStatusPushMonitor, CameraStatusPushLog, CameraStatusPushReceiver, CameraStatusOfflineLog,
Mirror, MirrorTree, MirrorFilterGroup, MirrorFilter, MirrorCamera
} = dc.models;
// Nvr.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
// User.hasMany(Nvr, { foreignKey: 'userId', sourceKey: 'id' });
Camera.belongsToMany(CameraAbility, { through: CameraAbilityBind, foreignKey: 'cameraId', otherKey: 'abilityId' });
CameraRemark.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraRemark, { foreignKey: 'cameraId', sourceKey: 'id' });
Camera.belongsTo(CameraKind, { foreignKey: 'kindId', targetKey: 'id' });
CameraKind.hasMany(Camera, { foreignKey: 'kindId', sourceKey: 'id' });
Camera.belongsTo(Nvr, { foreignKey: 'nvrId', targetKey: 'id' });
Nvr.hasMany(Camera, { foreignKey: 'nvrId', sourceKey: 'id' });
Nvr.belongsTo(GbCamera, { foreignKey: 'serialNo', targetKey: 'streamid', as: 'gbNvr' });
GbCamera.hasMany(Nvr, { foreignKey: 'serialNo', sourceKey: 'streamid', as: 'gbNvr' });
Camera.belongsTo(GbCamera, { foreignKey: 'gbId', targetKey: 'id' });
GbCamera.hasMany(Camera, { foreignKey: 'gbId', sourceKey: 'id' });
Camera.belongsTo(SecretYingshi, { foreignKey: 'yingshiSecretId', targetKey: 'id' });
SecretYingshi.hasMany(Camera, { foreignKey: 'yingshiSecretId', sourceKey: 'id' });
Camera.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Camera, { foreignKey: 'venderId', sourceKey: 'id' });
Nvr.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Nvr, { foreignKey: 'venderId', sourceKey: 'id' });
CameraStatusResolve.belongsTo(CameraStatus, { foreignKey: 'statusId', targetKey: 'id' });
CameraStatus.hasMany(CameraStatusResolve, { foreignKey: 'statusId', sourceKey: 'id' });
CameraStatusLog.belongsTo(CameraStatus, { foreignKey: 'statusId', targetKey: 'id' });
CameraStatus.hasMany(CameraStatusLog, { foreignKey: 'statusId', sourceKey: 'id' });
CameraStatusPushMonitor.belongsTo(CameraStatusPushConfig, { foreignKey: 'configId', targetKey: 'id' });
CameraStatusPushConfig.hasMany(CameraStatusPushMonitor, { foreignKey: 'configId', sourceKey: 'id' });
CameraStatusPushMonitor.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraStatusPushMonitor, { foreignKey: 'cameraId', sourceKey: 'id' });
CameraStatusPushLog.belongsTo(CameraStatusPushConfig, { foreignKey: 'pushConfigId', targetKey: 'id' });
CameraStatusPushConfig.hasMany(CameraStatusPushLog, { foreignKey: 'pushConfigId', sourceKey: 'id' });
CameraStatusPushReceiver.belongsTo(CameraStatusPushConfig, { foreignKey: 'configId', targetKey: 'id' });
CameraStatusPushConfig.hasMany(CameraStatusPushReceiver, { foreignKey: 'configId', sourceKey: 'id' });
CameraStatusOfflineLog.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraStatusOfflineLog, { foreignKey: 'cameraId', sourceKey: 'id' });
MirrorTree.belongsTo(Mirror, { foreignKey: 'mirrorId', targetKey: 'id' });
Mirror.hasMany(MirrorTree, { foreignKey: 'mirrorId', sourceKey: 'id' });
MirrorFilterGroup.belongsTo(Mirror, { foreignKey: 'mirrorId', targetKey: 'id' });
Mirror.hasMany(MirrorFilterGroup, { foreignKey: 'mirrorId', sourceKey: 'id' });
MirrorFilter.belongsTo(MirrorFilterGroup, { foreignKey: 'groupId', targetKey: 'id' });
MirrorFilterGroup.hasMany(MirrorFilter, { foreignKey: 'groupId', sourceKey: 'id' });
MirrorCamera.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(MirrorCamera, { foreignKey: 'cameraId', sourceKey: 'id' });
MirrorCamera.belongsTo(Mirror, { foreignKey: 'mirrorId', targetKey: 'id' });
Mirror.hasMany(MirrorCamera, { foreignKey: 'mirrorId', sourceKey: 'id' });
};

3
api/config.js

@ -98,9 +98,6 @@ const product = {
},
pssaRequest: [
{// name 会作为一个 request 出现在 ctx.app.fs
name: 'authRequest',
root: IOT_AUTH_API
}, {
name: 'axyRequest',
root: AXY_API_URL
}, {

3
web/client/index.ejs

@ -6,6 +6,9 @@
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<meta content="upgrade-insecure-requests" http-equiv="Content-Security-Policy">
<link rel="shortcut icon" href="/assets/images/favicon.ico">
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({ id: "Jo4eTlZVqgx3uwqm", ck: "Jo4eTlZVqgx3uwqm" })</script>
<script src="/assets/js/jessibuca/jessibuca.js"></script>
<script
src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_14797_10.b43556420cacd0119dedf94deff663bb.js"></script>

6
web/client/index.html

@ -5,9 +5,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<!-- <meta content="upgrade-insecure-requests" http-equiv="Content-Security-Policy"> 会将http转化成https,导致jessibuca视频播放不成功 -->
<link rel="shortcut icon" href="/assets/images/favicon.ico">
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({id: "Jo4eTlZVqgx3uwqm",ck: "Jo4eTlZVqgx3uwqm"})</script>
<script src="/assets/js/jessibuca/jessibuca.js"></script>
<script src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_14797_10.b43556420cacd0119dedf94deff663bb.js"></script>
</head>

3
web/client/src/app.jsx

@ -7,6 +7,7 @@ import Example from './sections/example';
import Example1 from './sections/example1';
import Problem from './sections/problem';
import NoMatch from './sections/noMatch';
import Console from './sections/console';
const App = props => {
const { projectName } = props
@ -20,7 +21,7 @@ const App = props => {
title={projectName}
sections={[
Example,Example1,Problem,
Auth, NoMatch
Auth, NoMatch,Console
]}
/>
)

42
web/client/src/layout/components/header/index.jsx

@ -2,12 +2,14 @@
import React from "react";
import { connect } from "react-redux";
import { Nav, Avatar, Dropdown } from "@douyinfe/semi-ui";
import "./index.less";
const Header = (props) => {
const { dispatch, history, user, actions, socket ,headerItems} = props;
const { dispatch, history, user, actions, socket ,headerItems,tochange} = props;
return (
<>
<div id="top-slider">
<Nav
mode={"horizontal"}
onClick={({ itemKey }) => {
@ -20,9 +22,6 @@ const Header = (props) => {
}
history.push(`/signin`);
}
else{
console.log('1111111111111111');
}
}}
style={{
height: 60,
@ -42,18 +41,28 @@ const Header = (props) => {
}}
footer={
<>
{headerItems.map((item,index)=>(
<Nav.Sub
key={index}
itemKey={item.itemKey}
text={item.text}
dropdownStyle={{color:'#F2F3F5'}}
>
{item.hasOwnProperty('items')&&item.items.map((ite,idx)=>(
<Nav.Item key={idx} itemKey={ite.itemKey} text={ite.text} />
))}
</Nav.Sub>
))}
{headerItems.map((item,index)=>{
// console.log('item',item);
if(item.hasOwnProperty('items')){
return(
<Nav.Sub
key={index+'a'}
itemKey={item.itemKey}
text={item.text}
dropdownStyle={{color:'#F2F3F5'}}
>
{item.hasOwnProperty('items')&&item.items.map((ite,idx)=>(
<Nav.Item key={idx+'d'} itemKey={ite.itemKey} text={ite.text} onClick={()=>{tochange(ite);}}/>
))}
</Nav.Sub>
)
}
else{
return(
<Nav.Item key={index+'a'} itemKey={item.itemKey} text={item.text} onClick={()=>{tochange(item)}} />
)
}
})}
<Nav.Sub
itemKey={"user"}
text={
@ -96,6 +105,7 @@ const Header = (props) => {
</>
}
/>
</div>
</>
);
};

11
web/client/src/layout/components/header/index.less

@ -0,0 +1,11 @@
#top-slider{
.semi-navigation-item-text{
color: #F2F3F5;
}
.semi-navigation-item-icon{
color: #F2F3F5;
}
.semi-navigation-item-selected{
background: none;
}
}

15
web/client/src/layout/components/sider/index.jsx

@ -9,7 +9,7 @@ import "./index.less";
let scrollbar = null
const homePath = '/example/e1/c1'
const Sider = (props) => {
const { collapsed, clientHeight, dispatch, pathname,leftItems } = props
const { collapsed, clientHeight, dispatch, pathname,leftItems,leftChange } = props
const [items, setItems] = useState([])
const [selectedKeys, setSelectedKeys] = useState([])
const [openKeys, setOpenKeys] = useState([])
@ -18,6 +18,7 @@ const Sider = (props) => {
let nextItems = leftItems
let pathname_ = pathname == '/' ? homePath : pathname
const initKeys = (items, lastKeys) => {
console.log('1111111',items);
for (let it of items) {
if (it.to && it.to == pathname_) {
lastKeys.selectedKeys.push(it.itemKey)
@ -66,6 +67,7 @@ const Sider = (props) => {
}, [leftItems])
let routeSelectedKey = [useLocation().pathname.split('/')[1]]//
let routeSelectedKeys = [useLocation().pathname.split('/')[2]]//
let routeSelectedKeyss = [useLocation().pathname.split('/')[3]]//
useEffect(()=>{
let pathname_ = pathname == '/' ? homePath : pathname
const initKeys = (items, lastKeys) => {
@ -84,8 +86,10 @@ const Sider = (props) => {
}
return lastKeys
}
if(routeSelectedKeys[0]){
if(routeSelectedKeyss[0]){
setSelectedKeys(routeSelectedKeyss)
}
else if(routeSelectedKeys[0]){
setSelectedKeys(routeSelectedKeys)
}
else{
@ -95,7 +99,7 @@ const Sider = (props) => {
if (lastOpenKeys) {
setOpenKeys(JSON.parse(lastOpenKeys))
}
},[window.localStorage.vcmp_open_sider,window.localStorage.vcmp_selected_sider])
},[window.localStorage.vcmp_open_sider,window.localStorage.vcmp_selected_sider,leftChange])
useEffect(() => {
if (scrollbar) {
@ -106,9 +110,8 @@ const Sider = (props) => {
<div id={'page-slider'} style={{ height: clientHeight, position: 'relative',background:'#101531',width:180 }}>
<Nav
style={{background:'#101531',width:180,padding:0}}
// defaultOpenKeys={openKeys}
// defaultSelectedKeys ={selectedKeys}
selectedKeys={selectedKeys}
openKeys={openKeys}
onSelect={({ selectedItems, selectedKeys, }) => {
const selectItem = selectedItems[0]

3
web/client/src/layout/components/sider/index.less

@ -11,8 +11,5 @@
}
.semi-navigation-sub-title-selected{
background: #1D2343;
.semi-navigation-item-inner{
}
}
}

35
web/client/src/layout/containers/layout/index.jsx

@ -79,21 +79,25 @@ const LayoutContainer = props => {
return data;
}
}
const [allItems, setAllItems] = useState([])
const [headerItems, setHeaderItems] = useState([])
const [leftItems, setLeftItems] = useState([])
const [leftChange, setLeftChange] = useState(true)
const [leftShow, setLeftShow] = useState(false)
useEffect(() => {
let topItems = []//
let siderItems = []//
// let siderItems = []//
let nextItems = []//
for (let c of sections) {
if (typeof c.getNavItem == 'function') {
let item = c.getNavItem(user, dispatch);
if (item) {
nextItems.push.apply(nextItems, item)
if (item.length > 0) {
let itm = deepCopy(item[0]);
let itms=deepCopy(item[0]);
if (itm.hasOwnProperty('items')) {
siderItems.push.apply(siderItems, itms.items)
// siderItems.push.apply(siderItems, itms.items)
for (let i = 0; i < itm.items.length; i++) {
delete itm.items[i].items
}
@ -103,12 +107,13 @@ const LayoutContainer = props => {
topItems.push.apply(topItems, item)
}
}
}
}
}
setLeftShow(false)
setAllItems(nextItems)
setHeaderItems(topItems)
setLeftItems(siderItems)
// setLeftItems(siderItems)
window.addEventListener('resize', resize_);
return () => {
@ -191,19 +196,35 @@ const LayoutContainer = props => {
}}
collapsed={collapsed}
history={history}
tochange={(val) => {
setLeftChange(!leftChange)
if(val.fatherKey){
for (let i = 0; i < allItems.length; i++) {
if(val.fatherKey==allItems[i].itemKey){
setLeftItems(allItems[i].items)
}
}
setLeftShow(true)
}
else{
setLeftShow(false)
}
history.push(val.to);
}}
/>
</Layout.Header>
<Layout style={{ height: 'calc(100% - 60px)' }}>
<Layout.Sider>
{leftShow?(<Layout.Sider>
<Sider
sections={sections}
leftItems={leftItems}
dispatch={dispatch}
user={user}
leftChange={leftChange}
pathname={location.pathname}
collapsed={collapsed}
/>
</Layout.Sider>
</Layout.Sider>):('')}
<Layout.Content>
<div style={{
margin: '12px 12px 0px',

14
web/client/src/sections/console/actions/console.js

@ -0,0 +1,14 @@
'use strict';
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' }
// });
// }

7
web/client/src/sections/console/actions/index.js

@ -0,0 +1,7 @@
'use strict';
import * as console from './console'
export default {
...console
}

49
web/client/src/sections/console/containers/console.jsx

@ -0,0 +1,49 @@
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { Spin, Card } from '@douyinfe/semi-ui';
import '../style.less'
const { Meta } = Card;
const Example = (props) => {
const { dispatch, actions, user, loading, socket } = props
useEffect(() => {
// ACTION
// dispatch(actions.example.getMembers(user.orgId))
}, [])
// websocket 使
// useEffect(() => {
// console.log(socket)
// if (socket) {
// socket.on('TEST', function (msg) {
// console.info(msg);
// });
// return () => {
// socket.off("TEST");
// }
// }
// }, [socket])
return (
<>
<div>
texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext
</div>
</>
)
}
function mapStateToProps (state) {
const { auth, global, members, webSocket } = state;
return {
// loading: members.isRequesting,
// user: auth.user,
// actions: global.actions,
// members: members.data,
// socket: webSocket.socket
};
}
export default connect(mapStateToProps)(Example);

5
web/client/src/sections/console/containers/index.js

@ -0,0 +1,5 @@
'use strict';
import Console from './console';
export { Console };

15
web/client/src/sections/console/index.js

@ -0,0 +1,15 @@
'use strict';
import reducers from './reducers';
import routes from './routes';
import actions from './actions';
import { getNavItem } from './nav-item';
export default {
key: 'console',
name: '控制台',
reducers: reducers,
routes: routes,
actions: actions,
getNavItem: getNavItem
};

15
web/client/src/sections/console/nav-item.jsx

@ -0,0 +1,15 @@
import React from 'react';
import { IconCode } from '@douyinfe/semi-icons';
export function getNavItem (user, dispatch) {
return (
[
{
itemKey: 'console',
text: '控制台',
to: '/console',
// icon: <IconCode />,
},
]
);
}

5
web/client/src/sections/console/reducers/index.js

@ -0,0 +1,5 @@
'use strict';
export default {
}

13
web/client/src/sections/console/routes.js

@ -0,0 +1,13 @@
'use strict';
import { Console, } from './containers';
export default [{
type: 'inner',
route: {
path: '/console',
key: 'console',
breadcrumb: '控制台',
component: Console,
// 不设置 component 则面包屑禁止跳转
}
}];

7
web/client/src/sections/console/style.less

@ -0,0 +1,7 @@
#example {
box-shadow: 3px 3px 2px black;
}
#example:hover {
color: yellowgreen;
}

3
web/client/src/sections/example/nav-item.jsx

@ -14,6 +14,7 @@ export function getNavItem (user, dispatch) {
text: '举个棒子1',
icon: <IconCode />,
to: '/example/e1/c1',
fatherKey:'example',
items: [{
itemKey: 'c1', to: '/example/e1/c1', text: '举个锤子1'
}]
@ -21,6 +22,8 @@ export function getNavItem (user, dispatch) {
itemKey: 'e2',
text: '举个棒子2',
icon: <IconCode />,
to: '/example/e2/c2',
fatherKey:'example',
items: [{
itemKey: 'c2', to: '/example/e2/c2', text: '举个锤子2'
}]

4
web/client/src/sections/example1/nav-item.jsx

@ -13,6 +13,8 @@ export function getNavItem (user, dispatch) {
itemKey: 'e3',
text: '举个棒子3',
icon: <IconCode />,
to: '/example/e3/c3',
fatherKey:'example1',
items: [{
itemKey: 'c3', to: '/example/e3/c3', text: '举个锤子3'
}]
@ -20,6 +22,8 @@ export function getNavItem (user, dispatch) {
itemKey: 'e4',
text: '举个棒子4',
icon: <IconCode />,
to: '/example/e4/c4',
fatherKey:'example1',
items: [{
itemKey: 'c4', to: '/example/e4/c4', text: '举个锤子4'
}]

Loading…
Cancel
Save