From 47835575bfca79a78174e13654fc95c81fd63295 Mon Sep 17 00:00:00 2001 From: cuibaocheng Date: Wed, 15 Sep 2021 18:32:26 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=B5=B7?= =?UTF-8?q?=E6=8A=A5=E7=9A=84=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9=202.=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=B7=E6=8A=A5=E4=B8=8E=E5=90=8D=E7=89=87?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E9=80=9F=E5=BA=A6=203.=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=90=8E=E5=8F=B0=E6=A8=A1=E6=9D=BF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6=204.=20=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=A1=A8=E5=8D=95=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=205.=20=E6=A0=8F=E7=9B=AE=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=92=E8=89=B2=E6=8E=A7=E5=88=B6=206.=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=B0=83=E8=AF=95=207.=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9C=8D=E5=8A=A1=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../route/cardconsole/CardConsoleController.java | 11 ++++++++++- src/main/resources/templates/cardconsole/console.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/com/tenlion/systemcard/controller/route/cardconsole/CardConsoleController.java b/src/main/java/cn/com/tenlion/systemcard/controller/route/cardconsole/CardConsoleController.java index f66ef58..3c7867c 100644 --- a/src/main/java/cn/com/tenlion/systemcard/controller/route/cardconsole/CardConsoleController.java +++ b/src/main/java/cn/com/tenlion/systemcard/controller/route/cardconsole/CardConsoleController.java @@ -2,7 +2,9 @@ package cn.com.tenlion.systemcard.controller.route.cardconsole; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.properties.ServerProperties; import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -20,9 +22,16 @@ import org.springframework.web.servlet.ModelAndView; @RequestMapping(ISystemConstant.ROUTE_PREFIX + "/cardconsole") public class CardConsoleController extends DefaultBaseController { + @Autowired + private ServerProperties systemProperties; + @GetMapping("console") public ModelAndView save() { - return new ModelAndView("cardconsole/console"); + ModelAndView mv = new ModelAndView("cardconsole/console"); + String serverUrl = systemProperties.getUrl(); + String wsUrl = serverUrl.replaceAll("https:", "ws:/").replaceAll("http:", "ws:/"); + mv.addObject("serverUrl", wsUrl); + return mv; } } \ No newline at end of file diff --git a/src/main/resources/templates/cardconsole/console.html b/src/main/resources/templates/cardconsole/console.html index 9a7253a..01fd16c 100644 --- a/src/main/resources/templates/cardconsole/console.html +++ b/src/main/resources/templates/cardconsole/console.html @@ -118,7 +118,7 @@ }else{ console.log("您的浏览器支持WebSocket"); //实现化WebSocket对象,指定要连接的服务器地址与端口 建立连接 - socket = new WebSocket("ws:///192.168.0.115:8091/systemcard/cardlogsocket"); + socket = new WebSocket("[[${serverUrl}]]/cardlogsocket"); //打开事件 socket.onopen = function() { console.log("Socket 已打开");