mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	自定义页面增加是否“启用系统自定义页面”选项
This commit is contained in:
		@@ -12,5 +12,5 @@ dbs:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fields:
 | 
					fields:
 | 
				
			||||||
  bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB", "autoTrimDisks" ]
 | 
					  bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB", "autoTrimDisks","enableGlobalPages" ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -231,6 +231,8 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, isLocationOrGr
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// pages
 | 
						// pages
 | 
				
			||||||
 | 
						config.EnableGlobalPages = web.EnableGlobalPages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO 检查forNode参数
 | 
						// TODO 检查forNode参数
 | 
				
			||||||
	if IsNotNull(web.Pages) {
 | 
						if IsNotNull(web.Pages) {
 | 
				
			||||||
		var pages = []*serverconfigs.HTTPPageConfig{}
 | 
							var pages = []*serverconfigs.HTTPPageConfig{}
 | 
				
			||||||
@@ -758,6 +760,22 @@ func (this *HTTPWebDAO) UpdateWebPages(tx *dbs.Tx, webId int64, pagesJSON []byte
 | 
				
			|||||||
	return this.NotifyUpdate(tx, webId)
 | 
						return this.NotifyUpdate(tx, webId)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UpdateGlobalPagesEnabled 设置是否启用系统配置的自定义页面
 | 
				
			||||||
 | 
					func (this *HTTPWebDAO) UpdateGlobalPagesEnabled(tx *dbs.Tx, webId int64, isEnabled bool) error {
 | 
				
			||||||
 | 
						if webId <= 0 {
 | 
				
			||||||
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						err := this.Query(tx).
 | 
				
			||||||
 | 
							Pk(webId).
 | 
				
			||||||
 | 
							Set(HTTPWebField_EnableGlobalPages, isEnabled).
 | 
				
			||||||
 | 
							UpdateQuickly()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return this.NotifyUpdate(tx, webId)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateWebShutdown 更改Shutdown配置
 | 
					// UpdateWebShutdown 更改Shutdown配置
 | 
				
			||||||
func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON []byte) error {
 | 
					func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON []byte) error {
 | 
				
			||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@ const (
 | 
				
			|||||||
	HTTPWebField_Charset            dbs.FieldName = "charset"            // 字符集
 | 
						HTTPWebField_Charset            dbs.FieldName = "charset"            // 字符集
 | 
				
			||||||
	HTTPWebField_Shutdown           dbs.FieldName = "shutdown"           // 临时关闭页面配置
 | 
						HTTPWebField_Shutdown           dbs.FieldName = "shutdown"           // 临时关闭页面配置
 | 
				
			||||||
	HTTPWebField_Pages              dbs.FieldName = "pages"              // 特殊页面
 | 
						HTTPWebField_Pages              dbs.FieldName = "pages"              // 特殊页面
 | 
				
			||||||
 | 
						HTTPWebField_EnableGlobalPages  dbs.FieldName = "enableGlobalPages"  // 是否启用系统配置的自定义页面
 | 
				
			||||||
	HTTPWebField_RedirectToHttps    dbs.FieldName = "redirectToHttps"    // 跳转到HTTPS设置
 | 
						HTTPWebField_RedirectToHttps    dbs.FieldName = "redirectToHttps"    // 跳转到HTTPS设置
 | 
				
			||||||
	HTTPWebField_Indexes            dbs.FieldName = "indexes"            // 首页文件列表
 | 
						HTTPWebField_Indexes            dbs.FieldName = "indexes"            // 首页文件列表
 | 
				
			||||||
	HTTPWebField_MaxRequestBodySize dbs.FieldName = "maxRequestBodySize" // 最大允许的请求内容尺寸
 | 
						HTTPWebField_MaxRequestBodySize dbs.FieldName = "maxRequestBodySize" // 最大允许的请求内容尺寸
 | 
				
			||||||
@@ -57,6 +58,7 @@ type HTTPWeb struct {
 | 
				
			|||||||
	Charset            dbs.JSON `field:"charset"`            // 字符集
 | 
						Charset            dbs.JSON `field:"charset"`            // 字符集
 | 
				
			||||||
	Shutdown           dbs.JSON `field:"shutdown"`           // 临时关闭页面配置
 | 
						Shutdown           dbs.JSON `field:"shutdown"`           // 临时关闭页面配置
 | 
				
			||||||
	Pages              dbs.JSON `field:"pages"`              // 特殊页面
 | 
						Pages              dbs.JSON `field:"pages"`              // 特殊页面
 | 
				
			||||||
 | 
						EnableGlobalPages  bool     `field:"enableGlobalPages"`  // 是否启用系统配置的自定义页面
 | 
				
			||||||
	RedirectToHttps    dbs.JSON `field:"redirectToHttps"`    // 跳转到HTTPS设置
 | 
						RedirectToHttps    dbs.JSON `field:"redirectToHttps"`    // 跳转到HTTPS设置
 | 
				
			||||||
	Indexes            dbs.JSON `field:"indexes"`            // 首页文件列表
 | 
						Indexes            dbs.JSON `field:"indexes"`            // 首页文件列表
 | 
				
			||||||
	MaxRequestBodySize dbs.JSON `field:"maxRequestBodySize"` // 最大允许的请求内容尺寸
 | 
						MaxRequestBodySize dbs.JSON `field:"maxRequestBodySize"` // 最大允许的请求内容尺寸
 | 
				
			||||||
@@ -99,6 +101,7 @@ type HTTPWebOperator struct {
 | 
				
			|||||||
	Charset            any // 字符集
 | 
						Charset            any // 字符集
 | 
				
			||||||
	Shutdown           any // 临时关闭页面配置
 | 
						Shutdown           any // 临时关闭页面配置
 | 
				
			||||||
	Pages              any // 特殊页面
 | 
						Pages              any // 特殊页面
 | 
				
			||||||
 | 
						EnableGlobalPages  any // 是否启用系统配置的自定义页面
 | 
				
			||||||
	RedirectToHttps    any // 跳转到HTTPS设置
 | 
						RedirectToHttps    any // 跳转到HTTPS设置
 | 
				
			||||||
	Indexes            any // 首页文件列表
 | 
						Indexes            any // 首页文件列表
 | 
				
			||||||
	MaxRequestBodySize any // 最大允许的请求内容尺寸
 | 
						MaxRequestBodySize any // 最大允许的请求内容尺寸
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -468,6 +468,31 @@ func (this *HTTPWebService) UpdateHTTPWebPages(ctx context.Context, req *pb.Upda
 | 
				
			|||||||
	return this.Success()
 | 
						return this.Success()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UpdateHTTPWebGlobalPagesEnabled 更改系统自定义页面启用状态
 | 
				
			||||||
 | 
					func (this *HTTPWebService) UpdateHTTPWebGlobalPagesEnabled(ctx context.Context, req *pb.UpdateHTTPWebGlobalPagesEnabledRequest) (*pb.RPCSuccess, error) {
 | 
				
			||||||
 | 
						// 校验请求
 | 
				
			||||||
 | 
						_, userId, err := this.ValidateAdminAndUser(ctx, true)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if userId > 0 {
 | 
				
			||||||
 | 
							// 检查用户权限
 | 
				
			||||||
 | 
							err = models.SharedHTTPWebDAO.CheckUserWeb(nil, userId, req.HttpWebId)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
						err = models.SharedHTTPWebDAO.UpdateGlobalPagesEnabled(tx, req.HttpWebId, req.IsEnabled)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateHTTPWebAccessLog 更改访问日志配置
 | 
					// UpdateHTTPWebAccessLog 更改访问日志配置
 | 
				
			||||||
func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.UpdateHTTPWebAccessLogRequest) (*pb.RPCSuccess, error) {
 | 
					func (this *HTTPWebService) UpdateHTTPWebAccessLog(ctx context.Context, req *pb.UpdateHTTPWebAccessLogRequest) (*pb.RPCSuccess, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103496,7 +103496,7 @@
 | 
				
			|||||||
      "name": "edgeHTTPWebs",
 | 
					      "name": "edgeHTTPWebs",
 | 
				
			||||||
      "engine": "InnoDB",
 | 
					      "engine": "InnoDB",
 | 
				
			||||||
      "charset": "utf8mb4_general_ci",
 | 
					      "charset": "utf8mb4_general_ci",
 | 
				
			||||||
      "definition": "CREATE TABLE `edgeHTTPWebs` (\n  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n  `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n  `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n  `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n  `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n  `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n  `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n  `root` json DEFAULT NULL COMMENT '根目录',\n  `charset` json DEFAULT NULL COMMENT '字符集',\n  `shutdown` json DEFAULT NULL COMMENT '临时关闭页面配置',\n  `pages` json DEFAULT NULL COMMENT '特殊页面',\n  `redirectToHttps` json DEFAULT NULL COMMENT '跳转到HTTPS设置',\n  `indexes` json DEFAULT NULL COMMENT '首页文件列表',\n  `maxRequestBodySize` json DEFAULT NULL COMMENT '最大允许的请求内容尺寸',\n  `requestHeader` json DEFAULT NULL COMMENT '请求Header配置',\n  `responseHeader` json DEFAULT NULL COMMENT '响应Header配置',\n  `accessLog` json DEFAULT NULL COMMENT '访问日志配置',\n  `stat` json DEFAULT NULL COMMENT '统计配置',\n  `gzip` json DEFAULT NULL COMMENT 'Gzip配置(v0.3.2弃用)',\n  `compression` json DEFAULT NULL COMMENT '压缩配置',\n  `cache` json DEFAULT NULL COMMENT '缓存配置',\n  `firewall` json DEFAULT NULL COMMENT '防火墙设置',\n  `locations` json DEFAULT NULL COMMENT '路由规则配置',\n  `websocket` json DEFAULT NULL COMMENT 'Websocket设置',\n  `rewriteRules` json DEFAULT NULL COMMENT '重写规则配置',\n  `hostRedirects` json DEFAULT NULL COMMENT '域名跳转',\n  `fastcgi` json DEFAULT NULL COMMENT 'Fastcgi配置',\n  `auth` json DEFAULT NULL COMMENT '认证策略配置',\n  `webp` json DEFAULT NULL COMMENT 'WebP配置',\n  `remoteAddr` json DEFAULT NULL COMMENT '客户端IP配置',\n  `mergeSlashes` tinyint(1) unsigned DEFAULT '0' COMMENT '是否合并路径中的斜杠',\n  `requestLimit` json DEFAULT NULL COMMENT '请求限制',\n  `requestScripts` json DEFAULT NULL COMMENT '请求脚本',\n  `uam` json DEFAULT NULL COMMENT 'UAM设置',\n  `cc` json DEFAULT NULL COMMENT 'CC设置',\n  `referers` json DEFAULT NULL COMMENT '防盗链设置',\n  `userAgent` json DEFAULT NULL COMMENT 'UserAgent设置',\n  `optimization` json DEFAULT NULL COMMENT '页面优化配置',\n  `hls` json DEFAULT NULL COMMENT 'HLS设置',\n  PRIMARY KEY (`id`),\n  KEY `userId` (`userId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Web'",
 | 
					      "definition": "CREATE TABLE `edgeHTTPWebs` (\n  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n  `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n  `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n  `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n  `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n  `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n  `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n  `root` json DEFAULT NULL COMMENT '根目录',\n  `charset` json DEFAULT NULL COMMENT '字符集',\n  `shutdown` json DEFAULT NULL COMMENT '临时关闭页面配置',\n  `pages` json DEFAULT NULL COMMENT '特殊页面',\n  `enableGlobalPages` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用系统配置的自定义页面',\n  `redirectToHttps` json DEFAULT NULL COMMENT '跳转到HTTPS设置',\n  `indexes` json DEFAULT NULL COMMENT '首页文件列表',\n  `maxRequestBodySize` json DEFAULT NULL COMMENT '最大允许的请求内容尺寸',\n  `requestHeader` json DEFAULT NULL COMMENT '请求Header配置',\n  `responseHeader` json DEFAULT NULL COMMENT '响应Header配置',\n  `accessLog` json DEFAULT NULL COMMENT '访问日志配置',\n  `stat` json DEFAULT NULL COMMENT '统计配置',\n  `gzip` json DEFAULT NULL COMMENT 'Gzip配置(v0.3.2弃用)',\n  `compression` json DEFAULT NULL COMMENT '压缩配置',\n  `cache` json DEFAULT NULL COMMENT '缓存配置',\n  `firewall` json DEFAULT NULL COMMENT '防火墙设置',\n  `locations` json DEFAULT NULL COMMENT '路由规则配置',\n  `websocket` json DEFAULT NULL COMMENT 'Websocket设置',\n  `rewriteRules` json DEFAULT NULL COMMENT '重写规则配置',\n  `hostRedirects` json DEFAULT NULL COMMENT '域名跳转',\n  `fastcgi` json DEFAULT NULL COMMENT 'Fastcgi配置',\n  `auth` json DEFAULT NULL COMMENT '认证策略配置',\n  `webp` json DEFAULT NULL COMMENT 'WebP配置',\n  `remoteAddr` json DEFAULT NULL COMMENT '客户端IP配置',\n  `mergeSlashes` tinyint(1) unsigned DEFAULT '0' COMMENT '是否合并路径中的斜杠',\n  `requestLimit` json DEFAULT NULL COMMENT '请求限制',\n  `requestScripts` json DEFAULT NULL COMMENT '请求脚本',\n  `uam` json DEFAULT NULL COMMENT 'UAM设置',\n  `cc` json DEFAULT NULL COMMENT 'CC设置',\n  `referers` json DEFAULT NULL COMMENT '防盗链设置',\n  `userAgent` json DEFAULT NULL COMMENT 'UserAgent设置',\n  `optimization` json DEFAULT NULL COMMENT '页面优化配置',\n  `hls` json DEFAULT NULL COMMENT 'HLS设置',\n  PRIMARY KEY (`id`),\n  KEY `userId` (`userId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Web'",
 | 
				
			||||||
      "fields": [
 | 
					      "fields": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "name": "id",
 | 
					          "name": "id",
 | 
				
			||||||
@@ -103542,6 +103542,10 @@
 | 
				
			|||||||
          "name": "pages",
 | 
					          "name": "pages",
 | 
				
			||||||
          "definition": "json COMMENT '特殊页面'"
 | 
					          "definition": "json COMMENT '特殊页面'"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "enableGlobalPages",
 | 
				
			||||||
 | 
					          "definition": "tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用系统配置的自定义页面'"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "name": "redirectToHttps",
 | 
					          "name": "redirectToHttps",
 | 
				
			||||||
          "definition": "json COMMENT '跳转到HTTPS设置'"
 | 
					          "definition": "json COMMENT '跳转到HTTPS设置'"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user