xui.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. // XUIController is the main controller for the X-UI panel, managing sub-controllers.
  6. type XUIController struct {
  7. BaseController
  8. settingController *SettingController
  9. xraySettingController *XraySettingController
  10. }
  11. // NewXUIController creates a new XUIController and initializes its routes.
  12. func NewXUIController(g *gin.RouterGroup) *XUIController {
  13. a := &XUIController{}
  14. a.initRouter(g)
  15. return a
  16. }
  17. // initRouter sets up the main panel routes and initializes sub-controllers.
  18. func (a *XUIController) initRouter(g *gin.RouterGroup) {
  19. g = g.Group("/panel")
  20. g.Use(a.checkLogin)
  21. g.GET("/", a.index)
  22. g.GET("/inbounds", a.inbounds)
  23. g.GET("/settings", a.settings)
  24. g.GET("/xray", a.xraySettings)
  25. a.settingController = NewSettingController(g)
  26. a.xraySettingController = NewXraySettingController(g)
  27. }
  28. // index renders the main panel index page.
  29. func (a *XUIController) index(c *gin.Context) {
  30. html(c, "index.html", "pages.index.title", nil)
  31. }
  32. // inbounds renders the inbounds management page.
  33. func (a *XUIController) inbounds(c *gin.Context) {
  34. html(c, "inbounds.html", "pages.inbounds.title", nil)
  35. }
  36. // settings renders the settings management page.
  37. func (a *XUIController) settings(c *gin.Context) {
  38. html(c, "settings.html", "pages.settings.title", nil)
  39. }
  40. // xraySettings renders the Xray settings page.
  41. func (a *XUIController) xraySettings(c *gin.Context) {
  42. html(c, "xray.html", "pages.xray.title", nil)
  43. }