config

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config 基础配置模块

Package config 数据库配置模块

Package config 分层配置管理器

Package config 配置管理器

Package config MCP配置模块

Package config 存储配置模块

Package config 配置存储策略

Package config 上传下载配置模块

Package config 用户系统配置模块

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConfig

type BaseConfig struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Keywords    string `json:"keywords"`
	Port        int    `json:"port"`
	Host        string `json:"host"`
	DataPath    string `json:"data_path"`
	Production  bool   `json:"production"`
}

BaseConfig 基础配置

func NewBaseConfig

func NewBaseConfig() *BaseConfig

NewBaseConfig 创建基础配置

func (*BaseConfig) Clone

func (bc *BaseConfig) Clone() *BaseConfig

Clone 克隆配置

func (*BaseConfig) FromMap

func (bc *BaseConfig) FromMap(data map[string]string) error

FromMap 从map加载配置

func (*BaseConfig) GetAddress

func (bc *BaseConfig) GetAddress() string

GetAddress 获取完整的监听地址

func (*BaseConfig) IsLocalhost

func (bc *BaseConfig) IsLocalhost() bool

IsLocalhost 判断是否为本地地址

func (*BaseConfig) IsPublic

func (bc *BaseConfig) IsPublic() bool

IsPublic 判断是否为公网地址

func (*BaseConfig) ToMap

func (bc *BaseConfig) ToMap() map[string]string

ToMap 转换为map格式

func (*BaseConfig) Update

func (bc *BaseConfig) Update(updates map[string]interface{}) error

Update 更新配置

func (*BaseConfig) Validate

func (bc *BaseConfig) Validate() error

Validate 验证基础配置

type BusinessConfig

type BusinessConfig struct {
	ID          uint       `gorm:"primaryKey" json:"id"`
	ConfigKey   string     `gorm:"uniqueIndex;size:100" json:"config_key"`
	ConfigValue string     `gorm:"type:json" json:"config_value"`
	Module      string     `gorm:"size:50;index" json:"module"` // 模块名称
	SubModule   string     `gorm:"size:50;index" json:"sub_module,omitempty"`
	IsEnabled   bool       `gorm:"default:true" json:"is_enabled"`
	ValidFrom   time.Time  `json:"valid_from"`
	ValidTo     *time.Time `json:"valid_to,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

BusinessConfig 业务配置(通知、限流等)

type ConfigCategory

type ConfigCategory string

ConfigCategory 配置分类

const (
	CategoryStatic   ConfigCategory = "static"   // 静态配置(文件)
	CategoryRuntime  ConfigCategory = "runtime"  // 运行时配置(数据库)
	CategorySystem   ConfigCategory = "system"   // 系统配置(专用表)
	CategoryBusiness ConfigCategory = "business" // 业务配置(业务表)
)

type ConfigManager

type ConfigManager struct {
	Base     *BaseConfig       `json:"base"`
	Database *DatabaseConfig   `json:"database"`
	Transfer *TransferConfig   `json:"transfer"`
	Storage  *StorageConfig    `json:"storage"`
	User     *UserSystemConfig `json:"user"`
	MCP      *MCPConfig        `json:"mcp"`

	// 其他配置字段
	NotifyTitle   string   `json:"notify_title"`
	NotifyContent string   `json:"notify_content"`
	PageExplain   string   `json:"page_explain"`
	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"`

	// 管理配置
	AdminToken    string `json:"admin_token"`
	ShowAdminAddr int    `json:"show_admin_address"`
	RobotsText    string `json:"robots_text"`
	// contains filtered or unexported fields
}

ConfigManager 配置管理器

func InitManager

func InitManager() *ConfigManager

InitManager 初始化配置管理器

func NewConfigManager

func NewConfigManager() *ConfigManager

NewConfigManager 创建配置管理器

func (*ConfigManager) Clone

func (cm *ConfigManager) Clone() *ConfigManager

Clone 克隆整个配置管理器

func (*ConfigManager) GetAddress

func (cm *ConfigManager) GetAddress() string

GetAddress 获取服务器完整地址

func (*ConfigManager) GetDatabaseDSN

func (cm *ConfigManager) GetDatabaseDSN() (string, error)

