diff --git a/server.go b/server.go index a5a8fc0..6fff36d 100644 --- a/server.go +++ b/server.go @@ -394,5 +394,9 @@ func Init(ctx context.Context, cbs ...Option) (err error) { return } } + if !opts.disableRecorder { + //启用操作记录 + NewActivityRecorder(ctx, opts.db).Recoder() + } return } diff --git a/types.go b/types.go index afc9c14..2bfc80a 100644 --- a/types.go +++ b/types.go @@ -20,16 +20,17 @@ var ( type ( options struct { - db *gorm.DB - domain string - moduleName string - apiPrefix string //接口前缀 - viewPrefix string //生成菜单View的前缀路径 - vuePath string //生成Vue文件的路径,如果指定了启动的时候会自动生成Vue的文件 - translate Translate - disableDefault bool - httpServer *http.Server - restOpts []rest.Option + db *gorm.DB + domain string + moduleName string + apiPrefix string //接口前缀 + viewPrefix string //生成菜单View的前缀路径 + vuePath string //生成Vue文件的路径,如果指定了启动的时候会自动生成Vue的文件 + translate Translate + disableDefault bool + disableRecorder bool + httpServer *http.Server + restOpts []rest.Option } Option func(*options) @@ -68,6 +69,12 @@ func WithoutDefault() Option { } } +func WithoutRecorder() Option { + return func(o *options) { + o.disableRecorder = true + } +} + func WithHttpServer(server *http.Server) Option { return func(o *options) { o.httpServer = server