import AddOutlined from "@mui/icons-material/AddOutlined"; import BedroomParentOutlined from "@mui/icons-material/BedroomParentOutlined"; import DeleteOutlineOutlined from "@mui/icons-material/DeleteOutlineOutlined"; import TuneOutlined from "@mui/icons-material/TuneOutlined"; import Autocomplete from "@mui/material/Autocomplete"; import MenuItem from "@mui/material/MenuItem"; import TextField from "@mui/material/TextField"; import Tooltip from "@mui/material/Tooltip"; import { Button } from "@/shared/ui/Button.jsx"; import { AdminFormDialog } from "@/shared/ui/AdminFormDialog.jsx"; import { AdminUserIdentity } from "@/shared/ui/AdminUserIdentity.jsx"; import { DataState } from "@/shared/ui/DataState.jsx"; import { DataTable } from "@/shared/ui/DataTable.jsx"; import { AdminSwitch } from "@/shared/ui/AdminSwitch.jsx"; import { AdminFilterResetButton } from "@/shared/ui/AdminListLayout.jsx"; import { createOptionsColumnFilter } from "@/shared/ui/tableFilters.js"; import { formatMillis } from "@/shared/utils/time.js"; import { giftId, giftOptionLabel, robotLocationLabel, robotOptionLabel, useRobotRoomsPage, } from "@/features/rooms/hooks/useRobotRoomsPage.js"; import styles from "@/features/rooms/rooms.module.css"; const statusOptions = [ { label: "运行中", value: "active" }, { label: "已停止", value: "stopped" }, { label: "全部状态", value: "all" }, ]; const columns = [ { key: "room", label: "房间信息", width: "minmax(280px, 1.4fr)", render: (room) => , }, { key: "owner", label: "房主机器人", width: "minmax(220px, 1fr)", render: (room) => , }, { key: "robots", label: "机器人", width: "minmax(150px, 0.6fr)", render: (room) => ( ), }, { key: "normalRule", label: "普通礼物", width: "minmax(190px, 0.8fr)", render: (room) => ( ), }, { key: "luckyRule", label: "幸运礼物", width: "minmax(220px, 0.9fr)", render: (room) => ( ), }, { key: "behaviorRule", label: "行为", width: "minmax(220px, 0.9fr)", render: (room) => ( ), }, { key: "createdAt", label: "创建时间", width: "minmax(170px, 0.8fr)", render: (room) => formatMillis(room.createdAtMs), }, ]; export function RoomRobotPage() { const page = useRobotRoomsPage(); const items = page.data.items || []; const total = page.data.total || 0; const tableColumns = [ ...columns.map((column) => column.key === "createdAt" ? { ...column, filter: createOptionsColumnFilter({ options: statusOptions, placeholder: "房间状态", value: page.status, onChange: page.changeStatus, }), } : column, ), { key: "status", label: "状态", width: "minmax(112px, 0.5fr)", render: (room) => , }, ]; return (
{page.abilities.canRobotCreate ? (
) : null}
room.roomId} pagination={ total > 0 ? { page: page.page, pageSize: page.data.pageSize || 50, total, onPageChange: page.setPage, } : undefined } />
option.userId === value.userId} loading={page.availableRobotsLoading} noOptionsText="当前无数据" options={page.availableRobots} renderInput={(params) => ( )} renderOption={(props, option) => (
  • )} size="small" value={page.selectedOwnerRobot} onChange={(_, option) => page.selectOwnerRobot(option)} /> option.userId === value.userId} loading={page.availableRobotsLoading} noOptionsText="当前无数据" options={page.candidateRobotOptions} renderInput={(params) => ( 候选机器人} /> )} renderOption={(props, option) => (
  • )} size="small" value={page.selectedCandidateRobots} onChange={(_, options) => page.selectCandidateRobots(options)} />
    page.setForm({ ...page.form, minRobotCount: event.target.value })} /> page.setForm({ ...page.form, maxRobotCount: event.target.value })} />
    giftId(option) === giftId(value)} loading={page.giftOptionsLoading} noOptionsText="当前无数据" options={page.giftOptions} renderInput={(params) => ( 礼物合集} /> )} size="small" value={page.selectedGiftOptions} onChange={(_, options) => page.selectGiftIds("giftIds", options)} /> page.setForm({ ...page.form, normalGiftIntervalMs: event.target.value })} />
    page.setForm({ ...page.form, robotStayMinMs: event.target.value })} /> page.setForm({ ...page.form, robotStayMaxMs: event.target.value })} /> page.setForm({ ...page.form, robotReplaceMinMs: event.target.value })} /> page.setForm({ ...page.form, robotReplaceMaxMs: event.target.value })} /> page.setForm({ ...page.form, maxGiftSenders: event.target.value })} />
    giftId(option) === giftId(value)} loading={page.giftOptionsLoading} noOptionsText="当前无数据" options={page.giftOptions} renderInput={(params) => ( 幸运礼物合集} /> )} size="small" value={page.selectedLuckyGiftOptions} onChange={(_, options) => page.selectGiftIds("luckyGiftIds", options)} />
    page.setForm({ ...page.form, luckyComboMin: event.target.value })} /> page.setForm({ ...page.form, luckyComboMax: event.target.value })} /> page.setForm({ ...page.form, luckyPauseMinMs: event.target.value })} /> page.setForm({ ...page.form, luckyPauseMaxMs: event.target.value })} />
    ); } function HumanConfigPanel({ page }) { const config = page.humanConfig || {}; return (
    真人房间机器人
    {page.humanConfigLoading ? "配置加载中" : page.humanConfigError || (config.enabled ? "已启用" : "未启用")}
    {page.abilities.canRobotUpdate ? (
    ) : null}
    ); } function HumanConfigDialog({ page }) { return (
    page.setHumanConfigForm({ ...page.humanConfigForm, candidateRoomMaxOnline: event.target.value, }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, roomTargetMinOnline: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, roomTargetMaxOnline: event.target.value }) } />
    page.setHumanConfigForm({ ...page.humanConfigForm, normalGiftIntervalMinMs: event.target.value, }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, normalGiftIntervalMaxMs: event.target.value, }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, robotStayMinMs: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, robotStayMaxMs: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, robotReplaceMinMs: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, robotReplaceMaxMs: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, maxGiftSenders: event.target.value }) } />
    page.selectHumanGiftIds("giftIds", options)} />
    page.setHumanConfigForm({ ...page.humanConfigForm, luckyComboMin: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, luckyComboMax: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, luckyPauseMinMs: event.target.value }) } /> page.setHumanConfigForm({ ...page.humanConfigForm, luckyPauseMaxMs: event.target.value }) } />
    page.selectHumanGiftIds("luckyGiftIds", options)} /> page.selectHumanGiftIds("superLuckyGiftIds", options)} /> {page.humanConfigForm.countryLimitEnabled ? : null}
    机器人池自动获取
    {page.humanConfigForm.countryLimitEnabled ? "国家配置启用后,只会读取已配置国家的机器人,并限制每个国家同时进入的真人房数量。" : "系统会读取所有启用的全站机器人,并按机器人账号国家进入同国家真人房间。"}
    ); } function HumanCountryRules({ page }) { const rows = page.humanConfigForm.countryRules || []; return (
    国家进房配置
    {rows.map((rule, index) => (
    page.updateHumanCountryRule(index, { countryCode: event.target.value }) } > {countrySelectOptions(page.countryOptions, rule.countryCode).map((option) => ( {option.label} ))} page.updateHumanCountryRule(index, { maxRoomCount: event.target.value }) } />
    ))} {rows.length === 0 ?
    当前没有国家配置
    : null}
    ); } function GiftAutocomplete({ label, loading, onChange, options, required = false, value }) { return ( giftId(option) === giftId(selected)} loading={loading} noOptionsText="当前无数据" options={options} renderInput={(params) => ( {label} : label} /> )} size="small" value={value} onChange={(_, selected) => onChange(selected)} /> ); } function RobotRoomIdentity({ room }) { return (
    {room.coverUrl ? : }
    {room.title || "-"}
    长ID {room.roomId || "-"}
    短ID {room.roomShortId || "-"}
    ); } function RobotIdentity({ fallbackId = "", openInAppUserDetail = true, user = {} }) { return ( ); } function OwnerRobotOption({ countryLabels, loadingLocation, option, regionLabels }) { return (
    {loadingLocation ? "国家/区域加载中" : robotLocationLabel(option, countryLabels, regionLabels)}
    ); } function RequiredLabel({ children }) { return ( {children} ); } function countrySelectOptions(options = [], currentValue = "") { const current = String(currentValue || "").toUpperCase(); const merged = options.map((option) => ({ label: option.label, value: option.value, })); if (current && !merged.some((option) => option.value === current)) { merged.unshift({ label: current, value: current }); } if (!merged.length) { return current ? [{ label: current, value: current }] : [{ label: "暂无可用国家", value: "" }]; } return merged; } function RobotRoomStatus({ page, room }) { const checked = room.status === "active"; return (
    page.setRoomStatus(room)} />
    ); } function RuleStack({ rows }) { return (
    {rows.map((row) => ( {row} ))}
    ); } function formatSeconds(ms) { const seconds = Math.round(Number(ms || 0) / 1000); return `${seconds.toLocaleString("zh-CN")}秒`; } function formatDurationRange(minMs, maxMs) { return `${formatSeconds(minMs)}-${formatSeconds(maxMs)}`; }