xui.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. type XUIController struct {
  6. BaseController
  7. inboundController *InboundController
  8. serverController *ServerController
  9. settingController *SettingController
  10. xraySettingController *XraySettingController
  11. }
  12. func NewXUIController(g *gin.RouterGroup) *XUIController {
  13. a := &XUIController{}
  14. a.initRouter(g)
  15. return a
  16. }
  17. func (a *XUIController) initRouter(g *gin.RouterGroup) {
  18. g = g.Group("/panel")
  19. g.Use(a.checkLogin)
  20. g.GET("/", a.index)
  21. g.GET("/inbounds", a.inbounds)
  22. g.GET("/settings", a.settings)
  23. g.GET("/xray", a.xraySettings)
  24. a.inboundController = NewInboundController(g)
  25. a.serverController = NewServerController(g)
  26. a.settingController = NewSettingController(g)
  27. a.xraySettingController = NewXraySettingController(g)
  28. }
  29. func (a *XUIController) index(c *gin.Context) {
  30. html(c, "index.html", "pages.index.title", nil)
  31. }
  32. func (a *XUIController) inbounds(c *gin.Context) {
  33. html(c, "inbounds.html", "pages.inbounds.title", nil)
  34. }
  35. func (a *XUIController) settings(c *gin.Context) {
  36. html(c, "settings.html", "pages.settings.title", nil)
  37. }
  38. func (a *XUIController) xraySettings(c *gin.Context) {
  39. html(c, "xray.html", "pages.xray.title", nil)
  40. }