GetDatabaseDSN 获取数据库连接字符串

func (*ConfigManager) InitDefaultDataInDB

func (cm *ConfigManager) InitDefaultDataInDB() error

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

func (*ConfigManager) InitWithDB

func (cm *ConfigManager) InitWithDB(db *gorm.DB) error

InitWithDB 使用数据库初始化配置管理器

func (*ConfigManager) IsMCPEnabled

func (cm *ConfigManager) IsMCPEnabled() bool

IsMCPEnabled 判断是否启用MCP服务器

func (*ConfigManager) IsUserSystemEnabled

func (cm *ConfigManager) IsUserSystemEnabled() bool

IsUserSystemEnabled 判断是否启用用户系统

func (*ConfigManager) LoadFromDatabase

func (cm *ConfigManager) LoadFromDatabase() error

LoadFromDatabase 从数据库加载配置

func (*ConfigManager) ReloadConfig

func (cm *ConfigManager) ReloadConfig() error

ReloadConfig 重新加载配置(热重载)

func (*ConfigManager) Save

func (cm *ConfigManager) Save() error

Save 保存配置

func (*ConfigManager) SetDB

func (cm *ConfigManager) SetDB(db *gorm.DB)

SetDB 设置数据库连接

func (*ConfigManager) Validate

func (cm *ConfigManager) Validate() error

Validate 验证所有配置

type ConfigMetadata

type ConfigMetadata struct {
	Key          string            `json:"key"`
	Category     ConfigCategory    `json:"category"`
	StorageType  ConfigStorageType `json:"storage_type"`
	TableName    string            `json:"table_name,omitempty"`
	FileName     string            `json:"file_name,omitempty"`
	Description  string            `json:"description"`
	Volatile     bool              `json:"volatile"`  // 是否易变
	Cacheable    bool              `json:"cacheable"` // 是否可缓存
	Version      int               `json:"version"`   // 配置版本
	LastModified time.Time         `json:"last_modified"`
}

ConfigMetadata 配置元数据

type ConfigStorageStrategy

type ConfigStorageStrategy struct {
	// contains filtered or unexported fields
}

ConfigStorageStrategy 配置存储策略

func NewConfigStorageStrategy

func NewConfigStorageStrategy(db *gorm.DB) *ConfigStorageStrategy

NewConfigStorageStrategy 创建配置存储策略

func (*ConfigStorageStrategy) GetConfig

func (s *ConfigStorageStrategy) GetConfig(key string, result interface{}) error

GetConfig 获取配置

func (*ConfigStorageStrategy) GetConfigMetadata

func (s *ConfigStorageStrategy) GetConfigMetadata(key string) (ConfigMetadata, error)

GetConfigMetadata 获取配置元数据

func (*ConfigStorageStrategy) InitTables

func (s *ConfigStorageStrategy) InitTables() error

InitTables 初始化配置相关表

func (*ConfigStorageStrategy) ListConfigsByCategory

func (s *ConfigStorageStrategy) ListConfigsByCategory(category ConfigCategory) ([]ConfigMetadata, error)

ListConfigsByCategory 按分类列出配置

func (*ConfigStorageStrategy) SetConfig

func (s *ConfigStorageStrategy) SetConfig(key string, value interface{}) error

SetConfig 设置配置

func (*ConfigStorageStrategy) ValidateConfig

func (s *ConfigStorageStrategy) ValidateConfig(key string, value interface{}) error

ValidateConfig 验证配置

type ConfigStorageType

type ConfigStorageType string

ConfigStorageType 配置存储类型

const (
	StorageTypeFile     ConfigStorageType = "file"     // 配置文件
	StorageTypeDatabase ConfigStorageType = "database" // 数据库表
	StorageTypeKeyValue ConfigStorageType = "keyvalue" // 键值对存储
	StorageTypeJSON     ConfigStorageType = "json"     // JSON配置
)

type DatabaseConfig

type DatabaseConfig struct {
	Type string `json:"database_type"` // sqlite, mysql, postgres
	Host string `json:"database_host"`
	Port int    `json:"database_port"`
	Name string `json:"database_name"`
	User string `json:"database_user"`
	Pass string `json:"database_pass"`
	SSL  string `json:"database_ssl"` // disable, require, verify-full (for postgres)
}

