Documentation
¶
Index ¶
- Constants
- Variables
- func AutoSetCacheDir()
- func DefaultConfigLocation() string
- func DeleteConfigIn(in string) error
- func GetConfigDir() (dir string, err error)
- func GetHomeDirectoryConfig() string
- func GetJwtSigningKey() string
- func GetProgramDirectoryConfig() string
- func GetQrcodeURL() string
- func GetVersion() string
- func GetWorkingDirectoryConfig() string
- func InitLibraryScanner()
- func OpenBrowserIfNeeded()
- func ResetConfigForRuntime()
- func SaveConfig(to string) error
- func ScanUserPlugins() error
- func SetPort(port int)
- func SetScanTaskFunc(fn func() error)
- func StartOrStopAutoRescan()
- func UpdateConfigByJson(jsonString string) error
- func UpdateConfigFile() error
- type Config
- func (c *Config) AddPlugin(pluginName string) error
- func (c *Config) AddStoreUrl(storeURL string) error
- func (c *Config) AddStringArrayConfig(fieldName, addValue string) ([]string, error)
- func (c *Config) DeleteStringArrayConfig(fieldName, deleteValue string) ([]string, error)
- func (c *Config) DisablePlugin(pluginName string) error
- func (c *Config) GetClearDatabaseWhenExit() bool
- func (c *Config) GetDebug() bool
- func (c *Config) GetEnableDatabase() bool
- func (c *Config) GetEnableUpload() bool
- func (c *Config) GetExcludePath() []string
- func (c *Config) GetHost() string
- func (c *Config) GetMaxScanDepth() int
- func (c *Config) GetMinImageNum() int
- func (c *Config) GetPort() int
- func (c *Config) GetStoreUrls() []string
- func (c *Config) GetSupportFileType() []string
- func (c *Config) GetSupportMediaType() []string
- func (c *Config) GetSupportTemplateFile() []string
- func (c *Config) GetTimeoutLimitForScan() int
- func (c *Config) GetTopStoreName() string
- func (c *Config) GetZipFileTextEncoding() string
- func (c *Config) HasLoginMethodConfigured() bool
- func (c *Config) HasPasswordLoginConfigured() bool
- func (c *Config) InitConfigStoreUrls()
- func (c *Config) IsPathOverlapping(newPath string) (overlapping bool, conflictPath string, message string)
- func (c *Config) IsPluginEnabled(pluginName string) bool
- func (c *Config) RequiresAuth() bool
- func (c *Config) SetConfigValue(fieldName, fieldValue string) error
- func (c *Config) StoreUrlIsExits(url string) bool
- type CustomPlugin
- type FrpClientConfig
- type Status
- type UploadDirOption
- type WebPServerConfig
Constants ¶
const ( HomeDirectory = "HomeDirectory" WorkingDirectory = "WorkingDirectory" ProgramDirectory = "ProgramDirectory" )
Variables ¶
var CfgStatus = Status{}
var GlobalLibraryScanner *scheduler.LibraryScanner
GlobalLibraryScanner 全局的定时扫描调度器实例
Functions ¶
func AutoSetCacheDir ¶ added in v1.1.0
func AutoSetCacheDir()
func DefaultConfigLocation ¶ added in v1.0.0
func DefaultConfigLocation() string
DefaultConfigLocation 判断当前配置文件应该保存到哪里。 逻辑:
- 是否在HomeDirectory已有 config.toml
- 否则是否在WorkingDirectory已有 config.toml
- 否则是否在ProgramDirectory已有 config.toml 若都没有,则返回 "HomeDirectory"。
返回:location字符串
func DeleteConfigIn ¶
func GetConfigDir ¶ added in v1.1.0
GetConfigDir 获取配置文件所在目录 优先级:1. 用户指定的配置文件路径 2. COMIGO_CONFIG_DIR 环境变量 3. 用户主目录 4. 临时目录
func GetHomeDirectoryConfig ¶ added in v1.0.0
func GetHomeDirectoryConfig() string
func GetJwtSigningKey ¶ added in v1.0.0
func GetJwtSigningKey() string
GetJwtSigningKey JWT令牌签名key,目前是用户名+密码(如果两者都设置了的话)
func GetProgramDirectoryConfig ¶ added in v1.0.0
func GetProgramDirectoryConfig() string
func GetQrcodeURL ¶
func GetQrcodeURL() string
func GetVersion ¶ added in v1.0.0
func GetVersion() string
func GetWorkingDirectoryConfig ¶ added in v1.0.0
func GetWorkingDirectoryConfig() string
func OpenBrowserIfNeeded ¶ added in v1.1.6
func OpenBrowserIfNeeded()
func ResetConfigForRuntime ¶ added in v1.2.25
func ResetConfigForRuntime()
ResetConfigForRuntime 在嵌入模式重复启动时重置全局配置,避免保留上一次运行的状态。
func SaveConfig ¶
func SetScanTaskFunc ¶ added in v1.1.8
func SetScanTaskFunc(fn func() error)
SetScanTaskFunc 设置扫描任务函数(由外部包调用,避免循环导入)
func StartOrStopAutoRescan ¶ added in v1.1.8
func StartOrStopAutoRescan()
StartOrStopAutoRescan 根据配置启动或停止自动扫描
func UpdateConfigByJson ¶ added in v1.0.0
UpdateConfigByJson 使用 JSON 字符串反序列化将更新的配置解析为映射,遍历映射并更新配置 使用反射自动处理字段赋值,减少重复代码
func UpdateConfigFile ¶ added in v1.1.0
func UpdateConfigFile() error
UpdateConfigFile 更新当前正在使用的配置文件。 如果尚未存在配置文件,则会自动在默认位置创建一份。
Types ¶
type Config ¶
type Config struct {
AutoRescanIntervalMinutes int `` /* 135-byte string literal not displayed */
CacheDir string `json:"CacheDir" comment:"本地图片缓存位置,默认系统临时文件夹"`
ClearCacheExit bool `json:"ClearCacheExit" comment:"退出程序的时候,清理web图片缓存"`
ClearDatabaseWhenExit bool `json:"ClearDatabaseWhenExit" comment:"启用本地数据库时,扫描完成后,清除不存在的书籍。"`
ConfigFile string `json:"-" toml:"-" comment:"用户指定的的yaml设置文件路径"`
SelfUpgrade bool `` /* 133-byte string literal not displayed */
ReadOnlyMode bool `json:"ReadOnlyMode" comment:"只读模式。禁止网页端更改配置或上传文件。"`
Debug bool `json:"Debug" comment:"开启Debug模式"`
EnablePlugin bool `json:"EnablePlugin" comment:"启用插件系统"`
PluginDirectory string `json:"-" toml:"-" comment:"插件存放目录"`
BuildInPluginList []string `json:"-" toml:"-" comment:"内置插件列表"`
UserPluginList []string `json:"-" toml:"-" comment:"用户自定义插件列表"`
EnabledPluginList []string `json:"-" toml:"-" comment:"已启用插件列表"`
CustomPlugins []CustomPlugin `json:"-" toml:"-" comment:"用户自定义插件内容列表"`
DisableLAN bool `json:"DisableLAN" comment:"只在本机提供阅读服务,不对外共享"`
EnableDatabase bool `json:"EnableDatabase" comment:"启用本地数据库,保存扫描到的书籍数据。"`
EnableTLS bool `json:"EnableTLS" comment:"是否启用HTTPS协议。需要设置证书于key文件。"`
AutoTLSCertificate bool `json:"AutoTLSCertificate" comment:"自动申请、签发 HTTPS 证书(Let's Encrypt)"`
Host string `` /* 191-byte string literal not displayed */
KeyFile string `json:"KeyFile" comment:"TLS/SSL key文件路径 (default: ~/.config/.comigo/key.key)"`
CertFile string `json:"CertFile" comment:"TLS/SSL 证书文件路径 (default: ~/.config/.comigo/cert.crt)"`
EnableUpload bool `json:"EnableUpload" comment:"启用上传功能"`
ExcludePath []string `json:"ExcludePath" comment:"扫描书籍的时候,需要排除的文件或文件夹的名字"`
GenerateMetaData bool `json:"GenerateMetaData" toml:"GenerateMetaData" comment:"生成书籍元数据"`
StoreUrls []string `json:"StoreUrls" comment:"本地书库路径列表,支持多个路径。可以是本地文件夹或网络书库地址。"` // 书库地址列表
LogFileName string `json:"LogFileName" comment:"Log文件名"`
LogFilePath string `json:"LogFilePath" comment:"Log文件的保存位置"`
LogToFile bool `json:"LogToFile" comment:"是否保存程序Log到本地文件。默认不保存。"`
MaxScanDepth int `json:"MaxScanDepth" comment:"最大扫描深度"`
MinImageNum int `json:"MinImageNum" comment:"压缩包或文件夹内,至少有几张图片,才算作书籍"`
OpenBrowser bool `json:"OpenBrowser" comment:"是否同时打开浏览器,windows默认true,其他默认false"`
Password string `json:"Password" comment:"登录界面需要的密码。"`
Port int `` /* 320-byte string literal not displayed */
PrintAllPossibleQRCode bool `json:"PrintAllPossibleQRCode" comment:"扫描完成后,打印所有可能的阅读链接二维码"`
SupportFileType []string `json:"SupportFileType" comment:"支持的书籍压缩包后缀"`
SupportMediaType []string `json:"SupportMediaType" comment:"扫描压缩包时,用于统计图片数量的图片文件后缀"`
SupportTemplateFile []string `json:"SupportTemplateFile" comment:"支持的模板文件类型,默认为html"`
Timeout int `json:"Timeout" comment:"cookie过期的时间。单位为分钟。默认60*24*30分钟后过期。"`
TimeoutLimitForScan int `` /* 130-byte string literal not displayed */
UseCache bool `json:"UseCache" comment:"开启本地图片缓存,可以加快二次读取,但会占用硬盘空间"`
Username string `json:"Username" comment:"登录界用的用户名。"`
EnableTailscale bool `json:"EnableTailscale" comment:"启用Tailscale网络支持"`
TailscaleHostname string `json:"TailscaleHostname" comment:"Tailscale网络的主机名,默认为comigo"`
FunnelTunnel bool `json:"FunnelTunnel" comment:"启用Tailscale的Funnel模式,允许通过Tailscale公开comigo服务到公网。"`
FunnelLoginCheck bool `json:"funnel_enforce_password" comment:"启用Funnel模式时,强制要求使用密码登录comigo服务。"`
TailscalePort int `json:"TailscalePort" comment:"Tailscale网络的端口,默认为443"`
TailscaleAuthKey string `` /* 142-byte string literal not displayed */
ZipFileTextEncoding string `json:"ZipFileTextEncoding" comment:"非utf-8编码的ZIP文件,尝试用什么编码解析,默认GBK"`
EnableSingleInstance bool `json:"EnableSingleInstance" comment:"启用单实例模式,确保同一时间只有一个程序实例运行"`
Language string `` /* 148-byte string literal not displayed */
RegisterContextMenu bool `json:"RegisterContextMenu" comment:"在 Windows 上注册资源管理器文件夹右键菜单:使用Comigo打开"`
UnregisterContextMenu bool `json:"UnregisterContextMenu" comment:"在 Windows 上卸载资源管理器文件夹右键菜单:使用Comigo打开"`
}
Config Comigo全局配置
func (*Config) AddStoreUrl ¶ added in v1.1.0
AddStoreUrl 添加书库(支持本地路径和远程 URL) 本地路径会将相对路径转换为绝对路径,并检查路径冲突 远程 URL(WebDAV 等)会在扫描时验证连接
func (*Config) AddStringArrayConfig ¶ added in v1.0.0
AddStringArrayConfig 往指定的 []string 字段中添加一个新字符串 对于 StoreUrls 字段,会进行路径验证和标准化
func (*Config) DeleteStringArrayConfig ¶ added in v1.0.0
DeleteStringArrayConfig 从指定的 []string 字段中删除某个字符串 对于 StoreUrls 字段,删除时也需要使用绝对路径进行匹配
func (*Config) DisablePlugin ¶ added in v1.2.3
DisablePlugin 禁用指定插件(从 EnabledPluginList 移除)
func (*Config) GetClearDatabaseWhenExit ¶ added in v1.0.0
func (*Config) GetEnableDatabase ¶ added in v1.0.0
func (*Config) GetEnableUpload ¶ added in v1.1.0
func (*Config) GetExcludePath ¶ added in v1.0.0
func (*Config) GetMaxScanDepth ¶ added in v1.0.0
func (*Config) GetMinImageNum ¶ added in v1.0.0
func (*Config) GetStoreUrls ¶ added in v1.1.0
func (*Config) GetSupportFileType ¶ added in v1.0.0
func (*Config) GetSupportMediaType ¶ added in v1.0.0
func (*Config) GetSupportTemplateFile ¶ added in v1.0.0
func (*Config) GetTimeoutLimitForScan ¶ added in v1.0.0
func (*Config) GetTopStoreName ¶ added in v1.0.0
func (*Config) GetZipFileTextEncoding ¶ added in v1.0.0
func (*Config) HasLoginMethodConfigured ¶ added in v1.2.25
HasLoginMethodConfigured 是否至少配置了一种可用登录方式。
func (*Config) HasPasswordLoginConfigured ¶ added in v1.2.25
HasPasswordLoginConfigured 是否已配置可用的账号密码登录。
func (*Config) InitConfigStoreUrls ¶ added in v1.1.5
func (c *Config) InitConfigStoreUrls()
InitConfigStoreUrls 初始化配置文件中的书库 本地路径会将相对路径转换为绝对路径 远程 URL(WebDAV 等)保持原样
func (*Config) IsPathOverlapping ¶ added in v1.2.4
func (c *Config) IsPathOverlapping(newPath string) (overlapping bool, conflictPath string, message string)
IsPathOverlapping 检查新路径是否与已有路径重合(完全相同、父子关系) 返回值: - overlapping: true 表示有重合 - conflictPath: 冲突的已有路径 - message: 错误消息
func (*Config) IsPluginEnabled ¶ added in v1.2.3
IsPluginEnabled 检查指定插件是否已启用
func (*Config) RequiresAuth ¶ added in v1.1.0
RequiresAuth 是否需要登录。 当前只要已配置可用的账号密码,就自动启用鉴权。
func (*Config) SetConfigValue ¶ added in v1.0.0
SetConfigValue 更新 Config 的相应字段,如果【fieldName】不存在、或【fieldValue】类型有问题,都返回错误。
func (*Config) StoreUrlIsExits ¶ added in v1.1.0
StoreUrlIsExits 检查书库URL是否可添加(已弃用,使用 IsPathOverlapping 代替)
type CustomPlugin ¶ added in v1.2.4
type CustomPlugin struct {
Name string // 文件名
Content string // 文件内容
FileType string // html/css/js
Scope string // global/shelf/flip/scroll
}
CustomPlugin 用户自定义插件结构
func GetCustomPluginsByScope ¶ added in v1.2.4
func GetCustomPluginsByScope(scope string) []CustomPlugin
GetCustomPluginsByScope 根据范围获取自定义插件
func LoadBookPlugins ¶ added in v1.2.4
func LoadBookPlugins(bookID, scope string) ([]CustomPlugin, error)
LoadBookPlugins 加载特定书籍的插件(按需加载) bookID: 书籍ID,如 "a1cE4Fz" scope: 范围,如 "flip" 或 "scroll" 返回该书籍在指定范围下的插件列表
type FrpClientConfig ¶ added in v1.0.0
type FrpClientConfig struct {
FrpcCommand string `comment:"手动设定frpc可执行程序的路径,默认为frpc"`
ServerAddr string
ServerPort int
Token string
FrpType string // 本地转发端口设置
RemotePort int
RandomRemotePort bool
}
FrpClientConfig frp客户端配置
type Status ¶
type Status struct {
// 当前生效的配置文件路径 None、HomeDirectory、WorkingDirectory、ProgramDirectory
// 设置读取顺序:None(默认值) -> HomeDirectory -> ProgramDirectory -> WorkingDirectory
In string
Path struct {
// 对应配置文件的绝对路径
WorkingDirectory string
HomeDirectory string
ProgramDirectory string
}
}
func (*Status) SetConfigStatus ¶ added in v1.0.0
type UploadDirOption ¶ added in v1.0.0
type UploadDirOption int