feat: publish sanitized custom.97 source

This commit is contained in:
cneicy committed 2026-10-27 20:43:39 +08:00
1 parent 8e6ed0317b
commit 86c0276156
1022 files changed
+69903 -19207

No files matched your search

+10 -40
View File
@@ -46,10 +46,7 @@ func GetSetup(c *gin.Context) {
func PostSetup(c *gin.Context) {
// Check if setup is already completed
if constant.Setup {
c.JSON(200, gin.H{
"success": false,
"message": "系统已经初始化完成",
})
common.ApiErrorT(c, "The system is already initialized")
return
}
@@ -59,10 +56,7 @@ func PostSetup(c *gin.Context) {
var req SetupRequest
err := c.ShouldBindJSON(&req)
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "请求参数有误",
})
common.ApiErrorT(c, "Invalid parameters")
return
}
@@ -70,18 +64,12 @@ func PostSetup(c *gin.Context) {
if !rootExists {
// Validate username length: max 12 characters to align with model.User validation
if len(req.Username) > 12 {
c.JSON(200, gin.H{
"success": false,
"message": "用户名长度不能超过12个字符",
})
common.ApiErrorT(c, "Username must be {{max}} characters or fewer", map[string]any{"max": 12})
return
}
// Validate password
if req.Password != req.ConfirmPassword {
c.JSON(200, gin.H{
"success": false,
"message": "两次输入的密码不一致",
})
common.ApiErrorT(c, "Passwords do not match")
return
}
@@ -96,10 +84,7 @@ func PostSetup(c *gin.Context) {
// Create root user
hashedPassword, err := common.HashAccountPassword(req.Password)
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "系统错误: " + err.Error(),
})
common.ApiErrorT(c, "System error: {{error}}", map[string]any{"error": err.Error()})
return
}
rootUser := model.User{
@@ -113,10 +98,7 @@ func PostSetup(c *gin.Context) {
}
err = model.DB.Create(&rootUser).Error
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "创建管理员账号失败: " + err.Error(),
})
common.ApiErrorT(c, "Failed to create the administrator account: {{error}}", map[string]any{"error": err.Error()})
return
}
}
@@ -128,19 +110,13 @@ func PostSetup(c *gin.Context) {
// Save operation modes to database for persistence
err = model.UpdateOption("SelfUseModeEnabled", boolToString(req.SelfUseModeEnabled))
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "保存自用模式设置失败: " + err.Error(),
})
common.ApiErrorT(c, "Failed to save the self-use mode setting: {{error}}", map[string]any{"error": err.Error()})
return
}
err = model.UpdateOption("DemoSiteEnabled", boolToString(req.DemoSiteEnabled))
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "保存演示站点模式设置失败: " + err.Error(),
})
common.ApiErrorT(c, "Failed to save the demo site mode setting: {{error}}", map[string]any{"error": err.Error()})
return
}
@@ -153,17 +129,11 @@ func PostSetup(c *gin.Context) {
}
err = model.DB.Create(&setup).Error
if err != nil {
c.JSON(200, gin.H{
"success": false,
"message": "系统初始化失败: " + err.Error(),
})
common.ApiErrorT(c, "Failed to initialize the system: {{error}}", map[string]any{"error": err.Error()})
return
}
c.JSON(200, gin.H{
"success": true,
"message": "系统初始化成功",
})
common.ApiSuccessT(c, "System initialized successfully", nil)
}
func boolToString(b bool) string {