feat: analysis user auth and ws

This commit is contained in:
zzw
2026-10-15 09:23:07 +08:00
parent 6fa185003d
commit a65b6d2803
102 changed files with 4966 additions and 786 deletions
+22 -7
View File
@@ -4,19 +4,20 @@ import (
"fmt"
"lone-services/pkg/utils"
"lone-services/pkg/wechat/auth"
"lone-services/pkg/wechat/qrcode"
)
type WechatQrcodeConfig struct {
type WechatConfig struct {
AppID string
Secret string
Page string
AuthPage string
Width int
EnvVersion string
}
func LoadWechatQrcodeConfig() (*WechatQrcodeConfig, error) {
func LoadWechatConfig() (*WechatConfig, error) {
appID := utils.GetConfigString("wechat.appid")
secret := utils.GetConfigString("wechat.secret")
if appID == utils.StringEmpty || secret == utils.StringEmpty {
@@ -24,22 +25,36 @@ func LoadWechatQrcodeConfig() (*WechatQrcodeConfig, error) {
}
page := utils.GetConfigString("wechat.page")
if page == utils.StringEmpty {
page = "pages/index/index"
}
authPage := utils.GetConfigString("wechat.auth_page")
if authPage == utils.StringEmpty {
authPage = "pagesB/authorize/scan"
}
width := utils.GetConfigInt("wechat.width")
if width <= 0 {
width = 430
}
envVersion := utils.GetConfigString("wechat.env_version")
if envVersion == utils.StringEmpty {
envVersion = "trial"
}
return &WechatQrcodeConfig{
return &WechatConfig{
AppID: appID,
Secret: secret,
Page: page,
AuthPage: authPage,
Width: width,
EnvVersion: envVersion,
}, nil
}
func (c *WechatQrcodeConfig) NewQrcodeClient() *qrcode.Client {
return qrcode.NewClient(c.AppID, c.Secret)
func (c *WechatConfig) NewAuthClient() *auth.Client {
return auth.NewClient(c.AppID, c.Secret)
}
func (c *WechatConfig) NewQrcodeClient() *qrcode.Client {
return qrcode.NewClient(c.NewAuthClient())
}