diff --git a/internal/servants/web/core.go b/internal/servants/web/core.go index 92dcfbaa..b3c3aee5 100644 --- a/internal/servants/web/core.go +++ b/internal/servants/web/core.go @@ -11,7 +11,6 @@ import ( "time" "unicode/utf8" - "github.com/alimy/cfg" "github.com/alimy/mir/v3" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" @@ -34,8 +33,6 @@ var ( _ api.Core = (*coreSrv)(nil) _ api.CoreBinding = (*coreBinding)(nil) _ api.CoreRender = (*coreRender)(nil) - - _EnablePhoneVerify = cfg.If("Sms") ) type coreSrv struct { diff --git a/internal/servants/web/web.go b/internal/servants/web/web.go index 286109d3..034cc83c 100644 --- a/internal/servants/web/web.go +++ b/internal/servants/web/web.go @@ -5,6 +5,8 @@ package web import ( + "sync" + "github.com/alimy/cfg" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" @@ -15,8 +17,14 @@ import ( "github.com/smartwalle/alipay/v3" ) +var ( + _EnablePhoneVerify bool + _onceInitial sync.Once +) + // RouteWeb register web route func RouteWeb(e *gin.Engine) { + initial() oss := dao.ObjectStorageService() ds := &base.DaoServant{ Redis: conf.Redis, @@ -66,3 +74,10 @@ func mustAlipayClient() *alipay.Client { } return client } + +// initial do some package lazy initialize for performance +func initial() { + _onceInitial.Do(func() { + _EnablePhoneVerify = cfg.If("Sms") + }) +}