import AddOutlined from "@mui/icons-material/AddOutlined";
import DeleteOutlineOutlined from "@mui/icons-material/DeleteOutlineOutlined";
import FormatListBulletedOutlined from "@mui/icons-material/FormatListBulletedOutlined";
import RefreshOutlined from "@mui/icons-material/RefreshOutlined";
import RestartAltOutlined from "@mui/icons-material/RestartAltOutlined";
import SaveOutlined from "@mui/icons-material/SaveOutlined";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import DialogTitle from "@mui/material/DialogTitle";
import TextField from "@mui/material/TextField";
import Tooltip from "@mui/material/Tooltip";
import { Button } from "@/shared/ui/Button.jsx";
import { DataState } from "@/shared/ui/DataState.jsx";
import { DataTable } from "@/shared/ui/DataTable.jsx";
import { IconButton } from "@/shared/ui/IconButton.jsx";
import { AdminListBody, AdminListPage, AdminListToolbar } from "@/shared/ui/AdminListLayout.jsx";
import { formatMillis } from "@/shared/utils/time.js";
import { useRegionBlockPage } from "@/features/region-blocks/hooks/useRegionBlockPage.js";
import styles from "@/features/region-blocks/region-blocks.module.css";
export function RegionBlockPage() {
const page = useRegionBlockPage();
const columns = buildColumns(page);
const whitelistColumns = buildWhitelistColumns(page);
const userWhitelistColumns = buildUserWhitelistColumns(page);
return (
}
onClick={page.resetDraft}
>
重置
}
onClick={page.reload}
>
刷新
}
variant="primary"
onClick={page.save}
>
保存
>
}
filters={
}
onClick={page.openWhitelistDialog}
>
白名单IP列表
}
/>
地区屏蔽
item.blockId || item.keyword}
/>
IP白名单
item.whitelistId || item.ipAddress}
/>
用户ID/短ID/靓号白名单
item.whitelistId || item.userId}
/>
);
}
function buildColumns(page) {
return [
{
key: "keyword",
label: "屏蔽词",
width: "minmax(220px, 1.2fr)",
render: (item) => ,
},
{
key: "countryCode",
label: "国家码",
width: "minmax(120px, 0.6fr)",
render: (item) => item.countryCode || "保存后解析",
},
{
key: "updatedAtMs",
label: "更新时间",
width: "minmax(180px, 0.85fr)",
render: (item) => (item.updatedAtMs ? formatMillis(item.updatedAtMs) : "-"),
},
{
key: "actions",
label: "操作",
width: "minmax(96px, 0.4fr)",
render: (item) => (
page.removeKeyword(item.keyword)}
>
),
},
];
}
function buildWhitelistColumns(page) {
return [
{
key: "ipAddress",
label: "IP",
width: "minmax(220px, 1fr)",
render: (item) => ,
},
{
key: "updatedAtMs",
label: "更新时间",
width: "minmax(180px, 0.8fr)",
render: (item) => (item.updatedAtMs ? formatMillis(item.updatedAtMs) : "-"),
},
{
key: "actions",
label: "操作",
width: "minmax(96px, 0.4fr)",
render: (item) => (
page.removeIP(item.ipAddress)}
>
),
},
];
}
function buildUserWhitelistColumns(page) {
return [
{
key: "userId",
label: "内部用户ID",
width: "minmax(220px, 1fr)",
render: (item) => ,
},
{
key: "displayUserId",
label: "当前短ID/靓号",
width: "minmax(180px, 0.8fr)",
render: (item) => item.displayUserId || (String(item.whitelistId || "").startsWith("draft-user-") ? "保存后解析" : "-"),
},
{
key: "updatedAtMs",
label: "更新时间",
width: "minmax(180px, 0.8fr)",
render: (item) => (item.updatedAtMs ? formatMillis(item.updatedAtMs) : "-"),
},
{
key: "actions",
label: "操作",
width: "minmax(96px, 0.4fr)",
render: (item) => (
page.removeUserID(item.userId)}
>
),
},
];
}
function buildWhitelistDialogColumns() {
return [
{
key: "ipAddress",
label: "IP",
width: "minmax(220px, 1fr)",
render: (item) => ,
},
{
key: "updatedAtMs",
label: "更新时间",
width: "minmax(180px, 0.8fr)",
render: (item) => (item.updatedAtMs ? formatMillis(item.updatedAtMs) : "-"),
},
];
}
function WhitelistDialog({ page }) {
const columns = buildWhitelistDialogColumns();
return (
);
}
function KeywordCell({ item }) {
return (
{item.keyword}
{item.enabled ? "启用" : "停用"}
);
}