feat(custom): CNY native billing, daily check-in button, subscription plans page, usage docs and promo banner

Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed).

- CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels
- New CheckinButton in both authenticated and public headers (Turnstile supported)
- New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset
- New /docs 12-section beginner guide with anchor navigation
- New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi)
- README: document custom features, live demo https://ai.88531.cn
This commit is contained in:
CaIon committed 2026-09-23 16:28:52 +08:00
commit 14a9acd368
2368 files changed
+551035

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
package performance_setting
import (
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/setting/config"
)
// PerformanceSetting 性能设置配置
type PerformanceSetting struct {
// DiskCacheEnabled 是否启用磁盘缓存(磁盘换内存)
DiskCacheEnabled bool `json:"disk_cache_enabled"`
// DiskCacheThresholdMB 触发磁盘缓存的请求体大小阈值(MB)
DiskCacheThresholdMB int `json:"disk_cache_threshold_mb"`
// DiskCacheMaxSizeMB 磁盘缓存最大总大小(MB)
DiskCacheMaxSizeMB int `json:"disk_cache_max_size_mb"`
// DiskCachePath 磁盘缓存目录
DiskCachePath string `json:"disk_cache_path"`
// MonitorEnabled 是否启用性能监控
MonitorEnabled bool `json:"monitor_enabled"`
// MonitorCPUThreshold CPU 使用率阈值(%)
MonitorCPUThreshold int `json:"monitor_cpu_threshold"`
// MonitorMemoryThreshold 内存使用率阈值(%)
MonitorMemoryThreshold int `json:"monitor_memory_threshold"`
// MonitorDiskThreshold 磁盘使用率阈值(%)
MonitorDiskThreshold int `json:"monitor_disk_threshold"`
}
// 默认配置
var performanceSetting = PerformanceSetting{
DiskCacheEnabled: false,
DiskCacheThresholdMB: 10, // 超过 10MB 使用磁盘缓存
DiskCacheMaxSizeMB: 1024, // 最大 1GB 磁盘缓存
DiskCachePath: "", // 空表示使用系统临时目录
MonitorEnabled: true,
MonitorCPUThreshold: 90,
MonitorMemoryThreshold: 90,
MonitorDiskThreshold: 95,
}
func init() {
// 注册到全局配置管理器
config.GlobalConfig.Register("performance_setting", &performanceSetting)
// 同步初始配置到 common 包
syncToCommon()
}
// syncToCommon 将配置同步到 common 包
func syncToCommon() {
common.SetDiskCacheConfig(common.DiskCacheConfig{
Enabled: performanceSetting.DiskCacheEnabled,
ThresholdMB: performanceSetting.DiskCacheThresholdMB,
MaxSizeMB: performanceSetting.DiskCacheMaxSizeMB,
Path: performanceSetting.DiskCachePath,
})
common.SetPerformanceMonitorConfig(common.PerformanceMonitorConfig{
Enabled: performanceSetting.MonitorEnabled,
CPUThreshold: performanceSetting.MonitorCPUThreshold,
MemoryThreshold: performanceSetting.MonitorMemoryThreshold,
DiskThreshold: performanceSetting.MonitorDiskThreshold,
})
}
// GetPerformanceSetting 获取性能设置
func GetPerformanceSetting() *PerformanceSetting {
return &performanceSetting
}
// UpdateAndSync 更新配置并同步到 common 包
// 当配置从数据库加载后,需要调用此函数同步
func UpdateAndSync() {
syncToCommon()
}
// GetCacheStats 获取缓存统计信息(代理到 common 包)
func GetCacheStats() common.DiskCacheStats {
return common.GetDiskCacheStats()
}
// ResetStats 重置统计信息
func ResetStats() {
common.ResetDiskCacheStats()
}