From b25f5ae6e9ab8f8a1b2ab0e894663691ffa723e1 Mon Sep 17 00:00:00 2001 From: Rocky <72559939+hkgood@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:37:13 +0800 Subject: [PATCH] Clarify Hint pack save behavior Keep manual editing while making save the only user action and applying changes immediately without a separate publish workflow. --- admin-web/src/api/types.ts | 1 + .../src/features/content/content-page.tsx | 8 +++---- .../features/content/hint-auto-section.tsx | 2 +- admin-web/src/test/content.test.tsx | 21 ++++++++++++++++++- docs/HINT_FEED_MIGRATION.md | 2 +- docs/openapi.yaml | 5 +++-- .../features/admin/models/AdminModels.kt | 1 + .../content/services/ContentService.kt | 2 +- 8 files changed, 32 insertions(+), 10 deletions(-) diff --git a/admin-web/src/api/types.ts b/admin-web/src/api/types.ts index f056c97..2576bb5 100644 --- a/admin-web/src/api/types.ts +++ b/admin-web/src/api/types.ts @@ -17,6 +17,7 @@ export type AdminAuditAction = | "CONTENT_SKILL_ENABLED" | "CONTENT_SKILL_DISABLED" | "CONTENT_HINT_PACK_PUBLISHED" + | "CONTENT_HINT_PACK_SAVED" | "CONTENT_HINT_FEED_SETTINGS_UPDATED" | "CONTENT_HINT_FEED_GENERATED"; diff --git a/admin-web/src/features/content/content-page.tsx b/admin-web/src/features/content/content-page.tsx index 6f14880..524baac 100644 --- a/admin-web/src/features/content/content-page.tsx +++ b/admin-web/src/features/content/content-page.tsx @@ -113,7 +113,7 @@ export function ContentPage() { const saved = await adminApi.updateContentHintPack(locale, payload); setHintVersion(saved.version); setHintText(formatHintPack(saved)); - toast.success(`${locale} Hint pack 已发布`); + toast.success(`${locale} Hint pack 已保存并生效`); } catch (requestError) { toast.error(errorMessage(requestError, "Hint pack 保存失败")); } finally { @@ -129,7 +129,7 @@ export function ContentPage() { setEditingSkill("new")}> @@ -221,7 +221,7 @@ export function ContentPage() { AI Hint packs

- JSON 必须符合 AIHintPack 卡片字段;服务端自动递增 version。 + 可查看并编辑当前生效的 AIHintPack;保存后立即生效,服务端自动递增 version。

@@ -263,7 +263,7 @@ export function ContentPage() { {canEdit ? (
) : null} diff --git a/admin-web/src/features/content/hint-auto-section.tsx b/admin-web/src/features/content/hint-auto-section.tsx index f2a3fea..20c2e7e 100644 --- a/admin-web/src/features/content/hint-auto-section.tsx +++ b/admin-web/src/features/content/hint-auto-section.tsx @@ -239,7 +239,7 @@ export function HintAutoSection({ canEdit }: HintAutoSectionProps) {

TopHub API Key 仅从服务器环境变量读取,不会保存到数据库或返回浏览器。 - 手动 JSON 发布仍保留;下一次自动生成会发布新的双语版本。 + 手动 JSON 编辑与保存仍保留;下一次自动生成会更新双语版本。

{canEdit ? ( diff --git a/admin-web/src/test/content.test.tsx b/admin-web/src/test/content.test.tsx index 35d1618..147aadd 100644 --- a/admin-web/src/test/content.test.tsx +++ b/admin-web/src/test/content.test.tsx @@ -26,7 +26,7 @@ describe("内容管理", () => { expect(screen.queryByRole("button", { name: "新增 Skill" })).toBeNull(); const editor = await screen.findByLabelText("zh JSON"); expect(editor).toHaveProperty("readOnly", true); - expect(screen.queryByRole("button", { name: "保存并立即发布" })).toBeNull(); + expect(screen.queryByRole("button", { name: "保存" })).toBeNull(); expect(screen.queryByRole("button", { name: "立即生成" })).toBeNull(); expect(screen.queryByRole("button", { name: "保存生成设置" })).toBeNull(); }); @@ -90,6 +90,25 @@ describe("内容管理", () => { await waitFor(() => expect(regenerate).toHaveBeenCalledOnce()); }); + + it("SUPER_ADMIN 可编辑并保存当前生效的 Hint pack", async () => { + mockSession("SUPER_ADMIN"); + mockContent(); + const save = vi.spyOn(adminApi, "updateContentHintPack").mockResolvedValue({ + locale: "zh", + generatedAt: "2026-08-21T06:00:00Z", + intervalHours: 12, + version: 3, + cards: [], + }); + window.location.hash = "#/content"; + render(); + + await userEvent.click(await screen.findByRole("button", { name: "保存" })); + + await waitFor(() => expect(save).toHaveBeenCalledOnce()); + expect(await screen.findByText("version 3")).toBeTruthy(); + }); }); function mockSession(role: AdminRole) { diff --git a/docs/HINT_FEED_MIGRATION.md b/docs/HINT_FEED_MIGRATION.md index 6701ea5..deb2a31 100644 --- a/docs/HINT_FEED_MIGRATION.md +++ b/docs/HINT_FEED_MIGRATION.md @@ -34,7 +34,7 @@ The migrated generator runs independently inside OSGAccountServer and publishes: ## Rollback Disable `HINT_FEED_ENABLED` to stop scheduled generation. Published packs remain -available from MySQL and manual publishing remains available. No rollback step +available from MySQL and manual editing/saving remains available. No rollback step depends on or modifies `key.osglab.com`. Provider credentials such as `TOPHUB_API_KEY` stay in environment-backed secret diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 0b7962c..167f2ba 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -808,7 +808,7 @@ paths: security: - adminMtls: [] adminSession: [] - summary: Immediately publish a locale Hint pack and increment its version + summary: Save and immediately apply edits to a locale Hint pack parameters: - $ref: "#/components/parameters/HintLocale" - $ref: "#/components/parameters/AdminCsrf" @@ -819,7 +819,7 @@ paths: schema: { $ref: "#/components/schemas/UpdateAIHintPackRequest" } responses: "200": - description: Published pack + description: Saved active pack content: application/json: schema: { $ref: "#/components/schemas/AdminAIHintPack" } @@ -1249,6 +1249,7 @@ paths: - CONTENT_SKILL_ENABLED - CONTENT_SKILL_DISABLED - CONTENT_HINT_PACK_PUBLISHED + - CONTENT_HINT_PACK_SAVED - CONTENT_HINT_FEED_SETTINGS_UPDATED - CONTENT_HINT_FEED_GENERATED - name: result diff --git a/src/main/kotlin/com/osglab/account/features/admin/models/AdminModels.kt b/src/main/kotlin/com/osglab/account/features/admin/models/AdminModels.kt index cff55ea..7dd380b 100644 --- a/src/main/kotlin/com/osglab/account/features/admin/models/AdminModels.kt +++ b/src/main/kotlin/com/osglab/account/features/admin/models/AdminModels.kt @@ -116,6 +116,7 @@ enum class AdminAuditAction { CONTENT_SKILL_ENABLED, CONTENT_SKILL_DISABLED, CONTENT_HINT_PACK_PUBLISHED, + CONTENT_HINT_PACK_SAVED, CONTENT_HINT_FEED_SETTINGS_UPDATED, CONTENT_HINT_FEED_GENERATED, } diff --git a/src/main/kotlin/com/osglab/account/features/content/services/ContentService.kt b/src/main/kotlin/com/osglab/account/features/content/services/ContentService.kt index 3ce4114..81d803e 100644 --- a/src/main/kotlin/com/osglab/account/features/content/services/ContentService.kt +++ b/src/main/kotlin/com/osglab/account/features/content/services/ContentService.kt @@ -215,7 +215,7 @@ class ContentService( now, audit( actor, - AdminAuditAction.CONTENT_HINT_PACK_PUBLISHED, + AdminAuditAction.CONTENT_HINT_PACK_SAVED, "OFFICIAL_HINT_PACK", locale, requestId,