Skip to content

Commit 4c0a2ac

Browse files
committed
fix: 修复不声明config就报错问题
1 parent 1cfa02e commit 4c0a2ac

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

telescope_provider.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ func (t *Providers) SetDB(db *gorm.DB) {
3535
}
3636

3737
func (t *Providers) Init() {
38-
errorRecord = app.Config("telescope.error_record", false)
38+
v := app.GetConfigAny("telescope.error_record")
39+
if b, ok := v.(*bool); ok && *b {
40+
errorRecord = true
41+
}
3942
if (app.IsDebug() || errorRecord) && !t.init {
4043
t.init = true
4144
t.Register()
@@ -74,9 +77,11 @@ type telescopeHook struct {
7477
isOnlyRoute bool
7578
}
7679

77-
// TODO 修正不声明config就报错后,可取消这func,改为依赖注入
7880
func (t *telescopeHook) Init() {
79-
t.isOnlyRoute = app.Config("telescope.is_only_route", false)
81+
v := app.GetConfigAny("telescope.is_only_route")
82+
if b, ok := v.(*bool); ok && *b {
83+
t.isOnlyRoute = true
84+
}
8085
}
8186

8287
func (t *telescopeHook) Levels() []logrus.Level {

0 commit comments

Comments
 (0)