This commit is contained in:
2026-09-03 17:55:42 +08:00
parent 7c38e84e30
commit c80a3d4a2d
35 changed files with 6795 additions and 597 deletions
+17 -6
View File
@@ -14,12 +14,13 @@ type Config struct {
UploadDir string
// MySQL
DBHost string
DBPort string
DBUser string
DBPassword string
DBName string
DBCharset string
DBHost string
DBPort string
DBUser string
DBPassword string
DBName string
DBCharset string
DBAutoMigrate bool
// 平台管理员账号(首次启动自动创建)
AdminUsername string
@@ -48,6 +49,7 @@ func Load() *Config {
DBPassword: getEnv("DB_PASSWORD", "Dfn47yeKpyJfwz8n"),
DBName: getEnv("DB_NAME", "photowall"),
DBCharset: getEnv("DB_CHARSET", "utf8mb4"),
DBAutoMigrate: getEnvBool("DB_AUTO_MIGRATE", false),
AdminUsername: getEnv("ADMIN_USERNAME", "hero920103"),
AdminPassword: getEnv("ADMIN_PASSWORD", "920103"),
// Redis
@@ -80,3 +82,12 @@ func getEnvInt(key string, def int) int {
}
return def
}
func getEnvBool(key string, def bool) bool {
if v := os.Getenv(key); v != "" {
if b, err := strconv.ParseBool(v); err == nil {
return b
}
}
return def
}