config

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config 处理应用程序配置管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.1.0

type Config struct {
	// 基础配置
	Name        string `json:"name"`
	Description string `json:"description"`
	Keywords    string `json:"keywords"`
	Port        int    `json:"port"`
	Host        string `json:"host"` // 新增:绑定IP地址
	DataPath    string `json:"data_path"`
	Production  bool   `json:"production"`

	// 通知配置
	NotifyTitle   string `json:"notify_title"`
	NotifyContent string `json:"notify_content"`
	PageExplain   string `json:"page_explain"`

	// 上传配置
	OpenUpload     int   `json:"open_upload"`
	UploadSize     int64 `json:"upload_size"`
	EnableChunk    int   `json:"enable_chunk"`
	ChunkSize      int64 `json:"chunk_size"` // 新增:分片大小
	MaxSaveSeconds int   `json:"max_save_seconds"`

	// 下载配置 (新增)
	EnableConcurrentDownload int `json:"enable_concurrent_download"` // 是否启用并发下载
	MaxConcurrentDownloads   int `json:"max_concurrent_downloads"`   // 最大并发下载数
	DownloadTimeout          int `json:"download_timeout"`           // 下载超时时间(秒)

	// 过期样式
	ExpireStyle []string `json:"expire_style"`

	// 限流配置
	UploadMinute int `json:"upload_minute"`
	UploadCount  int `json:"upload_count"`
	ErrorMinute  int `json:"error_minute"`
	ErrorCount   int `json:"error_count"`

	// 主题配置
	ThemesSelect  string  `json:"themes_select"`
	ThemesChoices []Theme `json:"themes_choices"`
	Opacity       float64 `json:"opacity"`
	Background    string  `json:"background"`

	// 存储配置
	FileStorage string `json:"file_storage"`
	StoragePath string `json:"storage_path"`

	// S3配置
	S3AccessKeyID      string `json:"s3_access_key_id"`
	S3SecretAccessKey  string `json:"s3_secret_access_key"`
	S3BucketName       string `json:"s3_bucket_name"`
	S3EndpointURL      string `json:"s3_endpoint_url"`
	S3RegionName       string `json:"s3_region_name"`
	S3SignatureVersion string `json:"s3_signature_version"`
	S3Hostname         string `json:"s3_hostname"`
	S3Proxy            int    `json:"s3_proxy"`
	AWSSessionToken    string `json:"aws_session_token"`

	// WebDAV配置
	WebDAVHostname string `json:"webdav_hostname"`
	WebDAVRootPath string `json:"webdav_root_path"`
	WebDAVProxy    int    `json:"webdav_proxy"`
	WebDAVURL      string `json:"webdav_url"`
	WebDAVPassword string `json:"webdav_password"`
	WebDAVUsername string `json:"webdav_username"`

	// OneDrive配置
	OneDriveDomain   string `json:"onedrive_domain"`
	OneDriveClientID string `json:"onedrive_client_id"`
	OneDriveUsername string `json:"onedrive_username"`
	OneDrivePassword string `json:"onedrive_password"`
	OneDriveRootPath string `json:"onedrive_root_path"`
	OneDriveProxy    int    `json:"onedrive_proxy"`

	// 管理配置
	AdminToken    string `json:"admin_token"`
	ShowAdminAddr int    `json:"show_admin_address"`
	RobotsText    string `json:"robots_text"`

	// 用户系统配置 (新增)
	EnableUserSystem      int   `json:"enable_user_system"`      // 是否启用用户系统 0-禁用 1-启用
	AllowUserRegistration int   `json:"allow_user_registration"` // 是否允许用户注册 0-禁用 1-启用
	RequireEmailVerify    int   `json:"require_email_verify"`    // 是否需要邮箱验证 0-不需要 1-需要
	UserUploadSize        int64 `json:"user_upload_size"`        // 用户上传文件大小限制(字节)
	UserStorageQuota      int64 `json:"user_storage_quota"`      // 用户存储配额(字节) 0-无限制
	SessionExpiryHours    int   `json:"session_expiry_hours"`    // 用户会话过期时间(小时)
	MaxSessionsPerUser    int   `json:"max_sessions_per_user"`   // 每个用户最大会话数

	// JWT 密钥配置
	JWTSecret string `json:"jwt_secret"` // JWT签名密钥
	// contains filtered or unexported fields
}

func Init added in v1.1.0

func Init() *Config

func (*Config) InitDefaultDataInDB added in v1.1.0

func (c *Config) InitDefaultDataInDB() error

InitDefaultDataInDB 在数据库中初始化默认配置数据

func (*Config) InitWithDB added in v1.1.0

func (c *Config) InitWithDB(db *gorm.DB) error

InitWithDB 使用数据库初始化配置

func (*Config) LoadFromDatabase added in v1.1.0

func (c *Config) LoadFromDatabase() error

func (*Config) Save added in v1.1.0

func (c *Config) Save() error

func (*Config) SetDB added in v1.1.0

func (c *Config) SetDB(db *gorm.DB)

SetDB 设置数据库连接

type Theme

type Theme struct {
	Name    string `json:"name"`
	Key     string `json:"key"`
	Author  string `json:"author"`
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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