feat: 优化小程序人生事件详情页、表单页和记录视图页样式
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -167,18 +167,65 @@ const profile = computed(() => store.userProfile || store.registrationData || {}
|
||||
const bottomInset = computed(() => Math.max(0, safeAreaBottom.value))
|
||||
|
||||
const eventYear = computed(() => {
|
||||
const date = displayEvent.value.time || displayEvent.value.date || displayEvent.value.eventDate
|
||||
return date ? String(date).slice(0, 4) : '2025'
|
||||
const event = displayEvent.value
|
||||
const date = event.time || event.date || event.eventDate
|
||||
if (date) return String(date).slice(0, 4)
|
||||
if (!isInvalidDateText(event.eventDateText)) return String(event.eventDateText).slice(0, 4)
|
||||
return '2025'
|
||||
})
|
||||
|
||||
const dateRange = computed(() => {
|
||||
const date = displayEvent.value.time || displayEvent.value.date || displayEvent.value.eventDate
|
||||
if (!date) return '05/20 - 05/28'
|
||||
const month = String(date).slice(5, 7) || '05'
|
||||
const day = String(date).slice(8, 10) || '20'
|
||||
return `${month}/${day} - ${month}/${String(Math.min(28, Number(day) + 8)).padStart(2, '0')}`
|
||||
return formatEventTime(displayEvent.value)
|
||||
})
|
||||
|
||||
const isInvalidDateText = (value) => {
|
||||
return !value || String(value).includes('%')
|
||||
}
|
||||
|
||||
const toDatePart = (value) => {
|
||||
return value ? String(value).split('T')[0] : ''
|
||||
}
|
||||
|
||||
const formatMonthDay = (value) => {
|
||||
const date = toDatePart(value)
|
||||
if (!date) return ''
|
||||
const [, month = '', day = ''] = date.split('-')
|
||||
return month && day ? `${month}/${day}` : ''
|
||||
}
|
||||
|
||||
const formatEventTime = (event = {}) => {
|
||||
const timeMode = event.timeMode || 'date'
|
||||
const start = toDatePart(event.time || event.date || event.eventDate)
|
||||
const end = toDatePart(event.endTime || event.eventEndDate)
|
||||
const text = isInvalidDateText(event.eventDateText) ? '' : String(event.eventDateText || '')
|
||||
|
||||
if (timeMode === 'range') {
|
||||
if (start && end) return `${formatMonthDay(start)} - ${formatMonthDay(end)}`
|
||||
if (text) {
|
||||
const normalized = text.replace(/\s*(至|到|~|—|-)\s*/g, ' - ')
|
||||
const [rawStart, rawEnd] = normalized.split(' - ')
|
||||
if (rawStart && rawEnd) return `${formatMonthDay(rawStart)} - ${formatMonthDay(rawEnd)}`
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
if (timeMode === 'month') {
|
||||
const value = text || start
|
||||
return value ? String(value).slice(0, 7).replace('-', '.') : '2025.05'
|
||||
}
|
||||
|
||||
if (timeMode === 'season') {
|
||||
const value = text || `${String(start || '2025').slice(0, 4)}-spring`
|
||||
const [year, season = 'spring'] = String(value).split('-')
|
||||
const seasonMap = { spring: '春季', summer: '夏季', autumn: '秋季', winter: '冬季' }
|
||||
return `${year} ${seasonMap[season] || '春季'}`
|
||||
}
|
||||
|
||||
if (!start) return '05/20 - 05/28'
|
||||
const first = formatMonthDay(start)
|
||||
return first || '05/20'
|
||||
}
|
||||
|
||||
const primaryTag = computed(() => {
|
||||
if (Array.isArray(displayEvent.value.tags) && displayEvent.value.tags.length) return displayEvent.value.tags[0]
|
||||
const map = { childhood: '童年', highlight: '高光', valley: '低谷', daily_log: '瞬间' }
|
||||
|
||||
Reference in New Issue
Block a user