config

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServerPort string
	// Mode 运行模式 dev/prod
	Mode      = constants.ModeProd
	JwtSecret string
	LogLevel  = "info"

	AdminUsername = "admin"
	AdminPassword = "admin"

	// BaseUrl 基础路径
	BaseUrl = "http://localhost:3000"
	OidcUri = "/api/v1/user/oidc/login"
	// EmailEnable Email 相关配置项 Email Configuration
	EmailEnable      bool   // 是否启用邮箱发送 Enable Email Sending
	EmailUsername    string // 邮箱用户名 Email Username
	EmailAddress     string // 邮箱地址 Email Address
	EmailHost        string // 邮箱服务器地址 Email Server Address
	EmailPort        string // 邮箱服务器端口 Email Server Port
	EmailPassword    string // 邮箱密码 Email Password
	EmailSSL         bool   // 是否启用SSL Enable SSL
	EmailTestAddress string // 测试邮箱地址,用于测试邮件发送功能 Test Email Address
	// DomainVerifyPolice 域名相关配置
	DomainVerifyPolice = constants.DomainVerifyPolicyLoose // 域名验证策略,默认为宽松验证 Loose Domain Verification Policy
	// PageLimit 每页显示的文章数量,默认为40
	PageLimit = 40
	// CaptchaType 验证码类型,支持turnstile、recaptcha和hcaptcha
	CaptchaType      = constants.CaptchaTypeDisable
	CaptchaSiteKey   string // reCAPTCHA v3的站点密钥
	CaptchaSecretKey string // reCAPTCHA v3的密钥
	CaptchaUrl       string // for mcaptcha

	TokenExpireTime        = 60 * 5
	RefreshTokenExpireTime = 3600 * 24

	BuildTime  = "0000-00-00 00:00:00" // 构建时间 Build Time
	Version    = "0.0.0"               // 版本号 Version
	CommitHash = "unknown"             // 提交哈希 Commit Hash

	AllowRegisterByOidc = true // 是否允许通过OIDC注册 Allow Register by OIDC
	AllowRegister       = true // 是否允许注册 Allow Register

	Icon = "/apage.svg"
	Name = "liteyuki spage"

	ReleaseSavePath  = "./data/releases"
	UploadsPath      = "./data/uploads"
	Title            = "spage"           // 网站标题 Website Title
	FileMaxSize      = 100 * 1024 * 1024 // 文件最大大小,单位字节 File Max Size
	FileDriverConfig = &filedriver.DriverConfig{
		Type:     constants.FileDriverLocal,
		BasePath: UploadsPath,
	}
)

Functions

func Get

func Get[T any](key string, defaultValue T) T

Get 返回配置项的值,如果不存在则返回默认值

func GetBool

func GetBool(key string, defaultValue ...bool) bool

GetBool 返回配置项的布尔值

func GetFloat64

func GetFloat64(key string, defaultValue ...float64) float64

GetFloat64 返回配置项的浮点数值

func GetInt

func GetInt(key string, defaultValue ...int) int

GetInt 返回配置项的整数值

func GetString

func GetString(key string, defaultValue ...string) string

GetString 返回配置项的字符串值

func GetStringSlice

func GetStringSlice(key string, defaultValue ...[]string) []string

GetStringSlice 返回配置项的字符串切片值

func Init

func Init() error

Init 初始化配置文件和常量

func InitConfig

func InitConfig() error

InitConfig 初始化配置文件

Types

type CmdUtilsType

type CmdUtilsType struct{}

func (CmdUtilsType) GetArgsMap

func (CmdUtilsType) GetArgsMap(args []string) map[string]string

GetArgsMap 输入--mode=dev --port=8080时,解析为map[string]string{"mode":"dev", "port":"8080"} When inputting --mode=dev --port=8080, it is parsed as map[string]string{"mode":"dev", "port":"8080"}

func (CmdUtilsType) GetArgsSlice

func (CmdUtilsType) GetArgsSlice() []string

GetArgsSlice 输入--mode=dev --port=8080时,解析为["mode","port"] When inputting --mode=dev --port=8080, it is parsed as ["mode","port"]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL