From 81fa3a25bba25aa050fc8a0967a0ab3ccadb6219 Mon Sep 17 00:00:00 2001 From: zhx Date: Tue, 23 Jun 2026 20:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E7=BD=AE=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/rooms/pages/RoomPinsPage.jsx | 9 ++++++++- src/features/rooms/schema.test.ts | 18 +++++++++++++++++- src/features/rooms/schema.ts | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/features/rooms/pages/RoomPinsPage.jsx b/src/features/rooms/pages/RoomPinsPage.jsx index 64cfd0a..6044651 100644 --- a/src/features/rooms/pages/RoomPinsPage.jsx +++ b/src/features/rooms/pages/RoomPinsPage.jsx @@ -27,6 +27,7 @@ const pinStatusOptions = [ const pinTypeOptions = [ { label: "区域置顶", value: "region" }, + { label: "国家置顶", value: "country" }, { label: "全区置顶", value: "global" }, ]; @@ -323,5 +324,11 @@ function formatRemaining(pin) { } function pinTypeLabel(pinType) { - return pinType === "global" ? "全区置顶" : "区域置顶"; + if (pinType === "global") { + return "全区置顶"; + } + if (pinType === "country") { + return "国家置顶"; + } + return "区域置顶"; } diff --git a/src/features/rooms/schema.test.ts b/src/features/rooms/schema.test.ts index 0d8c796..98ad2da 100644 --- a/src/features/rooms/schema.test.ts +++ b/src/features/rooms/schema.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "vitest"; import { parseForm } from "@/shared/forms/validation"; -import { humanRoomRobotConfigSchema, robotRoomCreateSchema, roomWhitelistSchema } from "./schema"; +import { humanRoomRobotConfigSchema, robotRoomCreateSchema, roomPinCreateSchema, roomWhitelistSchema } from "./schema"; describe("robot room form schema", () => { test("preserves int64 robot user ids as strings", () => { @@ -136,3 +136,19 @@ describe("room whitelist schema", () => { expect(payload.userIds).toEqual(["1001", "325379237278126080"]); }); }); + +describe("room pin create schema", () => { + test("accepts country pin type", () => { + const payload = parseForm(roomPinCreateSchema, { + expiresAtMs: "2026-07-23T19:17", + pinType: "country", + pinnedAtMs: "2026-06-23T19:17", + roomId: "lalu_20d8aba4-23da-44d2-aa6e-876f88", + weight: "0", + }); + + expect(payload.pinType).toBe("country"); + expect(payload.roomId).toBe("lalu_20d8aba4-23da-44d2-aa6e-876f88"); + expect(payload.weight).toBe(0); + }); +}); diff --git a/src/features/rooms/schema.ts b/src/features/rooms/schema.ts index 7f67085..7f3ce48 100644 --- a/src/features/rooms/schema.ts +++ b/src/features/rooms/schema.ts @@ -30,7 +30,7 @@ const commaSeparatedTextListSchema = z const pinTypeSchema = z .string() .trim() - .refine((value) => value === "region" || value === "global", "请选择置顶类型") + .refine((value) => value === "region" || value === "country" || value === "global", "请选择置顶类型") .default("region"); const dateTimeMsSchema = z.union([z.string(), z.number()]).transform((value, context) => { if (typeof value === "number" && Number.isFinite(value)) {