小优化

This commit is contained in:
xing 2023-05-10 14:28:21 +08:00
parent dfe7bb3181
commit 40451970a0

View File

@ -70,15 +70,11 @@ func PostPlugin(calls ...PostsPlugin) PostsPlugin {
} }
func UsePostsPlugins() PostsPlugin { func UsePostsPlugins() PostsPlugin {
p := config.GetConfig().ListPagePlugins
var pluginss []func(PostsPlugin, *Handle, *models.Posts)
m := pluginFns.Load() m := pluginFns.Load()
for _, s := range p { pluginss := slice.FilterAndMap(config.GetConfig().ListPagePlugins, func(t string) (func(PostsPlugin, *Handle, *models.Posts), bool) {
f, ok := m[s] f, ok := m[t]
if ok { return f, ok
pluginss = append(pluginss, f) })
}
}
slice.Unshift(&pluginss, PasswordProject) slice.Unshift(&pluginss, PasswordProject)
return PostsPlugins(PostPlugin(ordinaryPlugin.Load()...), pluginss...) return PostsPlugins(PostPlugin(ordinaryPlugin.Load()...), pluginss...)
} }