1. 增加了WebSocket请求与异常调试控制台

This commit is contained in:
cuibaocheng 2021-09-16 14:22:03 +08:00
parent 47835575bf
commit 35cf18019d
5 changed files with 29 additions and 9 deletions

View File

@ -158,6 +158,8 @@ public class CardTemplateUseAppController extends DefaultBaseController {
try { try {
String userId = securityComponent.getAppTokenUser(token).getId(); String userId = securityComponent.getAppTokenUser(token).getId();
params.put("userId", userId); params.put("userId", userId);
if(1 == 1)
throw new SearchException("测试");
}catch(Exception e) { }catch(Exception e) {
throw new SearchException("没有登陆信息"); throw new SearchException("没有登陆信息");
} }
@ -181,6 +183,8 @@ public class CardTemplateUseAppController extends DefaultBaseController {
try { try {
String userId = securityComponent.getAppTokenUser(token).getId(); String userId = securityComponent.getAppTokenUser(token).getId();
params.put("userId", userId); params.put("userId", userId);
if(1 == 1)
throw new SearchException("测试");
}catch(Exception e) { }catch(Exception e) {
throw new SearchException("没有登陆信息"); throw new SearchException("没有登陆信息");
} }

View File

@ -1,5 +1,6 @@
package cn.com.tenlion.systemcard.controller.route.cardconsole; package cn.com.tenlion.systemcard.controller.route.cardconsole;
import cn.com.tenlion.projectconfig.util.ProjectConfigUtil;
import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.properties.ServerProperties; import ink.wgink.properties.ServerProperties;
@ -28,9 +29,7 @@ public class CardConsoleController extends DefaultBaseController {
@GetMapping("console") @GetMapping("console")
public ModelAndView save() { public ModelAndView save() {
ModelAndView mv = new ModelAndView("cardconsole/console"); ModelAndView mv = new ModelAndView("cardconsole/console");
String serverUrl = systemProperties.getUrl(); mv.addObject("webSocketConsole", ProjectConfigUtil.getText("webSocketConsole"));
String wsUrl = serverUrl.replaceAll("https:", "ws:/").replaceAll("http:", "ws:/");
mv.addObject("serverUrl", wsUrl);
return mv; return mv;
} }

View File

@ -8,8 +8,9 @@ import ink.wgink.util.ReflectUtil;
import ink.wgink.util.date.DateUtil; import ink.wgink.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.annotation.WebFilter; import javax.servlet.annotation.WebFilter;

View File

@ -24,6 +24,8 @@ public class CardLogSocket {
public static String selectUser = ""; public static String selectUser = "";
public static Boolean exceptionDescription = false;
@OnOpen @OnOpen
public void onOpen(Session session) { public void onOpen(Session session) {
System.out.println("链接成功......"); System.out.println("链接成功......");
@ -60,18 +62,24 @@ public class CardLogSocket {
if(message.contains("selectUser")) { if(message.contains("selectUser")) {
selectUser = message.split("=")[1]; selectUser = message.split("=")[1];
} }
if(message.contains("exceptionDescription")) {
exceptionDescription = Boolean.parseBoolean(message.split("=")[1]);
}
} }
/** /**
* 群发消息 * 群发消息
* @param message 消息内容 * @param message 消息内容
*/ */
public synchronized void sendAll(String message) throws IOException { public synchronized void sendAll(String message) {
for (Map.Entry<String, Session> sessionEntry : SESSIONS.entrySet()) { for (Map.Entry<String, Session> sessionEntry : SESSIONS.entrySet()) {
synchronized(sessionEntry) { synchronized(sessionEntry) {
Session session = sessionEntry.getValue(); Session session = sessionEntry.getValue();
if(session.isOpen()) { if(session.isOpen()) {
try {
session.getBasicRemote().sendText(message); session.getBasicRemote().sendText(message);
} catch (IOException e) {
}
} }
} }
} }

View File

@ -11,7 +11,7 @@
<script src="assets/js/vendor/template/jquery.min.js"></script> <script src="assets/js/vendor/template/jquery.min.js"></script>
<script src="assets/js/vendor/template/jstorage.min.js"></script> <script src="assets/js/vendor/template/jstorage.min.js"></script>
<script> <script>
var codetype="php"; var codetype="java";
var unid="59396e99ae344"; var unid="59396e99ae344";
</script> </script>
<script src="assets/js/vendor/template/runcode.js"></script> <script src="assets/js/vendor/template/runcode.js"></script>
@ -53,6 +53,8 @@
<a class="btn btn-big btn-primary" id="query">内容查询</a> <a class="btn btn-big btn-primary" id="query">内容查询</a>
<a class="btn btn-big btn-success" id="replaceAll">内容替换</a> <a class="btn btn-big btn-success" id="replaceAll">内容替换</a>
<a class="btn btn-big btn-danger" id="jumpNumber">指定行跳转</a> <a class="btn btn-big btn-danger" id="jumpNumber">指定行跳转</a>
<label class="layui-form-label">打印异常详情</label>
<input type="checkbox" style="height:15px;width:15px;" id="exceptionDescription">
<a class="btn btn-big btn-warm">选中文字内容 CTRL + K【下一个】 | ALT + SHIF + K【上一个】</a> <a class="btn btn-big btn-warm">选中文字内容 CTRL + K【下一个】 | ALT + SHIF + K【上一个】</a>
</td> </td>
</tr> </tr>
@ -101,6 +103,12 @@
consoleLog = "控制台连接成功...\r\n\r\n"; consoleLog = "控制台连接成功...\r\n\r\n";
setCodeTxt(consoleLog); setCodeTxt(consoleLog);
}); });
$(document).on('click','#exceptionDescription',function(){
var exceptionDescription = $(this).is(':checked');
socket.send("exceptionDescription=" + exceptionDescription);
});
var stopStatus = false; var stopStatus = false;
$(document).on('click','#stop',function(){ $(document).on('click','#stop',function(){
if(stopStatus) { if(stopStatus) {
@ -118,7 +126,7 @@
}else{ }else{
console.log("您的浏览器支持WebSocket"); console.log("您的浏览器支持WebSocket");
//实现化WebSocket对象指定要连接的服务器地址与端口 建立连接 //实现化WebSocket对象指定要连接的服务器地址与端口 建立连接
socket = new WebSocket("[[${serverUrl}]]/cardlogsocket"); socket = new WebSocket("[[${webSocketConsole}]]");
//打开事件 //打开事件
socket.onopen = function() { socket.onopen = function() {
console.log("Socket 已打开"); console.log("Socket 已打开");
@ -339,7 +347,7 @@
enableLiveAutocompletion: true enableLiveAutocompletion: true
}); });
editor.setTheme("ace/theme/monokai"); editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/php"); editor.getSession().setMode("ace/mode/java");
editor.setOptions ({ editor.setOptions ({
enableBasicAutocompletion: true,// enableBasicAutocompletion: true,//