房间置顶
This commit is contained in:
parent
889e75f6a1
commit
81fa3a25bb
@ -27,6 +27,7 @@ const pinStatusOptions = [
|
|||||||
|
|
||||||
const pinTypeOptions = [
|
const pinTypeOptions = [
|
||||||
{ label: "区域置顶", value: "region" },
|
{ label: "区域置顶", value: "region" },
|
||||||
|
{ label: "国家置顶", value: "country" },
|
||||||
{ label: "全区置顶", value: "global" },
|
{ label: "全区置顶", value: "global" },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -323,5 +324,11 @@ function formatRemaining(pin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pinTypeLabel(pinType) {
|
function pinTypeLabel(pinType) {
|
||||||
return pinType === "global" ? "全区置顶" : "区域置顶";
|
if (pinType === "global") {
|
||||||
|
return "全区置顶";
|
||||||
|
}
|
||||||
|
if (pinType === "country") {
|
||||||
|
return "国家置顶";
|
||||||
|
}
|
||||||
|
return "区域置顶";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { parseForm } from "@/shared/forms/validation";
|
import { parseForm } from "@/shared/forms/validation";
|
||||||
import { humanRoomRobotConfigSchema, robotRoomCreateSchema, roomWhitelistSchema } from "./schema";
|
import { humanRoomRobotConfigSchema, robotRoomCreateSchema, roomPinCreateSchema, roomWhitelistSchema } from "./schema";
|
||||||
|
|
||||||
describe("robot room form schema", () => {
|
describe("robot room form schema", () => {
|
||||||
test("preserves int64 robot user ids as strings", () => {
|
test("preserves int64 robot user ids as strings", () => {
|
||||||
@ -136,3 +136,19 @@ describe("room whitelist schema", () => {
|
|||||||
expect(payload.userIds).toEqual(["1001", "325379237278126080"]);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const commaSeparatedTextListSchema = z
|
|||||||
const pinTypeSchema = z
|
const pinTypeSchema = z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.refine((value) => value === "region" || value === "global", "请选择置顶类型")
|
.refine((value) => value === "region" || value === "country" || value === "global", "请选择置顶类型")
|
||||||
.default("region");
|
.default("region");
|
||||||
const dateTimeMsSchema = z.union([z.string(), z.number()]).transform((value, context) => {
|
const dateTimeMsSchema = z.union([z.string(), z.number()]).transform((value, context) => {
|
||||||
if (typeof value === "number" && Number.isFinite(value)) {
|
if (typeof value === "number" && Number.isFinite(value)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user