mirror of
https://github.com/skyle1995/NetworkAuth.git
synced 2026-05-25 02:24:05 +08:00
修改项目为前后端分离方案
This commit is contained in:
@@ -3,30 +3,26 @@ package default_ctrl
|
||||
import (
|
||||
"NetworkAuth/services"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RootHandler 根路径处理器
|
||||
// 使用模板渲染服务器信息页面
|
||||
// 返回服务器信息 JSON
|
||||
func RootHandler(c *gin.Context) {
|
||||
// 获取设置服务
|
||||
settings := services.GetSettingsService()
|
||||
|
||||
// 传递模板数据
|
||||
data := map[string]interface{}{
|
||||
"Title": settings.GetString("site_title", "NetworkAuth Server"),
|
||||
"Keywords": settings.GetString("site_keywords", ""),
|
||||
"Description": settings.GetString("site_description", ""),
|
||||
"SystemName": "系统提醒", // 对应 H1
|
||||
"WarningText": "🚫 未授权,拒绝访问",
|
||||
"InfoText": "💬 如有问题,请联系网站管理员",
|
||||
"FooterText": settings.GetString("footer_text", "Copyright © 2026 NetworkAuth. All Rights Reserved."),
|
||||
"ICPRecord": settings.GetString("icp_record", ""),
|
||||
"ICPRecordLink": settings.GetString("icp_record_link", "https://beian.miit.gov.cn"),
|
||||
"CurrentYear": time.Now().Year(),
|
||||
// 传递数据
|
||||
data := gin.H{
|
||||
"title": settings.GetString("site_title", "NetworkAuth Server"),
|
||||
"description": settings.GetString("site_description", ""),
|
||||
"status": "running",
|
||||
"message": "NetworkAuth API Server is running",
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", data)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 200,
|
||||
"data": data,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user