plugin.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package initialize
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. email "github.com/flipped-aurora/gva-plugins/email" // 在线仓库模式go
  5. //"github.com/flipped-aurora/gin-vue-admin/server/plugin/email" // 本地插件仓库地址模式
  6. "github.com/flipped-aurora/gin-vue-admin/server/plugin/example_plugin"
  7. "github.com/flipped-aurora/gin-vue-admin/server/utils/plugin"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func PluginInit(group *gin.RouterGroup, Plugin ...plugin.Plugin) {
  11. for i := range Plugin {
  12. PluginGroup := group.Group(Plugin[i].RouterPath())
  13. Plugin[i].Register(PluginGroup)
  14. }
  15. }
  16. func InstallPlugin(PublicGroup *gin.RouterGroup, PrivateGroup *gin.RouterGroup) {
  17. // 添加开放权限的插件 示例
  18. PluginInit(PublicGroup,
  19. example_plugin.ExamplePlugin)
  20. // 添加跟角色挂钩权限的插件 示例 本地示例模式于在线仓库模式注意上方的import 可以自行切换 效果相同
  21. PluginInit(PrivateGroup, email.CreateEmailPlug(
  22. global.GVA_CONFIG.Email.To,
  23. global.GVA_CONFIG.Email.From,
  24. global.GVA_CONFIG.Email.Host,
  25. global.GVA_CONFIG.Email.Secret,
  26. global.GVA_CONFIG.Email.Nickname,
  27. global.GVA_CONFIG.Email.Port,
  28. global.GVA_CONFIG.Email.IsSSL,
  29. ))
  30. }