You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

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