支持在线时间跨天并优化发布与筛选体验

允许在线时段 end 早于 start 表示跨天,统一展示「次日」文案;修复移动端价格区间清空后被 sessionStorage 回写;优化 PC/移动端在线时间控件密度与通栏展示。
This commit is contained in:
yml2213
2026-07-19 17:28:57 +08:00
parent 6450b31129
commit ae79550d78
12 changed files with 410 additions and 136 deletions
+36 -2
View File
@@ -242,14 +242,48 @@ export function assetRegions(item: Listing) {
: []
}
/** 格式化在线时段;end < start 视为跨天,展示「次日」。 */
export function formatOnlineTimeRange(start: string, end: string) {
const startText = String(start || '').trim()
const endText = String(end || '').trim()
if (!startText || !endText) return ''
if (
startText === '全天' ||
endText === '全天' ||
(startText === '00:00' && endText === '23:59')
) {
return '全天'
}
const startMinute = parseClockToMinute(startText)
const endMinute = parseClockToMinute(endText)
const startLabel = formatClockLabel(startText)
const endLabel = formatClockLabel(endText)
if (startMinute !== null && endMinute !== null && endMinute < startMinute) {
return `${startLabel}-次日${endLabel}`
}
return `${startLabel}-${endLabel}`
}
export function getOnlineTimeText(item: Listing) {
const onlineTime = item.asset_summary?.online_time
if (typeof onlineTime !== 'object' || onlineTime === null) return ''
const start = (onlineTime as Record<string, unknown>).start
const end = (onlineTime as Record<string, unknown>).end
if (typeof start !== 'string' || typeof end !== 'string' || !start || !end) return ''
if (start === '全天' || end === '全天' || (start === '00:00' && end === '23:59')) return '全天'
return `${start.replace(':00', '')}-${end.replace(':00', '')}`
return formatOnlineTimeRange(start, end)
}
function parseClockToMinute(value: string) {
const match = /^(\d{1,2}):(\d{2})$/.exec(value.trim())
if (!match) return null
const hour = Number(match[1])
const minute = Number(match[2])
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) return null
return hour * 60 + minute
}
function formatClockLabel(value: string) {
return value.endsWith(':00') ? value.slice(0, -3) : value
}
export function getDailyLoss(item: Listing) {