feat: update workspace pages and global inbox
This commit is contained in:
@@ -24,7 +24,7 @@ export function mapWorkspace(payload: BackendProjectWorkspace, index = 0): Proje
|
||||
|
||||
return {
|
||||
project,
|
||||
channels: payload.channels.map(mapChannel),
|
||||
channels: payload.channels.filter((channel) => channel.type !== 'inbox').map(mapChannel),
|
||||
tags: payload.tags.map((tag) => (tag === 'all' ? '全部' : tag)),
|
||||
recentSessions: payload.recentSessions.map(mapAISession),
|
||||
inbox: payload.inbox.map(mapInbox),
|
||||
@@ -124,12 +124,44 @@ function mapTask(task: BackendTask): TaskItem {
|
||||
owner: task.owner,
|
||||
progress: task.completed ? '100%' : '60%',
|
||||
due: task.due || '未设置',
|
||||
createdAt: formatCreatedAt(task.createdAt),
|
||||
tag: task.tag || (task.completed ? '已完成' : '进行中'),
|
||||
summary: task.summary,
|
||||
completed: task.completed,
|
||||
}
|
||||
}
|
||||
|
||||
function formatCreatedAt(value: string) {
|
||||
const date = parseBackendDate(value)
|
||||
if (!date) return '未知时间'
|
||||
|
||||
const now = new Date()
|
||||
const today = startOfDay(now)
|
||||
const yesterday = new Date(today)
|
||||
yesterday.setDate(today.getDate() - 1)
|
||||
const dateDay = startOfDay(date)
|
||||
const time = `${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
|
||||
if (dateDay.getTime() === today.getTime()) return `今天 ${time}`
|
||||
if (dateDay.getTime() === yesterday.getTime()) return `昨天 ${time}`
|
||||
return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${time}`
|
||||
}
|
||||
|
||||
function parseBackendDate(value: string) {
|
||||
if (!value) return null
|
||||
const normalized = value.includes('T') ? value : `${value.replace(' ', 'T')}Z`
|
||||
const date = new Date(normalized)
|
||||
return Number.isNaN(date.getTime()) ? null : date
|
||||
}
|
||||
|
||||
function startOfDay(value: Date) {
|
||||
return new Date(value.getFullYear(), value.getMonth(), value.getDate())
|
||||
}
|
||||
|
||||
function pad(value: number) {
|
||||
return String(value).padStart(2, '0')
|
||||
}
|
||||
|
||||
function mapAISession(session: BackendAISession): AISession {
|
||||
return {
|
||||
id: session.id,
|
||||
|
||||
Reference in New Issue
Block a user