2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 16:10:59 +08:00

refactor: 重构 tools.Read 函数

This commit is contained in:
耗子
2023-11-14 02:08:26 +08:00
parent 2b1b58ea2b
commit 83cbae034c
21 changed files with 147 additions and 64 deletions

View File

@@ -162,8 +162,14 @@ func (r *WebsiteController) GetDefaultConfig(ctx http.Context) http.Response {
if check != nil {
return check
}
index := tools.Read("/www/server/openresty/html/index.html")
stop := tools.Read("/www/server/openresty/html/stop.html")
index, err := tools.Read("/www/server/openresty/html/index.html")
if err != nil {
return Error(ctx, http.StatusInternalServerError, err.Error())
}
stop, err := tools.Read("/www/server/openresty/html/stop.html")
if err != nil {
return Error(ctx, http.StatusInternalServerError, err.Error())
}
return Success(ctx, http.Json{
"index": index,
@@ -642,17 +648,18 @@ func (r *WebsiteController) Status(ctx http.Context) http.Response {
website := models.Website{}
if err := facades.Orm().Query().Where("id", idRequest.ID).Get(&website); err != nil {
facades.Log().Info("[面板][WebsiteController] 获取网站信息失败 ", err)
return ErrorSystem(ctx)
}
website.Status = ctx.Request().InputBool("status")
if err := facades.Orm().Query().Save(&website); err != nil {
facades.Log().Info("[面板][WebsiteController] 保存网站配置失败 ", err)
return ErrorSystem(ctx)
}
raw := tools.Read("/www/server/vhost/" + website.Name + ".conf")
raw, err := tools.Read("/www/server/vhost/" + website.Name + ".conf")
if err != nil {
return Error(ctx, http.StatusInternalServerError, err.Error())
}
// 运行目录
rootConfig := tools.Cut(raw, "# root标记位开始\n", "# root标记位结束")