mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 23:35:49 +00:00
feat(export): narrow chat window and refine progress settle
This commit is contained in:
@@ -708,9 +708,9 @@ function createSessionChatWindow(sessionId: string) {
|
|||||||
const isDark = nativeTheme.shouldUseDarkColors
|
const isDark = nativeTheme.shouldUseDarkColors
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 980,
|
width: 600,
|
||||||
height: 820,
|
height: 820,
|
||||||
minWidth: 560,
|
minWidth: 420,
|
||||||
minHeight: 560,
|
minHeight: 560,
|
||||||
icon: iconPath,
|
icon: iconPath,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ interface ExportTask {
|
|||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
status: TaskStatus
|
status: TaskStatus
|
||||||
|
settledSessionIds?: string[]
|
||||||
createdAt: number
|
createdAt: number
|
||||||
startedAt?: number
|
startedAt?: number
|
||||||
finishedAt?: number
|
finishedAt?: number
|
||||||
@@ -2277,6 +2278,7 @@ function ExportPage() {
|
|||||||
updateTask(next.id, task => ({
|
updateTask(next.id, task => ({
|
||||||
...task,
|
...task,
|
||||||
status: 'running',
|
status: 'running',
|
||||||
|
settledSessionIds: [],
|
||||||
startedAt: Date.now(),
|
startedAt: Date.now(),
|
||||||
finishedAt: undefined,
|
finishedAt: undefined,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
@@ -2286,6 +2288,7 @@ function ExportPage() {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
progressUnsubscribeRef.current?.()
|
progressUnsubscribeRef.current?.()
|
||||||
|
const settledSessionIdsFromProgress = new Set<string>()
|
||||||
if (next.payload.scope === 'sns') {
|
if (next.payload.scope === 'sns') {
|
||||||
progressUnsubscribeRef.current = window.electronAPI.sns.onExportProgress((payload) => {
|
progressUnsubscribeRef.current = window.electronAPI.sns.onExportProgress((payload) => {
|
||||||
updateTask(next.id, task => {
|
updateTask(next.id, task => {
|
||||||
@@ -2306,10 +2309,34 @@ function ExportPage() {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
progressUnsubscribeRef.current = window.electronAPI.export.onProgress((payload: ExportProgress) => {
|
progressUnsubscribeRef.current = window.electronAPI.export.onProgress((payload: ExportProgress) => {
|
||||||
|
const now = Date.now()
|
||||||
|
const currentSessionId = String(payload.currentSessionId || '').trim()
|
||||||
|
if (payload.phase === 'complete' && currentSessionId && !settledSessionIdsFromProgress.has(currentSessionId)) {
|
||||||
|
settledSessionIdsFromProgress.add(currentSessionId)
|
||||||
|
const phaseLabel = String(payload.phaseLabel || '')
|
||||||
|
const isFailed = phaseLabel.includes('失败')
|
||||||
|
if (!isFailed) {
|
||||||
|
const contentTypes = next.payload.contentType
|
||||||
|
? [next.payload.contentType]
|
||||||
|
: (next.payload.options ? inferContentTypesFromOptions(next.payload.options) : [])
|
||||||
|
markSessionExported([currentSessionId], now)
|
||||||
|
if (contentTypes.length > 0) {
|
||||||
|
markContentExported([currentSessionId], contentTypes, now)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateTask(next.id, task => {
|
updateTask(next.id, task => {
|
||||||
if (task.status !== 'running') return task
|
if (task.status !== 'running') return task
|
||||||
const now = Date.now()
|
|
||||||
const performance = applyProgressToTaskPerformance(task, payload, now)
|
const performance = applyProgressToTaskPerformance(task, payload, now)
|
||||||
|
const settledSessionIds = task.settledSessionIds || []
|
||||||
|
const nextSettledSessionIds = (
|
||||||
|
payload.phase === 'complete' &&
|
||||||
|
currentSessionId &&
|
||||||
|
!settledSessionIds.includes(currentSessionId)
|
||||||
|
)
|
||||||
|
? [...settledSessionIds, currentSessionId]
|
||||||
|
: settledSessionIds
|
||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
progress: {
|
progress: {
|
||||||
@@ -2321,6 +2348,7 @@ function ExportPage() {
|
|||||||
phaseProgress: payload.phaseProgress || 0,
|
phaseProgress: payload.phaseProgress || 0,
|
||||||
phaseTotal: payload.phaseTotal || 0
|
phaseTotal: payload.phaseTotal || 0
|
||||||
},
|
},
|
||||||
|
settledSessionIds: nextSettledSessionIds,
|
||||||
performance
|
performance
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -2470,6 +2498,7 @@ function ExportPage() {
|
|||||||
id: createTaskId(),
|
id: createTaskId(),
|
||||||
title,
|
title,
|
||||||
status: 'queued',
|
status: 'queued',
|
||||||
|
settledSessionIds: [],
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
payload: {
|
payload: {
|
||||||
sessionIds: exportDialog.sessionIds,
|
sessionIds: exportDialog.sessionIds,
|
||||||
@@ -2586,7 +2615,9 @@ function ExportPage() {
|
|||||||
const set = new Set<string>()
|
const set = new Set<string>()
|
||||||
for (const task of tasks) {
|
for (const task of tasks) {
|
||||||
if (task.status !== 'running') continue
|
if (task.status !== 'running') continue
|
||||||
|
const settled = new Set(task.settledSessionIds || [])
|
||||||
for (const id of task.payload.sessionIds) {
|
for (const id of task.payload.sessionIds) {
|
||||||
|
if (settled.has(id)) continue
|
||||||
set.add(id)
|
set.add(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user