Files
lunar-mini/server/internal/config/config.go
T
gouki 2a68eae999
Build and Publish Server / build (push) Successful in 2m8s
Publish Mini Program Dev Version / publish (push) Failing after 11m17s
feat(home): 修复swiper动画、宜忌布局、月历显示、节日速查
1. 修复swiper箭头点击动画丢失问题
   - 改用固定7天窗口,滑动到边缘时整体滚动数据
   - 保持dayIndex连续,确保swiper平滑动画

2. 修复宜忌两行显示压在一起
   - 设置item固定高度32rpx和行距12rpx
   - 超出2行显示...省略号

3. 修复月历数字竖向排列问题
   - 修正wxml嵌套结构,让42个格子正确排成6行7列
   - 压缩格子高度,放大数字字体

4. 节日速查功能优化
   - 默认显示3条,右侧添加更多
2026-08-10 23:07:47 +00:00

120 lines
2.5 KiB
Go

package config
import (
"os"
"strconv"
)
type Config struct {
Server ServerConfig
Database DatabaseConfig
Redis RedisConfig
JWT JWTConfig
Wechat WechatConfig
Admin AdminConfig
Wiki WikiConfig
}
type ServerConfig struct {
Port string
Env string
CORSOrigins string
}
type DatabaseConfig struct {
Type string
Host string
Port string
User string
Password string
Name string
}
type RedisConfig struct {
Host string
Port string
Password string
DB int
}
type JWTConfig struct {
Secret string
}
type WechatConfig struct {
AppID string
AppSecret string
PayKey string
MchID string
}
// AdminConfig 管理后台配置
type AdminConfig struct {
// Password 管理员登录密码;为空时禁用后台登录
Password string
}
// WikiConfig 百科/历史上的今天(维基百科同步)配置
type WikiConfig struct {
// SyncIntervalDays 同步间隔(天),距上次成功同步超过该间隔才会自动执行
SyncIntervalDays int
// SyncHour 自动同步执行的小时点(0-23)
SyncHour int
}
func Load() *Config {
return &Config{
Server: ServerConfig{
Port: getEnv("SERVER_PORT", "8080"),
Env: getEnv("SERVER_ENV", "development"),
CORSOrigins: getEnv("CORS_ORIGINS", ""),
},
Database: DatabaseConfig{
Type: getEnv("DB_TYPE", "mysql"),
Host: getEnv("DB_HOST", "localhost"),
Port: getEnv("DB_PORT", "3306"),
User: getEnv("DB_USER", "root"),
Password: getEnv("DB_PASSWORD", ""),
Name: getEnv("DB_NAME", "lunar"),
},
Redis: RedisConfig{
Host: getEnv("REDIS_HOST", "localhost"),
Port: getEnv("REDIS_PORT", "6379"),
Password: getEnv("REDIS_PASSWORD", ""),
DB: 0,
},
JWT: JWTConfig{
Secret: getEnv("JWT_SECRET", "your-secret-key"),
},
Wechat: WechatConfig{
AppID: getEnv("MINI_APP_ID", ""),
AppSecret: getEnv("MINI_APP_SECRET", ""),
PayKey: getEnv("WECHAT_PAY_APIKEY", ""),
MchID: getEnv("WECHAT_PAY_MCHID", ""),
},
Admin: AdminConfig{
Password: getEnv("ADMIN_PASSWORD", ""),
},
Wiki: WikiConfig{
SyncIntervalDays: getEnvInt("WIKI_SYNC_INTERVAL_DAYS", 7),
SyncHour: getEnvInt("WIKI_SYNC_HOUR", 4),
},
}
}
func getEnvInt(key string, defaultValue int) int {
if value := os.Getenv(key); value != "" {
if n, err := strconv.Atoi(value); err == nil {
return n
}
}
return defaultValue
}
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}