ServerConf

This commit is contained in:
ZhuoQinghui 2025-02-17 14:22:01 +08:00
parent b41a60a932
commit 4b43bc3533
3 changed files with 12 additions and 20 deletions

View File

@ -3,7 +3,7 @@ package conf
// AppConfig
// 配置文件
type AppConfig struct {
// 服务配置
// 服务配置
Server *ServerConf `json:"server" yaml:"server"`
// 网页配置
Web *WebConf `json:"web" yaml:"web"`
@ -17,8 +17,8 @@ type AppConfig struct {
// ServerConf 服务端配置
type ServerConf struct {
// 是否启用
Enable bool `json:"enable" yaml:"enable"`
// 是否启用WEB控制台支持
Web bool `json:"enable" yaml:"enable"`
// 监听地址
Host string `json:"host" yaml:"host"`
// 监听端口
@ -29,12 +29,7 @@ type ServerConf struct {
// WebConf 网页服务配置
type WebConf struct {
// 是否启用
Enable bool `json:"enable" yaml:"enable"`
// 监听地址
Host string `json:"host" yaml:"host"`
// 监听端口
Port int `json:"port" yaml:"port"`
Info string `json:"info" yaml:"info"`
}
// TaskConf 定时任务配置

View File

@ -14,15 +14,14 @@ func EditServer(host string, port int, key string) *AppConfig {
return appConf
}
func EditWeb(host string, port int) *AppConfig {
appConf.Web.Host = host
appConf.Web.Port = port
func EditWeb(info string) *AppConfig {
appConf.Web.Info = info
WriteConfig()
return appConf
}
func ExecWeb(run bool) *AppConfig {
appConf.Web.Enable = run
appConf.Server.Web = run
WriteConfig()
return appConf
}

View File

@ -56,15 +56,13 @@ func defaultAppConfig() *AppConfig {
return &AppConfig{
Server: &ServerConf{
Enable: false,
Web: false,
Host: "0.0.0.0",
Port: 36851,
Key: serverKey,
},
Web: &WebConf{
Enable: false,
Host: "0.0.0.0",
Port: 36852,
Info: "网页管理端",
},
Task: &TaskConf{
Delay: 0,