mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
feat: multi user template
This commit is contained in:
@@ -27,6 +27,7 @@ type Config struct {
|
||||
|
||||
Language string `mapstructure:"language" json:"language"` // 系统语言,默认 zh_CN
|
||||
SiteName string `mapstructure:"site_name" json:"site_name"`
|
||||
UserTemplate string `mapstructure:"user_template" json:"user_template,omitempty"`
|
||||
JWTSecretKey string `mapstructure:"jwt_secret_key" json:"jwt_secret_key,omitempty"`
|
||||
AgentSecretKey string `mapstructure:"agent_secret_key" json:"agent_secret_key,omitempty"`
|
||||
ListenPort uint `mapstructure:"listen_port" json:"listen_port,omitempty"`
|
||||
@@ -55,7 +56,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
// Read 读取配置文件并应用
|
||||
func (c *Config) Read(path string) error {
|
||||
func (c *Config) Read(path string, userTemplates []UserTemplate) error {
|
||||
c.k = koanf.New(".")
|
||||
c.filePath = path
|
||||
|
||||
@@ -87,6 +88,16 @@ func (c *Config) Read(path string) error {
|
||||
if c.Location == "" {
|
||||
c.Location = "Asia/Shanghai"
|
||||
}
|
||||
var userTemplateValid bool
|
||||
for _, v := range userTemplates {
|
||||
if v.Path == c.UserTemplate {
|
||||
userTemplateValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if c.UserTemplate == "" || !userTemplateValid {
|
||||
c.UserTemplate = "user-dist"
|
||||
}
|
||||
if c.AvgPingCount == 0 {
|
||||
c.AvgPingCount = 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user