mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: admin dashboard homepage
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/pkg/request"
|
||||
"github.com/HFO4/cloudreve/service/admin"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
)
|
||||
|
||||
// AdminSummary 获取管理站点概况
|
||||
@@ -15,3 +17,21 @@ func AdminSummary(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// AdminNews 获取社区新闻
|
||||
func AdminNews(c *gin.Context) {
|
||||
r := request.HTTPClient{}
|
||||
res := r.Request("GET", "https://forum.cloudreve.org/api/discussions?include=startUser%2ClastUser%2CstartPost%2Ctags&filter%5Bq%5D=%20tag%3Anotice&sort=-startTime&", nil)
|
||||
io.Copy(c.Writer, res.Response.Body)
|
||||
}
|
||||
|
||||
// AdminChangeSetting 获取站点设定项
|
||||
func AdminChangeSetting(c *gin.Context) {
|
||||
var service admin.BatchSettingChangeService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Change()
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/bootstrap"
|
||||
"github.com/HFO4/cloudreve/middleware"
|
||||
"github.com/HFO4/cloudreve/pkg/conf"
|
||||
"github.com/HFO4/cloudreve/pkg/hashid"
|
||||
@@ -70,7 +71,9 @@ func InitCORS(router *gin.Engine) {
|
||||
// InitMasterRouter 初始化主机模式路由
|
||||
func InitMasterRouter() *gin.Engine {
|
||||
r := gin.Default()
|
||||
bootstrap.InitCustomRoute(r.Group("/custom"))
|
||||
v3 := r.Group("/api/v3")
|
||||
|
||||
/*
|
||||
中间件
|
||||
*/
|
||||
@@ -282,6 +285,10 @@ func InitMasterRouter() *gin.Engine {
|
||||
{
|
||||
// 获取站点概况
|
||||
admin.GET("summary", controllers.AdminSummary)
|
||||
// 获取社区新闻
|
||||
admin.GET("news", controllers.AdminNews)
|
||||
// 更改设置
|
||||
admin.PATCH("setting", controllers.AdminChangeSetting)
|
||||
}
|
||||
|
||||
// 用户
|
||||
|
||||
Reference in New Issue
Block a user