From ffe98f6307971bff268a4f899e5a4c92b0a8581d Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 22 Jun 2026 12:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4Notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs.go | 44 ------------------- docs/swagger.json | 44 ------------------- docs/swagger.yaml | 26 ----------- .../(main)/websites/detail/page-client.tsx | 3 -- internal/apps/openflare/option/logics.go | 7 --- internal/apps/openflare/option/logics_test.go | 12 ----- internal/apps/openflare/option/routers.go | 17 ------- .../202606220002_remove_notice_option.sql | 5 +++ .../202606220002_remove_notice_option.sql | 5 +++ internal/model/openflare_option.go | 1 - .../router/v1/openflare/register_option.go | 1 - 11 files changed, 10 insertions(+), 155 deletions(-) create mode 100644 internal/db/migrator/goose/postgres/202606220002_remove_notice_option.sql create mode 100644 internal/db/migrator/goose/sqlite/202606220002_remove_notice_option.sql diff --git a/docs/docs.go b/docs/docs.go index 902150b8..7edc39a8 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7301,50 +7301,6 @@ const docTemplate = `{ } } }, - "/api/v1/d/notice": { - "get": { - "description": "返回 OpenFlare 控制台公告文本,无需登录", - "produces": [ - "application/json" - ], - "tags": [ - "openflare-option" - ], - "summary": "获取系统公告", - "responses": { - "200": { - "description": "系统公告", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.Any" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "参数错误", - "schema": { - "$ref": "#/definitions/response.Any" - } - }, - "500": { - "description": "内部错误", - "schema": { - "$ref": "#/definitions/response.Any" - } - } - } - } - }, "/api/v1/d/option": { "get": { "security": [ diff --git a/docs/swagger.json b/docs/swagger.json index 44458328..5501c74b 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7294,50 +7294,6 @@ } } }, - "/api/v1/d/notice": { - "get": { - "description": "返回 OpenFlare 控制台公告文本,无需登录", - "produces": [ - "application/json" - ], - "tags": [ - "openflare-option" - ], - "summary": "获取系统公告", - "responses": { - "200": { - "description": "系统公告", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.Any" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "参数错误", - "schema": { - "$ref": "#/definitions/response.Any" - } - }, - "500": { - "description": "内部错误", - "schema": { - "$ref": "#/definitions/response.Any" - } - } - } - } - }, "/api/v1/d/option": { "get": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2f19f658..d2519bda 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -8289,32 +8289,6 @@ paths: summary: 轮换引导令牌 tags: - openflare-node - /api/v1/d/notice: - get: - description: 返回 OpenFlare 控制台公告文本,无需登录 - produces: - - application/json - responses: - "200": - description: 系统公告 - schema: - allOf: - - $ref: '#/definitions/response.Any' - - properties: - data: - type: string - type: object - "400": - description: 参数错误 - schema: - $ref: '#/definitions/response.Any' - "500": - description: 内部错误 - schema: - $ref: '#/definitions/response.Any' - summary: 获取系统公告 - tags: - - openflare-option /api/v1/d/option: get: description: 返回全部非敏感 OpenFlare 配置项,需要管理员权限 diff --git a/frontend/app/(main)/websites/detail/page-client.tsx b/frontend/app/(main)/websites/detail/page-client.tsx index 5a90d29c..7d0e8a47 100644 --- a/frontend/app/(main)/websites/detail/page-client.tsx +++ b/frontend/app/(main)/websites/detail/page-client.tsx @@ -38,7 +38,6 @@ import { buildCertificateLabel, getCertificateStatus, getErrorMessage, - getMatchTypeMeta, isRouteRelatedToManagedDomain, } from '../components/website-utils'; @@ -175,9 +174,7 @@ export function WebsiteDetailPageClient() { ); } - const matchType = getMatchTypeMeta(website.domain); const certificateStatus = certificate ? getCertificateStatus(certificate) : null; - const enabledRoutesCount = relatedRoutes.filter((route) => route.enabled).length; return (
diff --git a/internal/apps/openflare/option/logics.go b/internal/apps/openflare/option/logics.go index 02b42290..0b168fec 100644 --- a/internal/apps/openflare/option/logics.go +++ b/internal/apps/openflare/option/logics.go @@ -143,13 +143,6 @@ func updateOptions(ctx context.Context, options []model.OpenFlareOption) error { return nil } -func getNotice(ctx context.Context) (string, error) { - if err := EnsureInitialized(ctx); err != nil { - return "", err - } - return model.OptionValue("Notice"), nil -} - func getStatus(ctx context.Context, baseAPIPath string) (*statusView, error) { if err := EnsureInitialized(ctx); err != nil { return nil, err diff --git a/internal/apps/openflare/option/logics_test.go b/internal/apps/openflare/option/logics_test.go index ce384f7d..f97baf7b 100644 --- a/internal/apps/openflare/option/logics_test.go +++ b/internal/apps/openflare/option/logics_test.go @@ -73,18 +73,6 @@ func TestUpdateOptionHotReloadsOptionMap(t *testing.T) { assert.Equal(t, "HotReloaded", model.SystemName) } -func TestGetNotice(t *testing.T) { - cleanup := setupOptionTestDB(t) - defer cleanup() - ctx := context.Background() - - require.NoError(t, updateOption(ctx, model.OpenFlareOption{Key: "Notice", Value: "hello"})) - - notice, err := getNotice(ctx) - require.NoError(t, err) - assert.Equal(t, "hello", notice) -} - func TestLookupGeoIPDisabledProvider(t *testing.T) { cleanup := setupOptionTestDB(t) defer cleanup() diff --git a/internal/apps/openflare/option/routers.go b/internal/apps/openflare/option/routers.go index 64838662..a46d0664 100644 --- a/internal/apps/openflare/option/routers.go +++ b/internal/apps/openflare/option/routers.go @@ -32,23 +32,6 @@ func GetStatusHandler(c *gin.Context) { c.JSON(http.StatusOK, response.OK(view)) } -// GetNoticeHandler 获取系统公告。 -// @Summary 获取系统公告 -// @Description 返回 OpenFlare 控制台公告文本,无需登录 -// @Tags openflare-option -// @Produce json -// @Success 200 {object} response.Any{data=string} "系统公告" -// @Failure 400 {object} response.Any "参数错误" -// @Failure 500 {object} response.Any "内部错误" -// @Router /api/v1/d/notice [get] -func GetNoticeHandler(c *gin.Context) { - notice, err := getNotice(c.Request.Context()) - if apiutil.AbortBadRequestOnError(c, err) { - return - } - c.JSON(http.StatusOK, response.OK(notice)) -} - // ListOptionsHandler 列出全部配置项。 // @Summary 列出 OpenFlare 配置项 // @Description 返回全部非敏感 OpenFlare 配置项,需要管理员权限 diff --git a/internal/db/migrator/goose/postgres/202606220002_remove_notice_option.sql b/internal/db/migrator/goose/postgres/202606220002_remove_notice_option.sql new file mode 100644 index 00000000..8ac27973 --- /dev/null +++ b/internal/db/migrator/goose/postgres/202606220002_remove_notice_option.sql @@ -0,0 +1,5 @@ +-- +goose Up +DELETE FROM of_options WHERE key = 'Notice'; + +-- +goose Down +INSERT OR IGNORE INTO of_options (key, value) VALUES ('Notice', ''); diff --git a/internal/db/migrator/goose/sqlite/202606220002_remove_notice_option.sql b/internal/db/migrator/goose/sqlite/202606220002_remove_notice_option.sql new file mode 100644 index 00000000..8ac27973 --- /dev/null +++ b/internal/db/migrator/goose/sqlite/202606220002_remove_notice_option.sql @@ -0,0 +1,5 @@ +-- +goose Up +DELETE FROM of_options WHERE key = 'Notice'; + +-- +goose Down +INSERT OR IGNORE INTO of_options (key, value) VALUES ('Notice', ''); diff --git a/internal/model/openflare_option.go b/internal/model/openflare_option.go index 92971f1f..3b590ef0 100644 --- a/internal/model/openflare_option.go +++ b/internal/model/openflare_option.go @@ -159,7 +159,6 @@ func DefaultOpenFlareOptions() map[string]string { "SMTPPort": strconv.Itoa(SMTPPort), "SMTPAccount": "", "SMTPToken": "", - "Notice": "", "About": "", "Footer": Footer, "HomePageLink": HomePageLink, diff --git a/internal/router/v1/openflare/register_option.go b/internal/router/v1/openflare/register_option.go index 421ed345..4636761f 100644 --- a/internal/router/v1/openflare/register_option.go +++ b/internal/router/v1/openflare/register_option.go @@ -11,7 +11,6 @@ import ( func registerOptionRoutes(apiGroup *gin.RouterGroup) { apiGroup.GET("/status", option.GetStatusHandler) - apiGroup.GET("/notice", option.GetNoticeHandler) optionRoute := apiGroup.Group("/option") optionRoute.Use(apiutil.AdminMiddlewares()...)