✏️ 修复 webgui 无法启动

This commit is contained in:
fumiama 2021-11-09 13:01:01 +08:00
parent 34bc8e3a3c
commit e2032cdc74
3 changed files with 12 additions and 15 deletions

View File

@ -1,4 +1,4 @@
package web package webctrl
import ( import (
"encoding/json" "encoding/json"
@ -36,8 +36,8 @@ var (
type logWriter struct { type logWriter struct {
} }
// initGui 初始化gui // InitGui 初始化gui
func initGui() { func InitGui() {
// 将日志重定向到前端hook // 将日志重定向到前端hook
writer := io.MultiWriter(l, os.Stderr) writer := io.MultiWriter(l, os.Stderr)
log.SetOutput(writer) log.SetOutput(writer)

View File

@ -1,11 +0,0 @@
// Package web 网页管理后端
package web
import "flag"
func init() {
// 解析命令行参数,输入 `-g` 即可启用 gui
if *flag.Bool("g", false, "Enable web gui.") {
initGui()
}
}

10
main.go
View File

@ -10,7 +10,7 @@ import (
// 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用 // 下列插件可与 wdvxdr1123/ZeroBot v1.1.2 以上配合单独使用
// 插件控制 // 插件控制
// _ "github.com/FloatTech/ZeroBot-Plugin/control/web" // web 后端控制 // webctrl "github.com/FloatTech/ZeroBot-Plugin/control/web" // web 后端控制
// 词库类 // 词库类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
@ -74,10 +74,14 @@ func init() {
d := flag.Bool("d", false, "Enable debug level log and higher.") d := flag.Bool("d", false, "Enable debug level log and higher.")
w := flag.Bool("w", false, "Enable warning level log and higher.") w := flag.Bool("w", false, "Enable warning level log and higher.")
h := flag.Bool("h", false, "Display this help.") h := flag.Bool("h", false, "Display this help.")
// 解析命令行参数,输入 `-g` 即可启用 gui
// g := flag.Bool("g", false, "Enable web gui.")
// 直接写死 AccessToken 时,请更改下面第二个参数 // 直接写死 AccessToken 时,请更改下面第二个参数
token = flag.String("t", "", "Set AccessToken of WSClient.") token = flag.String("t", "", "Set AccessToken of WSClient.")
// 直接写死 URL 时,请更改下面第二个参数 // 直接写死 URL 时,请更改下面第二个参数
url = flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.") url = flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
flag.Parse() flag.Parse()
if *h { if *h {
printBanner() printBanner()
@ -92,6 +96,10 @@ func init() {
logrus.SetLevel(logrus.WarnLevel) logrus.SetLevel(logrus.WarnLevel)
} }
} }
// 解析命令行参数,输入 `-g` 即可启用 gui
// if *g {
// webctrl.InitGui()
// }
} }
func printBanner() { func printBanner() {