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.

43 lines
1.6 KiB

3 years ago
3 years ago
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. "github.com/flipped-aurora/gin-vue-admin/server/plugin/notify"
  7. //email "github.com/flipped-aurora/gva-plug-email" // 在线仓库模式
  8. "github.com/flipped-aurora/gin-vue-admin/server/plugin/email" // 本地插件仓库地址模式
  9. "github.com/flipped-aurora/gin-vue-admin/server/plugin/example_plugin"
  10. "github.com/flipped-aurora/gin-vue-admin/server/utils/plugin"
  11. "github.com/gin-gonic/gin"
  12. )
  13. func PluginInit(group *gin.RouterGroup, Plugin ...plugin.Plugin) {
  14. for i := range Plugin {
  15. PluginGroup := group.Group(Plugin[i].RouterPath())
  16. Plugin[i].Register(PluginGroup)
  17. }
  18. }
  19. func InstallPlugin(PublicGroup *gin.RouterGroup, PrivateGroup *gin.RouterGroup) {
  20. // 添加开放权限的插件 示例
  21. PluginInit(PublicGroup, example_plugin.ExamplePlugin, ws.GenerateWs(
  22. zap.L(), 100, ws.DefaultCheckMap()))
  23. // 添加跟角色挂钩权限的插件 示例 本地示例模式于在线仓库模式注意上方的import 可以自行切换 效果相同
  24. PluginInit(PrivateGroup, email.CreateEmailPlug(
  25. global.GVA_CONFIG.Email.To,
  26. global.GVA_CONFIG.Email.From,
  27. global.GVA_CONFIG.Email.Host,
  28. global.GVA_CONFIG.Email.Secret,
  29. global.GVA_CONFIG.Email.Nickname,
  30. global.GVA_CONFIG.Email.Port,
  31. global.GVA_CONFIG.Email.IsSSL,
  32. ))
  33. // 钉钉通知,暂时开放权限
  34. PluginInit(PublicGroup, notify.CreateDDPlug(
  35. "https://oapi.dingtalk.com/robot/send",
  36. "8ded23f91917dc4f6275f44ba5ef243e6ed1d2cc74de83f01a6f5f5f39905671",
  37. "SECaecf452bd6e671ab0d47469c3ad933e32fcc47b335333049a1b8961606192f38"))
  38. }