import AddOutlined from "@mui/icons-material/AddOutlined"; import DeleteOutlineOutlined from "@mui/icons-material/DeleteOutlineOutlined"; import EditOutlined from "@mui/icons-material/EditOutlined"; import ImageOutlined from "@mui/icons-material/ImageOutlined"; import MenuItem from "@mui/material/MenuItem"; import TextField from "@mui/material/TextField"; import { useMemo } from "react"; import { useSplashScreenConfigPage } from "@/features/app-config/hooks/useSplashScreenConfigPage.js"; import styles from "@/features/app-config/app-config.module.css"; import { AdminFormDialog, AdminFormFieldGrid, AdminFormSection, AdminFormSwitchField, } from "@/shared/ui/AdminFormDialog.jsx"; import { AdminActionIconButton, AdminListBody, AdminListPage, AdminListToolbar, AdminRowActions, } from "@/shared/ui/AdminListLayout.jsx"; import { DataState } from "@/shared/ui/DataState.jsx"; import { DataTable } from "@/shared/ui/DataTable.jsx"; import { createRegionColumnFilter } from "@/shared/ui/RegionFilterControl.jsx"; import { RegionSelect } from "@/shared/ui/RegionSelect.jsx"; import { createOptionsColumnFilter, createTextColumnFilter } from "@/shared/ui/tableFilters.js"; import { TimeRangeFilter } from "@/shared/ui/TimeRangeFilter.jsx"; import { UploadField } from "@/shared/ui/UploadField.jsx"; import { formatMillis } from "@/shared/utils/time.js"; const statusOptions = [ ["", "全部状态"], ["active", "启用"], ["disabled", "关闭"], ["expired", "过期"], ]; const platformOptions = [ ["", "全部平台"], ["android", "安卓"], ["ios", "iOS"], ]; export function SplashScreenConfigPage() { const page = useSplashScreenConfigPage(); const items = page.data.items || []; const columns = useMemo(() => splashScreenColumns(page), [page]); return ( ) : null } /> item.id} />
page.setForm({ coverUrl })} />
page.setForm({ splashType: event.target.value })} > H5 APP page.setForm({ platform: event.target.value })} > 安卓 iOS page.setForm({ param: event.target.value })} /> page.setForm({ regionId })} /> page.setForm({ countryCode })} /> page.setForm({ sortOrder: event.target.value })} /> page.setForm({ displayDurationMs: event.target.value })} /> page.setForm({ status: checked ? "active" : "disabled" })} /> page.setForm({ endsAtMs: range.endMs, startsAtMs: range.startMs }) } /> page.setForm({ description: event.target.value })} />
); } function splashScreenColumns(page) { const columns = [ { key: "cover", label: "封面图", render: (item) => , width: "minmax(96px, 0.45fr)", }, { key: "target", label: "类型 / 参数", render: (item) => , filter: createTextColumnFilter({ placeholder: "搜索参数、国家、描述", value: page.keyword, onChange: page.setKeyword, }), width: "minmax(260px, 1.3fr)", }, { key: "platform", label: "平台", render: (item) => platformLabel(item.platform), filter: createOptionsColumnFilter({ options: platformOptions, placeholder: "搜索平台", value: page.platform, onChange: page.setPlatform, }), width: "minmax(110px, 0.6fr)", }, { key: "status", label: "状态", render: (item) => , filter: createOptionsColumnFilter({ options: statusOptions, placeholder: "搜索状态", value: page.status, onChange: page.setStatus, }), width: "minmax(100px, 0.55fr)", }, { key: "region", label: "区域", render: (item) => regionLabel(page.regionOptions, item.regionId), filter: createRegionColumnFilter({ loading: page.loadingRegions, options: page.regionOptions, value: page.regionId, onChange: page.setRegionId, }), width: "minmax(150px, 0.8fr)", }, { key: "country", label: "国家", render: (item) => countryLabel(page.countryOptions, item.countryCode), filter: createOptionsColumnFilter({ emptyLabel: "全部国家", loading: page.loadingCountries, options: page.countryOptions, placeholder: "搜索国家", value: page.countryCode, onChange: page.setCountryCode, }), width: "minmax(150px, 0.8fr)", }, { key: "sortOrder", label: "排序", width: "minmax(80px, 0.4fr)", }, { key: "displayDurationMs", label: "展示时长", render: (item) => durationLabel(item.displayDurationMs), width: "minmax(110px, 0.55fr)", }, { key: "deliveryTime", label: "投放时间", render: (item) => deliveryTimeLabel(item.startsAtMs, item.endsAtMs), width: "minmax(220px, 1fr)", }, { key: "description", label: "描述", render: (item) => item.description || "-", width: "minmax(180px, 0.9fr)", }, { key: "updatedAtMs", label: "更新时间", render: (item) => formatMillis(item.updatedAtMs), width: "minmax(160px, 0.8fr)", }, ]; if (!page.abilities.canUpdate) { return columns; } return [ ...columns, { key: "actions", label: "操作", render: (item) => , width: "minmax(96px, 0.45fr)", }, ]; } function SplashCover({ src }) { if (!src) { return ( ); } return ; } function SplashActions({ item, page }) { const deleting = page.loadingAction === `delete:${item.id}`; return ( page.openEdit(item)} > page.removeSplashScreen(item)} > ); } function CountrySelect({ className, disabled, emptyLabel, label = "国家", onChange, options, value }) { return ( onChange(event.target.value)} > {emptyLabel} {options.map((option) => ( {option.label} ))} ); } function Stack({ primary, secondary }) { return (
{primary || "-"} {secondary || "-"}
); } function StatusBadge({ status }) { const tone = status === "active" ? "succeeded" : status === "expired" ? "warning" : "stopped"; return ( {statusLabel(status)} ); } function typeLabel(value) { return value === "app" ? "APP" : "H5"; } function platformLabel(value) { if (value === "android") { return "安卓"; } if (value === "ios") { return "iOS"; } return value || "-"; } function deliveryTimeLabel(startsAtMs, endsAtMs) { const start = startsAtMs ? formatMillis(startsAtMs) : "不限"; const end = endsAtMs ? formatMillis(endsAtMs) : "不限"; return `${start} - ${end}`; } function statusLabel(status) { if (status === "active") { return "启用"; } if (status === "expired") { return "过期"; } return "关闭"; } function durationLabel(value) { const duration = Number(value || 3000); if (!Number.isFinite(duration) || duration < 0) { return "3000 ms"; } return `${duration} ms`; } function regionLabel(options, value) { if (!value) { return "全部区域"; } return options.find((option) => option.value === String(value))?.label || `区域 ${value}`; } function countryLabel(options, value) { if (!value) { return "全部国家"; } return options.find((option) => option.value === value)?.label || value; }