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 已打开");