DatabaseConfig 数据库配置

func NewDatabaseConfig

func NewDatabaseConfig() *DatabaseConfig

NewDatabaseConfig 创建数据库配置

func (*DatabaseConfig) Clone

func (dc *DatabaseConfig) Clone() *DatabaseConfig

Clone 克隆配置

func (*DatabaseConfig) FromMap

func (dc *DatabaseConfig) FromMap(data map[string]string) error

FromMap 从map加载配置

func (*DatabaseConfig) GetDSN

func (dc *DatabaseConfig) GetDSN() (string, error)

GetDSN 获取数据库连接字符串

func (*DatabaseConfig) GetDefaultPort

func (dc *DatabaseConfig) GetDefaultPort() int

GetDefaultPort 获取默认端口

func (*DatabaseConfig) HasPassword

func (dc *DatabaseConfig) HasPassword() bool

HasPassword 检查是否设置了密码

func (*DatabaseConfig) IsMySQL

func (dc *DatabaseConfig) IsMySQL() bool

IsMySQL 判断是否为MySQL数据库

func (*DatabaseConfig) IsPostgreSQL

func (dc *DatabaseConfig) IsPostgreSQL() bool

IsPostgreSQL 判断是否为PostgreSQL数据库

func (*DatabaseConfig) IsSQLite

func (dc *DatabaseConfig) IsSQLite() bool

IsSQLite 判断是否为SQLite数据库

func (*DatabaseConfig) SetPassword

func (dc *DatabaseConfig) SetPassword(password string)

SetPassword 安全地设置密码

func (*DatabaseConfig) ToMap

func (dc *DatabaseConfig) ToMap() map[string]string

ToMap 转换为map格式

func (*DatabaseConfig) Update

func (dc *DatabaseConfig) Update(updates map[string]interface{}) error

Update 更新配置

func (*DatabaseConfig) Validate

func (dc *DatabaseConfig) Validate() error

Validate 验证数据库配置

type DownloadConfig

type DownloadConfig struct {
	EnableConcurrentDownload int `json:"enable_concurrent_download"` // 是否启用并发下载
	MaxConcurrentDownloads   int `json:"max_concurrent_downloads"`   // 最大并发下载数
	DownloadTimeout          int `json:"download_timeout"`           // 下载超时时间(秒)
}

DownloadConfig 下载配置

func NewDownloadConfig

func NewDownloadConfig() *DownloadConfig

NewDownloadConfig 创建下载配置

func (*DownloadConfig) Clone

func (dc *DownloadConfig) Clone() *DownloadConfig

Clone 克隆下载配置

func (*DownloadConfig) FromMap

func (dc *DownloadConfig) FromMap(data map[string]string) error

FromMap 从map加载下载配置

func (*DownloadConfig) GetDownloadTimeoutMinutes

func (dc *DownloadConfig) GetDownloadTimeoutMinutes() float64

GetDownloadTimeoutMinutes 获取下载超时时间(分钟)

func (*DownloadConfig) IsDownloadConcurrentEnabled

func (dc *DownloadConfig) IsDownloadConcurrentEnabled() bool

IsDownloadConcurrentEnabled 判断是否启用并发下载

func (*DownloadConfig) ToMap

func (dc *DownloadConfig) ToMap() map[string]string

ToMap 下载配置转换为map格式

func (*DownloadConfig) Update

func (dc *DownloadConfig) Update(updates map[string]interface{}) error

Update 更新下载配置

func (*DownloadConfig) Validate

func (dc *DownloadConfig) Validate() error

Validate 验证下载配置

type LayeredConfigManager

type LayeredConfigManager struct {

	// 配置模块
	Base     *BaseConfig       `json:"base"`
	Database *DatabaseConfig   `json:"database"`
	Transfer *TransferConfig   `json:"transfer"`
	Storage  *StorageConfig    `json:"storage"`
	User     *UserSystemConfig `json:"user"`
	MCP      *MCPConfig        `json:"mcp"`

	// 业务配置
	Notification *NotificationConfig `json:"notification"`
	RateLimit    *RateLimitConfig    `json:"rate_limit"`
	Theme        *ThemeConfig        `json:"theme"`
	// contains filtered or unexported fields
}

