diff --git a/main.go b/main.go
index a537f5c..5416b3a 100644
--- a/main.go
+++ b/main.go
@@ -108,7 +108,7 @@ func main() {
}
func onGameStart() error {
- log.Info("加入游戏.")
+ log.Info("加入游戏")
watch = make(chan bool)
go watchdog()
go listenMsg()
diff --git a/web/templates/index.html b/web/templates/index.html
index 6ec54ae..b646086 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -56,7 +56,7 @@
Msc自动钓鱼
const app = Vue.createApp(Main);
app.use(ElementPlus);
v = app.mount('#app')
- var ws = new WebSocket("ws://localhost:8080/ws")
+ var ws = new WebSocket("ws://"+location.host+"/ws")
ws.onopen = function () {
var d = new Date();
v.logsData = [{
diff --git a/web/web.go b/web/web.go
index df0216d..ed1607e 100644
--- a/web/web.go
+++ b/web/web.go
@@ -1,6 +1,7 @@
package web
import (
+ _ "embed"
"sync"
"time"
@@ -26,15 +27,19 @@ var upgrader = ws.Upgrader{
var data updateData
+//go:embed templates\index.html
+var index []byte
+
func init() {
data.logs = make(chan log, 1024)
}
func WebRun(sendMsg func(string) error, log *logrus.Logger) {
r := gin.Default()
- r.LoadHTMLGlob("web/templates/*")
r.GET("/", func(c *gin.Context) {
- c.HTML(200, "index.html", nil)
+ if _, err := c.Writer.Write(index); err != nil {
+ log.Warn(err)
+ }
})
r.GET("/ws", func(c *gin.Context) {
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)