启动时自动调用 installation 统计接口

This commit is contained in:
RockYang 2025-03-25 18:32:44 +08:00
parent 96dd0ddb99
commit f080425ee6
2 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,8 @@
## v4.2.2
- 功能优化:开启图形验证码功能的时候现检查是否配置了 API 服务,防止开启之后没法登录的 Bug。
- 功能新增对话页面支持AI输出语音播报TTS
- 功能新增:支持 Goole 账号登录。
## v4.2.1

View File

@ -27,7 +27,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
"github.com/golang-jwt/jwt/v5"
"github.com/imroc/req/v3"
"github.com/nfnt/resize"
"github.com/shirou/gopsutil/host"
"golang.org/x/image/webp"
"gorm.io/gorm"
)
@ -70,6 +72,23 @@ func (s *AppServer) Run(db *gorm.DB) error {
if err != nil {
return fmt.Errorf("failed to decode system config: %v", err)
}
// 统计安装信息
go func() {
info, err := host.Info()
if err == nil {
apiURL := fmt.Sprintf("%s/%s", s.Config.ApiConfig.ApiURL, "api/installs/push")
timestamp := time.Now().Unix()
product := "geekai-plus"
signStr := fmt.Sprintf("%s#%s#%d", product, info.HostID, timestamp)
sign := utils.Sha256(signStr)
resp, err := req.C().R().SetBody(map[string]interface{}{"product": product, "device_id": info.HostID, "timestamp": timestamp, "sign": sign}).Post(apiURL)
if err != nil {
logger.Errorf("register install info failed: %v", err)
} else {
logger.Debugf("register install info success: %v", resp.String())
}
}
}()
logger.Infof("http://%s", s.Config.Listen)
return s.Engine.Run(s.Config.Listen)
}