mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-04-22 15:09:04 +00:00
图片与视频索引优化 #786;修复 #786;修复导出页面打开目录缺失路径的问题;完善朋友圈卡片封面解析
This commit is contained in:
@@ -178,6 +178,7 @@ interface ExportTask {
|
||||
title: string
|
||||
status: TaskStatus
|
||||
settledSessionIds?: string[]
|
||||
sessionOutputPaths?: Record<string, string>
|
||||
createdAt: number
|
||||
startedAt?: number
|
||||
finishedAt?: number
|
||||
@@ -653,6 +654,32 @@ const formatPathBrief = (value: string, maxLength = 52): string => {
|
||||
return `${normalized.slice(0, headLength)}…${normalized.slice(-tailLength)}`
|
||||
}
|
||||
|
||||
const resolveParentDir = (value: string): string => {
|
||||
const normalized = String(value || '').trim()
|
||||
if (!normalized) return ''
|
||||
const noTrailing = normalized.replace(/[\\/]+$/, '')
|
||||
if (!noTrailing) return normalized
|
||||
const lastSlash = Math.max(noTrailing.lastIndexOf('/'), noTrailing.lastIndexOf('\\'))
|
||||
if (lastSlash < 0) return normalized
|
||||
if (lastSlash === 0) return noTrailing.slice(0, 1)
|
||||
if (/^[A-Za-z]:$/.test(noTrailing.slice(0, lastSlash))) {
|
||||
return `${noTrailing.slice(0, lastSlash)}\\`
|
||||
}
|
||||
return noTrailing.slice(0, lastSlash)
|
||||
}
|
||||
|
||||
const resolveTaskOpenDir = (task: ExportTask): string => {
|
||||
const sessionIds = Array.isArray(task.payload.sessionIds) ? task.payload.sessionIds : []
|
||||
if (sessionIds.length === 1) {
|
||||
const onlySessionId = String(sessionIds[0] || '').trim()
|
||||
const outputPath = onlySessionId ? String(task.sessionOutputPaths?.[onlySessionId] || '').trim() : ''
|
||||
if (outputPath) {
|
||||
return resolveParentDir(outputPath) || task.payload.outputDir
|
||||
}
|
||||
}
|
||||
return task.payload.outputDir
|
||||
}
|
||||
|
||||
const formatRecentExportTime = (timestamp?: number, now = Date.now()): string => {
|
||||
if (!timestamp) return ''
|
||||
const diff = Math.max(0, now - timestamp)
|
||||
@@ -2005,7 +2032,14 @@ const TaskCenterModal = memo(function TaskCenterModal({
|
||||
{isPerfExpanded ? '收起详情' : '性能详情'}
|
||||
</button>
|
||||
)}
|
||||
<button className="task-action-btn" onClick={() => task.payload.outputDir && void window.electronAPI.shell.openPath(task.payload.outputDir)}>
|
||||
<button
|
||||
className="task-action-btn"
|
||||
onClick={() => {
|
||||
const openDir = resolveTaskOpenDir(task)
|
||||
if (!openDir) return
|
||||
void window.electronAPI.shell.openPath(openDir)
|
||||
}}
|
||||
>
|
||||
<FolderOpen size={14} /> 目录
|
||||
</button>
|
||||
</div>
|
||||
@@ -5715,6 +5749,12 @@ function ExportPage() {
|
||||
...task,
|
||||
status: 'success',
|
||||
finishedAt: doneAt,
|
||||
sessionOutputPaths: {
|
||||
...(task.sessionOutputPaths || {}),
|
||||
...((result.sessionOutputPaths && typeof result.sessionOutputPaths === 'object')
|
||||
? result.sessionOutputPaths
|
||||
: {})
|
||||
},
|
||||
progress: {
|
||||
...task.progress,
|
||||
current: task.progress.total || next.payload.sessionIds.length,
|
||||
|
||||
Reference in New Issue
Block a user