From 0e026a8b3b738d7bf5d954adbe0b28eab0bd13ee Mon Sep 17 00:00:00 2001 From: fumiama Date: Mon, 22 Nov 2021 19:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20=E4=BF=AE=E5=A4=8D=20we?= =?UTF-8?q?bgui=20=E7=9B=91=E5=90=AC=E7=AB=AF=E5=8F=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- control/web/gui.go | 10 +++++----- main.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 44e341b0..8b0e0f72 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ ## 命令行参数 ```bash -zerobot -h -t token -u url [-d|w] [-g] qq1 qq2 qq3 ... +zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ... ``` - **-h**: 显示帮助 - **-t token**: 设置`AccessToken`,默认为空 - **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700` - **-d|w**: 开启 debug | warning 级别及以上日志输出 -- **-g**: 开启 [webgui](https://github.com/FloatTech/bot-manager) +- **-g 监听地址:端口**: 在 http://监听地址:端口 上开启 [webgui](https://github.com/FloatTech/bot-manager) - **qqs**: superusers 的 qq 号 ## 功能 diff --git a/control/web/gui.go b/control/web/gui.go index 6be18ea1..b09de441 100644 --- a/control/web/gui.go +++ b/control/web/gui.go @@ -58,12 +58,12 @@ type request struct { } // InitGui 初始化gui -func InitGui() { +func InitGui(addr string) { // 将日志重定向到前端hook writer := io.MultiWriter(l, os.Stderr) log.SetOutput(writer) // 监听后端 - go controller() + go controller(addr) // 注册消息handle messageHandle() } @@ -75,7 +75,7 @@ var upGrader = websocket.Upgrader{ }, } -func controller() { +func controller(addr string) { defer func() { err := recover() if err != nil { @@ -129,9 +129,9 @@ func controller() { // 发送信息 engine.POST("/send_msg", sendMsg) engine.GET("/data", upgrade) - log.Infoln("[gui] the webui is running http://127.0.0.1:3000") + log.Infoln("[gui] the webui is running on", addr) log.Infoln("[gui] ", "you input the `ZeroBot-Plugin.exe -g` can disable the gui") - if err := engine.Run("127.0.0.1:3000"); err != nil { + if err := engine.Run(addr); err != nil { log.Debugln("[gui] ", err.Error()) } } diff --git a/main.go b/main.go index 51337018..de8cfcb0 100644 --- a/main.go +++ b/main.go @@ -75,8 +75,8 @@ func init() { d := flag.Bool("d", false, "Enable debug level log and higher.") w := flag.Bool("w", false, "Enable warning level log and higher.") h := flag.Bool("h", false, "Display this help.") - // 解析命令行参数,输入 `-g` 即可启用 gui - // g := flag.Bool("g", false, "Enable web gui.") + // 解析命令行参数,输入 `-g 监听地址:端口` 即可启用 gui + // g := flag.String("g", "127.0.0.1:3000", "Enable web gui.") // 直接写死 AccessToken 时,请更改下面第二个参数 token = flag.String("t", "", "Set AccessToken of WSClient.") @@ -99,7 +99,7 @@ func init() { } // 解析命令行参数,输入 `-g` 即可启用 gui // if *g { - // webctrl.InitGui() + // webctrl.InitGui(*g) // } }