LayeredConfigManager 分层配置管理器

func NewLayeredConfigManager

func NewLayeredConfigManager(db *gorm.DB) *LayeredConfigManager

NewLayeredConfigManager 创建分层配置管理器

func (*LayeredConfigManager) ClearCache

func (m *LayeredConfigManager) ClearCache()

ClearCache 清除缓存

func (*LayeredConfigManager) GetCacheStats

func (m *LayeredConfigManager) GetCacheStats() map[string]interface{}

GetCacheStats 获取缓存统计

func (*LayeredConfigManager) GetConfigByCategory

func (m *LayeredConfigManager) GetConfigByCategory(category ConfigCategory) (map[string]interface{}, error)

GetConfigByCategory 按分类获取配置

func (*LayeredConfigManager) InitTables

func (m *LayeredConfigManager) InitTables() error

InitTables 初始化数据库表

func (*LayeredConfigManager) LoadAllConfigs

func (m *LayeredConfigManager) LoadAllConfigs() error

LoadAllConfigs 加载所有配置

func (*LayeredConfigManager) SaveAllConfigs

func (m *LayeredConfigManager) SaveAllConfigs() error

SaveAllConfigs 保存所有配置

func (*LayeredConfigManager) ValidateAllConfigs

func (m *LayeredConfigManager) ValidateAllConfigs() error

ValidateAllConfigs 验证所有配置

type MCPConfig

type MCPConfig struct {
	EnableMCPServer int    `json:"enable_mcp_server"` // 是否启用 MCP 服务器
	MCPPort         string `json:"mcp_port"`          // MCP 服务器端口
	MCPHost         string `json:"mcp_host"`          // MCP 服务器绑定地址
}

MCPConfig MCP服务器配置

func NewMCPConfig

func NewMCPConfig() *MCPConfig

NewMCPConfig 创建MCP配置

func (*MCPConfig) Clone

func (mc *MCPConfig) Clone() *MCPConfig

Clone 克隆配置

func (*MCPConfig) DisableMCP

func (mc *MCPConfig) DisableMCP()

DisableMCP 禁用MCP服务器

func (*MCPConfig) EnableMCP

func (mc *MCPConfig) EnableMCP()

EnableMCP 启用MCP服务器

func (*MCPConfig) FromMap

func (mc *MCPConfig) FromMap(data map[string]string) error

FromMap 从map加载配置

func (*MCPConfig) GetMCPAddress

func (mc *MCPConfig) GetMCPAddress() string

GetMCPAddress 获取MCP服务器地址

func (*MCPConfig) GetMCPPortInt

func (mc *MCPConfig) GetMCPPortInt() (int, error)

GetMCPPortInt 获取MCP端口号(整数)

func (*MCPConfig) IsMCPEnabled

func (mc *MCPConfig) IsMCPEnabled() bool

IsMCPEnabled 判断是否启用MCP服务器

func (*MCPConfig) SetHost

func (mc *MCPConfig) SetHost(host string) error

SetHost 设置主机地址

func (*MCPConfig) SetPort

func (mc *MCPConfig) SetPort(port string) error

SetPort 设置端口

func (*MCPConfig) ToMap

func (mc *MCPConfig) ToMap() map[string]string

ToMap 转换为map格式

func (*MCPConfig) Update

func (mc *MCPConfig) Update(updates map[string]interface{}) error

Update 更新配置

func (*MCPConfig) Validate

func (mc *MCPConfig) Validate() error

Validate 验证MCP配置

type NFSConfig

type NFSConfig struct {
	Server     string `json:"nfs_server"`      // NFS服务器地址
	Path       string `json:"nfs_path"`        // NFS路径
	MountPoint string `json:"nfs_mount_point"` // 本地挂载点
	Version    string `json:"nfs_version"`     // NFS版本
	Options    string `json:"nfs_options"`     // 挂载选项
	Timeout    int    `json:"nfs_timeout"`     // 超时时间(秒)
	AutoMount  int    `json:"nfs_auto_mount"`  // 是否自动挂载
	RetryCount int    `json:"nfs_retry_count"` // 重试次数
	SubPath    string `json:"nfs_sub_path"`    // 子路径
}

