package system import ( "sun-panel/api/api_v1/common/apiReturn" "sun-panel/global" "sun-panel/lib/cmn/systemSetting" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" ) type CustomStyleApi struct{} // 获取自定义 CSS/JS(无需登录) func (a *CustomStyleApi) Get(c *gin.Context) { cfg := systemSetting.CustomStyle{} global.SystemSetting.GetValueByInterface(systemSetting.CUSTOM_STYLE, &cfg) apiReturn.SuccessData(c, cfg) } // 保存自定义 CSS/JS(管理员) func (a *CustomStyleApi) Set(c *gin.Context) { cfg := systemSetting.CustomStyle{} if err := c.ShouldBindBodyWith(&cfg, binding.JSON); err != nil { apiReturn.ErrorParamFomat(c, err.Error()) return } if err := global.SystemSetting.Set(systemSetting.CUSTOM_STYLE, cfg); err != nil { apiReturn.ErrorDatabase(c, err.Error()) return } apiReturn.Success(c) }