通知弹窗列表时间改为显示完整的时期和时间
This commit is contained in:
parent
a3d6c55615
commit
abcba30ec7
@ -41,6 +41,7 @@ export interface ToDoItem {
|
||||
allocated_to: string | null
|
||||
assigned_by: string | null
|
||||
creation: string
|
||||
modified: string
|
||||
}
|
||||
|
||||
export interface ActivityItem {
|
||||
|
||||
@ -51,19 +51,9 @@ const loadActivities = async () => {
|
||||
const formatTime = (ts: string): string => {
|
||||
if (!ts) return ''
|
||||
const d = new Date(ts.replace(/-/g, '/').replace(/[TZ]/g, ' ').replace(/\.[0-9]*/, ''))
|
||||
const diff = Math.floor((Date.now() - d.getTime()) / 1000)
|
||||
const day = Math.floor(diff / 86400)
|
||||
if (isNaN(day) || day < 0) return ''
|
||||
if (day === 0) {
|
||||
if (diff < 60) return t('just now')
|
||||
if (diff < 3600) return t('{0} minutes ago', { 0: Math.floor(diff / 60).toString() })
|
||||
return t('{0} hours ago', { 0: Math.floor(diff / 3600).toString() })
|
||||
}
|
||||
if (day === 1) return t('yesterday')
|
||||
if (day < 7) return t('{0} days ago', { 0: day.toString() })
|
||||
if (day < 30) return t('{0} weeks ago', { 0: Math.floor(day / 7).toString() })
|
||||
if (day < 365) return t('{0} months ago', { 0: Math.floor(day / 30).toString() })
|
||||
return t('{0} years ago', { 0: Math.floor(day / 365).toString() })
|
||||
if (isNaN(d.getTime())) return ''
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
||||
}
|
||||
|
||||
const handleClick = (item: ActivityItem) => {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<span class="priority-dot" :class="priorityClass(item.priority)" />
|
||||
{{ item.title }}
|
||||
</div>
|
||||
<div class="item-time text-muted">{{ formatDate(item.date) }}</div>
|
||||
<div class="item-time text-muted">{{ formatDate(item.modified) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
@ -59,16 +59,10 @@ const priorityClass = (p: string | null): string => {
|
||||
|
||||
const formatDate = (d: string | null): string => {
|
||||
if (!d) return ''
|
||||
const date = new Date(d)
|
||||
const now = new Date()
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
|
||||
const target = new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
||||
const diff = Math.floor((target.getTime() - today.getTime()) / 86400000)
|
||||
if (diff === 0) return t('Today')
|
||||
if (diff === 1) return t('Tomorrow')
|
||||
if (diff === -1) return t('Yesterday')
|
||||
if (diff < -1) return t('{0} days ago', { 0: Math.abs(diff).toString() })
|
||||
return date.toLocaleDateString()
|
||||
const date = new Date(d.replace(/-/g, '/'))
|
||||
if (isNaN(date.getTime())) return ''
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||
}
|
||||
|
||||
const handleClick = (item: ToDoItem) => {
|
||||
|
||||
@ -40,7 +40,7 @@ def get_todo_list(limit=20):
|
||||
return jingrow.get_list(
|
||||
"ToDo",
|
||||
fields=["name", "title", "description", "status", "date", "priority",
|
||||
"reference_type", "reference_name", "allocated_to", "assigned_by", "creation"],
|
||||
"reference_type", "reference_name", "allocated_to", "assigned_by", "creation", "modified"],
|
||||
filters=[
|
||||
["ToDo", "status", "in", ["Todo", "In Progress"]],
|
||||
["ToDo", "allocated_to", "=", jingrow.session.user],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user