feat(workbench): separate stale progress items
This commit is contained in:
@@ -203,6 +203,7 @@
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="progress-row"
|
||||
:class="{ 'has-long-duration-divider': item.hasLongDurationDivider }"
|
||||
@click="openWorkbenchTarget(item)"
|
||||
>
|
||||
<span class="progress-time">
|
||||
@@ -464,12 +465,21 @@ const visibleProgressItems = computed(() => {
|
||||
const rows = Array.isArray(props.workbenchSummary.progressItems)
|
||||
? props.workbenchSummary.progressItems
|
||||
: []
|
||||
return rows.slice(0, 5).map((item) => ({
|
||||
const progressRows = rows.slice(0, 5).map((item) => ({
|
||||
...item,
|
||||
displayTime: formatProgressTime(item?.updatedAt)
|
||||
displayTime: formatProgressTime(item?.updatedAt),
|
||||
isLongDuration: isLongDurationProgress(item?.updatedAt)
|
||||
}))
|
||||
|
||||
return progressRows.map((item, index) => ({
|
||||
...item,
|
||||
hasLongDurationDivider: item.isLongDuration && !progressRows[index - 1]?.isLongDuration
|
||||
}))
|
||||
})
|
||||
|
||||
const LONG_DURATION_DAYS = 10
|
||||
const DAY_MS = 24 * 60 * 60 * 1000
|
||||
|
||||
function formatProgressTime(value) {
|
||||
const text = String(value || '').trim()
|
||||
if (!text) {
|
||||
@@ -484,6 +494,34 @@ function formatProgressTime(value) {
|
||||
return text
|
||||
}
|
||||
|
||||
function parseProgressDate(value) {
|
||||
const text = String(value || '').trim()
|
||||
if (!text) {
|
||||
return null
|
||||
}
|
||||
|
||||
const localDateMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text)
|
||||
if (localDateMatch) {
|
||||
return new Date(
|
||||
Number(localDateMatch[1]),
|
||||
Number(localDateMatch[2]) - 1,
|
||||
Number(localDateMatch[3])
|
||||
)
|
||||
}
|
||||
|
||||
const date = new Date(text)
|
||||
return Number.isNaN(date.getTime()) ? null : date
|
||||
}
|
||||
|
||||
function isLongDurationProgress(value) {
|
||||
const date = parseProgressDate(value)
|
||||
if (!date) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (Date.now() - date.getTime()) / DAY_MS >= LONG_DURATION_DAYS
|
||||
}
|
||||
|
||||
function buildSelectedFileKey(file) {
|
||||
return [file?.name, file?.size, file?.lastModified, file?.type].join('__')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user