index.tsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { PageContainer } from '@ant-design/pro-layout';
  2. import { Card, Col, message, Row, Tooltip, Typography } from 'antd';
  3. import { PermissionButton } from '@/components';
  4. import { getMenuPathByCode } from '@/utils/menu';
  5. import useHistory from '@/hooks/route/useHistory';
  6. import { QuestionCircleOutlined } from '@ant-design/icons';
  7. import { useRequest } from 'umi';
  8. import Service from './service';
  9. import { useState } from 'react';
  10. import DeviceModal from './deviceModal';
  11. import './index.less';
  12. const permissionTip = '暂无权限,请联系管理员';
  13. export const service = new Service('media/device');
  14. export default () => {
  15. const dashBoardUrl = getMenuPathByCode('media/DashBoard');
  16. const deviceUrl = getMenuPathByCode('media/Device');
  17. const channelUrl = getMenuPathByCode('media/Device/Channel');
  18. const splitScreenUrl = getMenuPathByCode('media/SplitScreen');
  19. const cascadeUrl = getMenuPathByCode('media/Cascade');
  20. const [visible, setVisible] = useState(false);
  21. const { permission: devicePermission } = PermissionButton.usePermission('media/Device');
  22. const history = useHistory();
  23. const { data: deviceTotal } = useRequest(service.deviceCount, {
  24. formatResult: (res) => res.result,
  25. });
  26. const { data: channelTotal } = useRequest<any, any>(service.channelCount, {
  27. formatResult: (res) => res.result,
  28. defaultParams: {},
  29. });
  30. const addDevice = () => {
  31. if (deviceUrl && devicePermission.add) {
  32. history.push(deviceUrl, {
  33. save: true,
  34. });
  35. } else {
  36. message.warning(permissionTip);
  37. }
  38. };
  39. const jumpSplitScreen = () => {
  40. if (splitScreenUrl) {
  41. history.push(splitScreenUrl);
  42. } else {
  43. message.warning(permissionTip);
  44. }
  45. };
  46. const jumpCascade = () => {
  47. if (cascadeUrl) {
  48. history.push(cascadeUrl);
  49. } else {
  50. message.warning(permissionTip);
  51. }
  52. };
  53. const jumpChannel = () => {
  54. if (channelUrl) {
  55. setVisible(true);
  56. } else {
  57. message.warning(permissionTip);
  58. }
  59. };
  60. return (
  61. <PageContainer>
  62. <DeviceModal
  63. visible={visible}
  64. url={channelUrl}
  65. onCancel={() => {
  66. setVisible(false);
  67. }}
  68. />
  69. <Card className={'media-home'}>
  70. <Row gutter={[12, 12]}>
  71. <Col span={14}>
  72. <div className={'media-home-top'}>
  73. <Typography.Title level={5}>视频中心引导</Typography.Title>
  74. <div className={'media-guide'}>
  75. <div onClick={addDevice}>添加视频设备</div>
  76. <div onClick={jumpSplitScreen}>分屏展示</div>
  77. <div onClick={jumpCascade}>国标级联</div>
  78. </div>
  79. </div>
  80. </Col>
  81. <Col span={10}>
  82. <div className={'media-home-top'}>
  83. <Typography.Title level={5}>
  84. 基础统计
  85. <PermissionButton
  86. isPermission={!!dashBoardUrl}
  87. onClick={() => {
  88. history.push(dashBoardUrl);
  89. }}
  90. type={'link'}
  91. >
  92. 详情
  93. </PermissionButton>
  94. </Typography.Title>
  95. <div className={'media-statistics'}>
  96. <div>
  97. 设备数量
  98. {deviceTotal}
  99. </div>
  100. <div>
  101. 通道数量
  102. {channelTotal}
  103. </div>
  104. </div>
  105. </div>
  106. </Col>
  107. <Col span={24}>
  108. <Typography.Title level={5}>平台架构图</Typography.Title>
  109. <div className={'media-home-content'}></div>
  110. </Col>
  111. <Col span={24}>
  112. <Typography.Title level={5}>
  113. <span style={{ paddingRight: 12 }}>视频设备管理推荐步骤</span>
  114. <Tooltip title={'请根据业务需要对下述步骤进行选择性操作'}>
  115. <QuestionCircleOutlined />
  116. </Tooltip>
  117. </Typography.Title>
  118. <div className={'media-home-steps'}>
  119. <div onClick={addDevice}>
  120. 添加视频设备
  121. <div>根据视频设备的传输协议,在已创建的产品下添加对应的设备</div>
  122. </div>
  123. <div onClick={jumpChannel}>
  124. 查看通道
  125. <div>查看设备下的通道数据,可以进行直播、录制等操作</div>
  126. </div>
  127. <div onClick={jumpSplitScreen}>
  128. 分屏展示
  129. <div>对多个通道的视频流数据进行分屏展示</div>
  130. </div>
  131. </div>
  132. </Col>
  133. </Row>
  134. </Card>
  135. </PageContainer>
  136. );
  137. };