Index.cshtml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. @using WeApp.Configuration
  2. @{
  3. ViewBag.Title = "客户端消息监测";
  4. Layout = "~/Views/Shared/Layout/_Layout.None.cshtml";
  5. }
  6. @section styles{
  7. <style>
  8. .main-box {
  9. width: 100vw;
  10. height: 100vh;
  11. display: flex;
  12. flex-direction: column;
  13. padding: 5px 15px;
  14. margin: 0 auto;
  15. font-size: 16px;
  16. /*background-image: url('../../Content/Image/home/bg.jpg');*/
  17. }
  18. .tool-box {
  19. width: 100%;
  20. height: 50px;
  21. display: flex;
  22. justify-content: flex-start;
  23. align-items: center;
  24. }
  25. .tool-box .btn, .tool-box .form-control {
  26. margin: 0 10px;
  27. }
  28. .content-box {
  29. width: 100%;
  30. height: calc(100vh - 50px)
  31. }
  32. .msg-box {
  33. width: 100%;
  34. height: 100%;
  35. color: #fff;
  36. background-image: linear-gradient(45deg,#3b2e7e,#4b5cc4);
  37. background-size: 100% 100%;
  38. background-repeat: no-repeat;
  39. padding: 15px;
  40. }
  41. .message {
  42. width: 100%;
  43. word-break: break-all;
  44. padding-top: 5px;
  45. line-height: 1.45;
  46. max-height: 100px;
  47. }
  48. .message .date {
  49. color: #ff0;
  50. padding-left: 6px;
  51. }
  52. .message .topic {
  53. padding-left: 2px;
  54. color: #ff0;
  55. font-weight: 600;
  56. }
  57. </style>
  58. }
  59. <div class="main-box">
  60. <div class="tool-box">
  61. <button class="btn btn-sm btn-danger" type="button" onclick="Refresh(1)">重新连接</button>
  62. <button class="btn btn-sm btn-danger" type="button" onclick="Refresh(2)">引擎重连</button>
  63. <input id="msg" class="form-control" style="width: 300px" placeholder="请输入需发送的消息" type="text" value="" />
  64. <button class="btn btn-sm btn-success" type="button" onclick="Send()">发送消息</button>
  65. <button class="btn btn-sm btn-success" type="button" onclick="EngineSend()">引擎发送消息</button>
  66. </div>
  67. <div class="content-box row">
  68. <div id="r-box" class="col-md-8 msg-box"><div class="box-body"></div></div>
  69. <div id="s-box" class="col-md-4 msg-box"><div class="box-body"></div></div>
  70. </div>
  71. </div>
  72. @section scripts
  73. {
  74. <script>
  75. $(function () {
  76. Scroll($('.msg-box'));
  77. //setInterval(function () {
  78. // Send();
  79. // EngineSend();
  80. //},1000*5)
  81. });
  82. function Scroll(that) {
  83. $(that).overlayScrollbars({
  84. className: "os-theme-thin-dark",
  85. resize: "n", //[ "none", "both", "horizontal", "vertical" ]shorthand: [ "n", "b", "h", "v" ]
  86. normalizeRTL: true, //是否应规范化RTL滚动。
  87. sizeAutoCapable: true,
  88. clipAlways: true,
  89. paddingAbsolute: false,
  90. overflowBehavior: {
  91. x: "v-h", //[ "hidden", "scroll", "visible-hidden", "visible-scroll" ]shorthand: [ "h", "s", "v-h", "v-s" ]
  92. y: "s"
  93. },
  94. scrollbars: {
  95. dragScrolling: true,
  96. clickScrolling: true,
  97. visibility: "a", //[ "visible", "hidden", "auto" ]shorthand: [ "v", "h", "a" ]
  98. autoHide: "n", //[ "never", "scroll", "leave", "move" ]shorthand: [ "n", "s", "l", "m" ]
  99. autoHideDelay: 800
  100. }
  101. });
  102. }
  103. function Refresh(id) {
  104. $.iwbAjax5({
  105. url: '/MsgMonitor/Refresh/' + id
  106. });
  107. var str = '<div class="message"><span class="date">[ {0} ] </span><span class="content">{1}</span></div>'
  108. .format(new Date().format('yyyy-MM-dd hh:mm:ss'), id == 1 ? "客户端重连" : "引擎重连");
  109. $('#s-box .box-body').prepend(str);
  110. }
  111. function Send() {
  112. var msg = $('#msg').val();
  113. $.iwbAjax5({
  114. url: '/MsgMonitor/Send/' + msg
  115. });
  116. //var str = '<div class="message"><span class="date">[ {0} ] </span><span class="content">客户端:{1}</span></div>'
  117. // .format(new Date().format('yyyy-MM-dd hh:mm:ss'), msg);
  118. //$('#s-box .box-body').prepend(str);
  119. }
  120. function EngineSend() {
  121. var msg = $('#msg').val();
  122. $.iwbAjax5({
  123. url: '/MsgMonitor/EngineSend/' + msg
  124. });
  125. //var str = '<div class="message"><span class="date">[ {0} ] </span><span class="content">引擎:{1}</span></div>'
  126. // .format(new Date().format('yyyy-MM-dd hh:mm:ss'), msg);
  127. //$('#s-box .box-body').prepend(str);
  128. }
  129. abp.signalr.connect(['@(IwbConsts.ClientName)']);
  130. iwbHub.client.getMqttMsg = function (data) {
  131. console.log('getMqttMsg: ', data);
  132. if (data) {
  133. var $str = $(
  134. '<div class="message"><span class="date">[ {0} ] </span><span class="topic">【 {1} 】</span><span class="content">{2}</span></div>'
  135. .format(new Date().format('yyyy-MM-dd hh:mm:ss'), data.topic, data.msg));
  136. $('#r-box .box-body').prepend($str);
  137. Scroll($str);
  138. }
  139. };
  140. iwbHub.client.getSendMqttMsg = function (data) {
  141. console.log('getSendMqttMsg: ', data);
  142. if (data) {
  143. var $str = $('<div class="message"><span class="date">[ {0} ] </span><span class="topic">【 {1} 】</span><span class="content">{2}</span></div>'.format(new Date().format('yyyy-MM-dd hh:mm:ss'), data.topic, data.msg));
  144. $('#s-box .box-body').prepend($str);
  145. Scroll($str);
  146. }
  147. };
  148. </script>
  149. }