Documentation
¶
Index ¶
- Constants
- func ConfigFilePath() (string, error)
- func EnsureDefaultConfigFile() error
- func EnvValue(spec SettingSpec) (string, bool)
- func IsSensitiveSetting(alias string) bool
- func NewLogger(writer io.Writer, cfg RuntimeConfig) (*slog.Logger, error)
- func PublicSettingText(alias, text string) string
- func RefreshTokenFromEnv() (string, error)
- func SetConfigValue(path, alias string, value parser.Value) error
- func SetFilePathForTest(configPath string) func()
- func UnsetConfigValue(path, alias string) (bool, error)
- func ValidSettingAliases() []string
- func WritePrivateFile(path string, body []byte) error
- type AccountPoolConfig
- type AccountPoolStrategy
- type RuntimeConfig
- type SettingSpec
- type SettingValue
- type SettingsState
Constants ¶
View Source
const ( DefaultDownloadPath = "./downloads" DefaultFilenameTemplate = "{author} - {title}_{id}" )
View Source
const DefaultConfigFileMode = constants.PrivateFileMode
Variables ¶
This section is empty.
Functions ¶
func ConfigFilePath ¶
func EnsureDefaultConfigFile ¶ added in v0.7.1
func EnsureDefaultConfigFile() error
EnsureDefaultConfigFile 在配置首次缺失时生成只含常用选项的基线文件。高级设置 (代理、日志、登录超时与 Premium 缓存等)必须由用户显式写入,已有文件绝不覆盖。
func EnvValue ¶
func EnvValue(spec SettingSpec) (string, bool)
func IsSensitiveSetting ¶ added in v0.8.0
IsSensitiveSetting 标记禁止通过公开配置查询回显的凭据型值。
func NewLogger ¶ added in v0.2.0
NewLogger 按已解析的运行时配置创建本进程根 logger。调用方决定输出流,CLI/MCP 一律传 stderr;本函数绝不设置或读取 slog 默认全局 logger。
func PublicSettingText ¶ added in v0.8.0
PublicSettingText 返回可安全进入 CLI、SDK JSON 与日志边界的配置值。
func RefreshTokenFromEnv ¶
RefreshTokenFromEnv 读取 App API refresh token。Cookie 形态在此处即被拒绝, 不能继续流入默认 SDK 的 OAuth 请求。
func SetFilePathForTest ¶
func SetFilePathForTest(configPath string) func()
func UnsetConfigValue ¶
func ValidSettingAliases ¶
func ValidSettingAliases() []string
func WritePrivateFile ¶
Types ¶
type AccountPoolConfig ¶ added in v0.8.0
type AccountPoolConfig struct {
Enabled bool
Accounts []int64
Strategy AccountPoolStrategy
}
AccountPoolConfig 描述内容读取和作品下载可使用的本地受管账号白名单。 账号 token 仍只存在 auth.json,配置与状态文件均不保存凭据。
type AccountPoolStrategy ¶ added in v0.8.0
type AccountPoolStrategy string
const ( AccountPoolStrategyRoundRobin AccountPoolStrategy = "round_robin" AccountPoolStrategyRandom AccountPoolStrategy = "random" )
type RuntimeConfig ¶
type RuntimeConfig struct {
DownloadPath string
FilenameTemplate string
HTTPSProxy string
WebFallbackEnabled bool
UpdateCheckEnabled bool
OutputJSON bool
LoginOpenBrowser bool
LoginUseAfterLogin bool
// LoginRelay* 描述跨机器浏览器回调中继。secret 只用于 handler 与 server
// 间的 bearer 认证,不能作为普通配置输出的一部分。
LoginRelayPublicURL string
LoginRelayListenAddr string
LoginRelaySecret string
LoginRelayTargetURL string
LoginRelayTLSCertFile string
LoginRelayTLSKeyFile string
// LogLevel 只描述应用根 logger,不会改变 slog 默认全局 logger。
LogLevel string
// AccountPool 只能在 config.toml 的 [account_pool] 表中手工维护,避免普通
// config set 的扁平字符串接口误写账号白名单。
AccountPool AccountPoolConfig
}
type SettingSpec ¶
type SettingSpec struct {
Alias string
KoanfKey string
Table []string
Key string
Kind settingKind
// Sensitive 表示该值可用于认证或中继授权。它可以被写入私有 config.toml,
// 但绝不能通过 config get、日志或错误消息回显。
Sensitive bool
HasDefault bool
Default any
}
func SettingSpecByAlias ¶
func SettingSpecByAlias(alias string) (SettingSpec, bool)
type SettingValue ¶
func ParseSettingInput ¶
func ParseSettingInput(alias, raw string) (SettingValue, parser.Value, error)
type SettingsState ¶
type SettingsState struct {
// contains filtered or unexported fields
}
func LoadSettingsState ¶
func LoadSettingsState() (SettingsState, error)
func LoadSettingsStateAt ¶ added in v0.2.0
func LoadSettingsStateAt(path string) (SettingsState, error)
LoadSettingsStateAt 从明确给定的路径加载配置。SDK 需要它避免改动 包级测试路径或依赖调用进程的隐式当前配置位置。
func (SettingsState) Effective ¶
func (s SettingsState) Effective(alias string) (SettingValue, error)
func (SettingsState) Runtime ¶
func (s SettingsState) Runtime() (RuntimeConfig, error)
Click to show internal directories.
Click to hide internal directories.