feat: register NodeController routes and nodes page

- Add nodeController field and route group in api.go
- Add /panel/nodes page route in xui.go
- Verified node.go does not add duplicate checkAdmin middleware
This commit is contained in:
root 2026-04-24 17:08:52 +08:00
parent 16eb179eaf
commit cb4b1eba85
2 changed files with 15 additions and 3 deletions

View file

@ -15,6 +15,7 @@ type APIController struct {
inboundController *InboundController inboundController *InboundController
serverController *ServerController serverController *ServerController
userController *UserController userController *UserController
nodeController *NodeController
Tgbot service.Tgbot Tgbot service.Tgbot
} }
@ -58,6 +59,11 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
users.Use(a.checkAdmin) users.Use(a.checkAdmin)
a.userController = NewUserController(users) a.userController = NewUserController(users)
// Nodes API
nodes := api.Group("/nodes")
nodes.Use(a.checkAdmin)
a.nodeController = NewNodeController(nodes)
// Extra routes // Extra routes
api.GET("/backuptotgbot", a.checkAdmin, a.BackuptoTgbot) api.GET("/backuptotgbot", a.checkAdmin, a.BackuptoTgbot)
} }

View file

@ -33,6 +33,7 @@ func (a *XUIController) initRouter(g *gin.RouterGroup) {
g.GET("/inbounds", a.checkAdmin, a.inbounds) g.GET("/inbounds", a.checkAdmin, a.inbounds)
g.GET("/settings", a.checkAdmin, a.settings) g.GET("/settings", a.checkAdmin, a.settings)
g.GET("/xray", a.checkAdmin, a.xraySettings) g.GET("/xray", a.checkAdmin, a.xraySettings)
g.GET("/nodes", a.checkAdmin, a.nodes)
g.GET("/users", a.checkAdmin, a.users) g.GET("/users", a.checkAdmin, a.users)
a.settingController = NewSettingController(g) a.settingController = NewSettingController(g)
@ -69,6 +70,11 @@ func (a *XUIController) xraySettings(c *gin.Context) {
html(c, "xray.html", "pages.xray.title", nil) html(c, "xray.html", "pages.xray.title", nil)
} }
// nodes renders the node management page.
func (a *XUIController) nodes(c *gin.Context) {
html(c, "nodes.html", "pages.nodes.title", nil)
}
// users renders the admin user management page. // users renders the admin user management page.
func (a *XUIController) users(c *gin.Context) { func (a *XUIController) users(c *gin.Context) {
html(c, "users.html", "pages.users.title", nil) html(c, "users.html", "pages.users.title", nil)