NFSConfig NFS存储配置

func NewNFSConfig

func NewNFSConfig() *NFSConfig

NewNFSConfig 创建NFS配置

func (*NFSConfig) Clone

func (nc *NFSConfig) Clone() *NFSConfig

Clone 克隆NFS配置

func (*NFSConfig) FromMap

func (nc *NFSConfig) FromMap(data map[string]string) error

FromMap 从map加载NFS配置

func (*NFSConfig) ToMap

func (nc *NFSConfig) ToMap() map[string]string

ToMap NFS配置转换为map格式

func (*NFSConfig) Validate

func (nc *NFSConfig) Validate() error

Validate 验证NFS配置

type NotificationConfig

type NotificationConfig struct {
	Title   string `json:"title"`
	Content string `json:"content"`
	Explain string `json:"explain"`
}

NotificationConfig 通知配置

type OneDriveConfig

type OneDriveConfig struct {
	Domain   string `json:"onedrive_domain"`
	ClientID string `json:"onedrive_client_id"`
	Username string `json:"onedrive_username"`
	Password string `json:"onedrive_password"`
	RootPath string `json:"onedrive_root_path"`
	Proxy    int    `json:"onedrive_proxy"`
}

OneDriveConfig OneDrive存储配置

func NewOneDriveConfig

func NewOneDriveConfig() *OneDriveConfig

NewOneDriveConfig 创建OneDrive配置

func (*OneDriveConfig) Clone

func (oc *OneDriveConfig) Clone() *OneDriveConfig

Clone 克隆OneDrive配置

func (*OneDriveConfig) FromMap

func (oc *OneDriveConfig) FromMap(data map[string]string) error

FromMap 从map加载OneDrive配置

func (*OneDriveConfig) ToMap

func (oc *OneDriveConfig) ToMap() map[string]string

ToMap OneDrive配置转换为map格式

func (*OneDriveConfig) Validate

func (oc *OneDriveConfig) Validate() error

Validate 验证OneDrive配置

type RateLimitConfig

type RateLimitConfig struct {
	UploadMinute int `json:"upload_minute"`
	UploadCount  int `json:"upload_count"`
	ErrorMinute  int `json:"error_minute"`
	ErrorCount   int `json:"error_count"`
}

RateLimitConfig 限流配置

type RuntimeConfig

