mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-09 05:51:01 +08:00
feat: 添加use_default_coins开关,简化默认币种配置
- 新增use_default_coins配置项:true=使用默认8个主流币种,false=使用API币种池 - 更直观的配置方式,新手可直接设置true快速开始 - 优先级:use_default_coins > coin_pool_api_url > 缓存 > 默认列表 - 更新所有语言版本README(en/zh-CN/ru/uk)添加配置说明 - 更新config.json.example示例文件
This commit is contained in:
@@ -26,15 +26,17 @@ var defaultMainstreamCoins = []string{
|
||||
|
||||
// CoinPoolConfig 币种池配置
|
||||
type CoinPoolConfig struct {
|
||||
APIURL string
|
||||
Timeout time.Duration
|
||||
CacheDir string
|
||||
APIURL string
|
||||
Timeout time.Duration
|
||||
CacheDir string
|
||||
UseDefaultCoins bool // 是否使用默认主流币种
|
||||
}
|
||||
|
||||
var coinPoolConfig = CoinPoolConfig{
|
||||
APIURL: "",
|
||||
Timeout: 30 * time.Second, // 增加到30秒
|
||||
CacheDir: "coin_pool_cache",
|
||||
APIURL: "",
|
||||
Timeout: 30 * time.Second, // 增加到30秒
|
||||
CacheDir: "coin_pool_cache",
|
||||
UseDefaultCoins: false, // 默认不使用
|
||||
}
|
||||
|
||||
// CoinPoolCache 币种池缓存
|
||||
@@ -76,8 +78,19 @@ func SetOITopAPI(apiURL string) {
|
||||
oiTopConfig.APIURL = apiURL
|
||||
}
|
||||
|
||||
// SetUseDefaultCoins 设置是否使用默认主流币种
|
||||
func SetUseDefaultCoins(useDefault bool) {
|
||||
coinPoolConfig.UseDefaultCoins = useDefault
|
||||
}
|
||||
|
||||
// GetCoinPool 获取币种池列表(带重试和缓存机制)
|
||||
func GetCoinPool() ([]CoinInfo, error) {
|
||||
// 优先检查是否启用默认币种列表
|
||||
if coinPoolConfig.UseDefaultCoins {
|
||||
log.Printf("✓ 已启用默认主流币种列表")
|
||||
return convertSymbolsToCoins(defaultMainstreamCoins), nil
|
||||
}
|
||||
|
||||
// 检查API URL是否配置
|
||||
if strings.TrimSpace(coinPoolConfig.APIURL) == "" {
|
||||
log.Printf("⚠️ 未配置币种池API URL,使用默认主流币种列表")
|
||||
|
||||
Reference in New Issue
Block a user