diff --git a/databi/src/styles/social-v2.css b/databi/src/styles/social-v2.css
index c816211..d6b13f5 100644
--- a/databi/src/styles/social-v2.css
+++ b/databi/src/styles/social-v2.css
@@ -184,22 +184,9 @@
box-shadow: 0 1px 3px rgba(16, 34, 56, 0.12);
}
+/* 自定义区间触发按钮:复用全局 TimeRangeFilter(@/shared/ui),这里只做与预设条的对齐微调。 */
.sbi-custom-range {
- display: inline-flex;
- align-items: center;
- gap: 6px;
margin-left: 6px;
- color: var(--sbi-text-3);
-}
-
-.sbi-custom-range input {
- height: 30px;
- padding: 0 8px;
- border: 1px solid var(--sbi-border);
- border-radius: 7px;
- background: #ffffff;
- color: var(--sbi-text);
- font-size: 12.5px;
}
.sbi-granularity {
diff --git a/src/shared/ui/TimeRangeFilter.jsx b/src/shared/ui/TimeRangeFilter.jsx
index f03744c..76cdfd9 100644
--- a/src/shared/ui/TimeRangeFilter.jsx
+++ b/src/shared/ui/TimeRangeFilter.jsx
@@ -18,7 +18,9 @@ const quickRanges = [
];
const weekLabels = ["一", "二", "三", "四", "五", "六", "日"];
-export function TimeRangeFilter({ className = "", disabled = false, label = "时间", onChange, value }) {
+// withTime=false 时是纯日期区间选择器:隐藏时/分与小时级快捷区间,
+// 选中的开始/结束日分别取当天 00:00:00.000 与 23:59:59.999 的本地毫秒。
+export function TimeRangeFilter({ className = "", disabled = false, label = "时间", onChange, value, withTime = true }) {
const range = useMemo(() => normalizeRange(value), [value]);
const [anchorEl, setAnchorEl] = useState(null);
const [draft, setDraft] = useState(() => range);
@@ -39,7 +41,14 @@ export function TimeRangeFilter({ className = "", disabled = false, label = "时
}
}, [open, range]);
- const displayLabel = useMemo(() => timeRangeLabel(label, range), [label, range]);
+ const formatPart = withTime ? formatRangePart : formatDayPart;
+ const displayLabel = useMemo(
+ () =>
+ !range.startMs && !range.endMs
+ ? label
+ : `${formatPart(range.startMs) || "不限"} - ${formatPart(range.endMs) || "不限"}`,
+ [formatPart, label, range],
+ );
const openPopover = (event) => {
if (disabled) {
@@ -71,15 +80,12 @@ export function TimeRangeFilter({ className = "", disabled = false, label = "时
const changeDay = (day) => {
setDraft((current) => {
const base = dateForField(current, activeField, viewDate);
- const nextDate = new Date(
- day.getFullYear(),
- day.getMonth(),
- day.getDate(),
- base.getHours(),
- base.getMinutes(),
- 0,
- 0,
- );
+ const timeParts = withTime
+ ? [base.getHours(), base.getMinutes(), 0, 0]
+ : activeField === "start"
+ ? [0, 0, 0, 0]
+ : [23, 59, 59, 999];
+ const nextDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), ...timeParts);
return setRangeField(current, activeField, nextDate.getTime());
});
setViewDate(new Date(day.getFullYear(), day.getMonth(), 1));
@@ -105,7 +111,7 @@ export function TimeRangeFilter({ className = "", disabled = false, label = "时
event.stopPropagation();
const nextRange = normalizeRange(draft);
if (nextRange.startMs && nextRange.endMs && nextRange.endMs <= nextRange.startMs) {
- setError("结束时间必须晚于开始时间");
+ setError(withTime ? "结束时间必须晚于开始时间" : "结束日期不能早于开始日期");
return;
}
applyRange(nextRange);
@@ -136,27 +142,31 @@ export function TimeRangeFilter({ className = "", disabled = false, label = "时
onClose={closePopover}
>