type RuntimeConfig struct {
	ID          uint       `gorm:"primaryKey" json:"id"`
	ConfigKey   string     `gorm:"uniqueIndex;size:100" json:"config_key"`
	ConfigValue string     `gorm:"type:text" json:"config_value"`
	DataType    string     `gorm:"size:20" json:"data_type"` // string, int, bool, json
	Category    string     `gorm:"size:50;index" json:"category"`
	UserID      *uint      `gorm:"index" json:"user_id,omitempty"` // 用户专属配置
	IsGlobal    bool       `gorm:"default:true" json:"is_global"`
	Priority    int        `gorm:"default:0" json:"priority"` // 优先级
	ExpiresAt   *time.Time `json:"expires_at,omitempty"`      // 过期时间
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

RuntimeConfig 运行时配置(存储在数据库中)

type S3Config

type S3Config struct {
	AccessKeyID      string `json:"s3_access_key_id"`
	SecretAccessKey  string `json:"s3_secret_access_key"`
	BucketName       string `json:"s3_bucket_name"`
	EndpointURL      string `json:"s3_endpoint_url"`
	RegionName       string `json:"s3_region_name"`
	SignatureVersion string `json:"s3_signature_version"`
	Hostname         string `json:"s3_hostname"`
	Proxy            int    `json:"s3_proxy"`
	SessionToken     string `json:"aws_session_token"`
}

S3Config S3存储配置

func NewS3Config

func NewS3Config() *S3Config

NewS3Config 创建S3配置

func (*S3Config) Clone

func (s3c *S3Config) Clone() *S3Config

Clone 克隆S3配置

func (*S3Config) FromMap

func (s3c *S3Config) FromMap(data map[string]string) error

FromMap 从map加载S3配置

func (*S3Config) ToMap

func (s3c *S3Config) ToMap() map[string]string

ToMap S3配置转换为map格式

func (*S3Config) Validate

func (s3c *S3Config) Validate() error

Validate 验证S3配置

type StaticConfig

type StaticConfig struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	ConfigKey   string    `gorm:"uniqueIndex;size:100" json:"config_key"`
	ConfigValue string    `gorm:"type:text" json:"config_value"`
	Category    string    `gorm:"size:50;index" json:"category"`
	Description string    `gorm:"size:255" json:"description"`
	IsActive    bool      `gorm:"default:true" json:"is_active"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

StaticConfig 静态配置(存储在文件中)

type StorageConfig

type StorageConfig struct {
	Type        string          `json:"file_storage"` // local, s3, webdav, onedrive, nfs
	StoragePath string          `json:"storage_path"`
	S3          *S3Config       `json:"s3,omitempty"`
	WebDAV      *WebDAVConfig   `json:"webdav,omitempty"`
	OneDrive    *OneDriveConfig `json:"onedrive,omitempty"`
	NFS         *NFSConfig      `json:"nfs,omitempty"`
}

StorageConfig 存储配置

func NewStorageConfig

func NewStorageConfig() *StorageConfig

NewStorageConfig 创建存储配置

func (*StorageConfig) Clone

func (sc *StorageConfig) Clone() *StorageConfig

Clone 克隆存储配置

func (*StorageConfig) FromMap

func (sc *StorageConfig) FromMap(data map[string]string) error

FromMap 从map加载存储配置

func (*StorageConfig) IsLocal

func (sc *StorageConfig) IsLocal() bool

IsLocal 判断是否为本地存储

func (*StorageConfig) IsNFS

func (sc *StorageConfig) IsNFS() bool

IsNFS 判断是否为NFS存储

func (*StorageConfig) IsOneDrive

func (sc *StorageConfig) IsOneDrive() bool

IsOneDrive 判断是否为OneDrive存储

func (*StorageConfig) IsS3

func (sc *StorageConfig) IsS3() bool

IsS3 判断是否为S3存储

func (*StorageConfig) IsWebDAV

func (sc *StorageConfig) IsWebDAV() bool

IsWebDAV 判断是否为WebDAV存储

func (*StorageConfig) ToMap

func (sc *StorageConfig) ToMap() map[string]string

ToMap 存储配置转换为map格式

func (*StorageConfig) Validate

func (sc *StorageConfig) Validate() error

Validate 验证存储配置

type SystemConfig

type SystemConfig struct {
	ID           uint      `gorm:"primaryKey" json:"id"`
	ConfigKey    string    `gorm:"uniqueIndex;size:100" json:"config_key"`
	ConfigValue  string    `gorm:"type:json" json:"config_value"`
	ConfigSchema string    `gorm:"type:text" json:"config_schema"` // JSON Schema
	Version      int       `gorm:"default:1" json:"version"`
	Environment  string    `gorm:"size:20;default:'production'" json:"environment"`
	IsEncrypted  bool      `gorm:"default:false" json:"is_encrypted"`
	Checksum     string    `gorm:"size:64" json:"checksum"` // 配置校验和
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

SystemConfig 系统配置(存储配置、传输配置等)

type Theme

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

Theme 主题配置

type ThemeConfig

type ThemeConfig struct {
	Select     string  `json:"select"`
	Choices    []Theme `json:"choices"`
	Opacity    float64 `json:"opacity"`
	Background string  `json:"background"`
}

ThemeConfig 主题配置

type TransferConfig

type TransferConfig struct {
	Upload   *UploadConfig   `json:"upload"`
	Download *DownloadConfig `json:"download"`
}

TransferConfig 文件传输配置(包含上传和下载)

func NewTransferConfig

func NewTransferConfig() *TransferConfig

NewTransferConfig 创建传输配置

func (*TransferConfig) Clone

func (tc *TransferConfig) Clone() *TransferConfig

Clone 克隆传输配置

func (*TransferConfig) FromMap

func (tc *TransferConfig) FromMap(data map[string]string) error

FromMap 从map加载传输配置

func (*TransferConfig) ToMap

func (tc *TransferConfig) ToMap() map[string]string

ToMap 传输配置转换为map格式

func (*TransferConfig) Update

func (tc *TransferConfig) Update(updates map[string]interface{}) error

Update 更新传输配置

func (*TransferConfig) Validate

func (tc *TransferConfig) Validate() error

Validate 验证传输配置

type UploadConfig

type UploadConfig struct {
	OpenUpload     int   `json:"open_upload"`      // 是否开启上传 0-禁用 1-启用
	UploadSize     int64 `json:"upload_size"`      // 上传文件大小限制(字节)
	EnableChunk    int   `json:"enable_chunk"`     // 是否启用分片上传 0-禁用 1-启用
	ChunkSize      int64 `json:"chunk_size"`       // 分片大小(字节)
	MaxSaveSeconds int   `json:"max_save_seconds"` // 最大保存时间(秒)
}

UploadConfig 上传配置

func NewUploadConfig

func NewUploadConfig() *UploadConfig

NewUploadConfig 创建上传配置

func (*UploadConfig) Clone

func (uc *UploadConfig) Clone() *UploadConfig

Clone 克隆上传配置

func (*UploadConfig) FromMap

func (uc *UploadConfig) FromMap(data map[string]string) error

FromMap 从map加载上传配置

func (*UploadConfig) GetChunkSizeMB

func (uc *UploadConfig) GetChunkSizeMB() float64

GetChunkSizeMB 获取分片大小(MB)

func (*UploadConfig) GetMaxSaveHours

func (uc *UploadConfig) GetMaxSaveHours() float64

GetMaxSaveHours 获取最大保存时间(小时)

func (*UploadConfig) GetUploadSizeMB

func (uc *UploadConfig) GetUploadSizeMB() float64

GetUploadSizeMB 获取上传大小限制(MB)

func (*UploadConfig) IsChunkEnabled

func (uc *UploadConfig) IsChunkEnabled() bool

IsChunkEnabled 判断是否启用分片上传

func (*UploadConfig) IsUploadEnabled

func (uc *UploadConfig) IsUploadEnabled() bool

IsUploadEnabled 判断是否启用上传

func (*UploadConfig) ToMap

func (uc *UploadConfig) ToMap() map[string]string

ToMap 上传配置转换为map格式

func (*UploadConfig) Update

func (uc *UploadConfig) Update(updates map[string]interface{}) error

Update 更新上传配置

func (*UploadConfig) Validate

func (uc *UploadConfig) Validate() error

Validate 验证上传配置

type UserSystemConfig

type UserSystemConfig struct {
	AllowUserRegistration int    `json:"allow_user_registration"` // 是否允许用户注册
	RequireEmailVerify    int    `json:"require_email_verify"`    // 是否需要邮箱验证
	UserUploadSize        int64  `json:"user_upload_size"`        // 用户上传文件大小限制
	UserStorageQuota      int64  `json:"user_storage_quota"`      // 用户存储配额
	SessionExpiryHours    int    `json:"session_expiry_hours"`    // 用户会话过期时间
	MaxSessionsPerUser    int    `json:"max_sessions_per_user"`   // 每个用户最大会话数
	JWTSecret             string `json:"jwt_secret"`              // JWT签名密钥
}

UserSystemConfig 用户系统配置

func NewUserSystemConfig

func NewUserSystemConfig() *UserSystemConfig

NewUserSystemConfig 创建用户系统配置

func (*UserSystemConfig) Clone

func (usc *UserSystemConfig) Clone() *UserSystemConfig

Clone 克隆配置

func (*UserSystemConfig) DisableEmailVerify

func (usc *UserSystemConfig) DisableEmailVerify()

DisableEmailVerify 禁用邮箱验证

func (*UserSystemConfig) DisableRegistration

func (usc *UserSystemConfig) DisableRegistration()

DisableRegistration 禁用用户注册

func (*UserSystemConfig) EnableEmailVerify

func (usc *UserSystemConfig) EnableEmailVerify()

EnableEmailVerify 启用邮箱验证

func (*UserSystemConfig) EnableRegistration

func (usc *UserSystemConfig) EnableRegistration()

EnableRegistration 启用用户注册

func (*UserSystemConfig) FromMap

func (usc *UserSystemConfig) FromMap(data map[string]string) error

FromMap 从map加载配置

func (*UserSystemConfig) GenerateRandomJWTSecret

func (usc *UserSystemConfig) GenerateRandomJWTSecret() error

GenerateRandomJWTSecret 生成随机JWT密钥

func (*UserSystemConfig) GetSessionDuration

func (usc *UserSystemConfig) GetSessionDuration() time.Duration

GetSessionDuration 获取会话持续时间

func (*UserSystemConfig) GetSessionExpiryDays

func (usc *UserSystemConfig) GetSessionExpiryDays() float64

GetSessionExpiryDays 获取会话过期天数

func (*UserSystemConfig) GetUserStorageQuotaGB

func (usc *UserSystemConfig) GetUserStorageQuotaGB() float64

GetUserStorageQuotaGB 获取用户存储配额(GB)

func (*UserSystemConfig) GetUserUploadSizeMB

func (usc *UserSystemConfig) GetUserUploadSizeMB() float64

GetUserUploadSizeMB 获取用户上传大小限制(MB)

func (*UserSystemConfig) IsEmailVerifyRequired

func (usc *UserSystemConfig) IsEmailVerifyRequired() bool

IsEmailVerifyRequired 判断是否需要邮箱验证

func (*UserSystemConfig) IsRegistrationAllowed

func (usc *UserSystemConfig) IsRegistrationAllowed() bool

IsRegistrationAllowed 判断是否允许用户注册

func (*UserSystemConfig) IsStorageQuotaUnlimited

func (usc *UserSystemConfig) IsStorageQuotaUnlimited() bool

IsStorageQuotaUnlimited 判断存储配额是否无限制

func (*UserSystemConfig) IsUserSystemEnabled

func (usc *UserSystemConfig) IsUserSystemEnabled() bool

IsUserSystemEnabled 判断是否启用用户系统 - 始终返回true

func (*UserSystemConfig) SetSessionExpiryDays

func (usc *UserSystemConfig) SetSessionExpiryDays(days int) error

SetSessionExpiryDays 设置会话过期天数

func (*UserSystemConfig) SetUserStorageQuotaGB

func (usc *UserSystemConfig) SetUserStorageQuotaGB(quotaGB int64) error

SetUserStorageQuotaGB 设置用户存储配额(GB)

func (*UserSystemConfig) SetUserUploadSizeMB

func (usc *UserSystemConfig) SetUserUploadSizeMB(sizeMB int64) error

SetUserUploadSizeMB 设置用户上传大小限制(MB)

func (*UserSystemConfig) ToMap

func (usc *UserSystemConfig) ToMap() map[string]string

ToMap 转换为map格式

func (*UserSystemConfig) Update

func (usc *UserSystemConfig) Update(updates map[string]interface{}) error

Update 更新配置

func (*UserSystemConfig) Validate

func (usc *UserSystemConfig) Validate() error

Validate 验证用户系统配置

type WebDAVConfig

type WebDAVConfig struct {
	Hostname string `json:"webdav_hostname"`
	RootPath string `json:"webdav_root_path"`
	Proxy    int    `json:"webdav_proxy"`
	URL      string `json:"webdav_url"`
	Password string `json:"webdav_password"`
	Username string `json:"webdav_username"`
}

WebDAVConfig WebDAV存储配置

func NewWebDAVConfig

func NewWebDAVConfig() *WebDAVConfig

NewWebDAVConfig 创建WebDAV配置

func (*WebDAVConfig) Clone

func (wc *WebDAVConfig) Clone() *WebDAVConfig

Clone 克隆WebDAV配置

func (*WebDAVConfig) FromMap

func (wc *WebDAVConfig) FromMap(data map[string]string) error

FromMap 从map加载WebDAV配置

func (*WebDAVConfig) ToMap

func (wc *WebDAVConfig) ToMap() map[string]string

ToMap WebDAV配置转换为map格式

func (*WebDAVConfig) Validate

func (wc *WebDAVConfig) Validate() error

Validate 验证WebDAV配置

Jump to

Keyboard shortcuts

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