feat: enhance migration process with new 'migration_completed' stage

- Added 'migration_completed' stage to the migration process for better tracking of completion.
- Updated relevant components and hooks to handle the new stage, including UI changes to confirm migration completion.
- Adjusted messages and progress indicators to reflect the new stage in the migration workflow.
This commit is contained in:
fullex 2025-11-20 20:32:33 +08:00
parent d79602325d
commit db10bdd539
6 changed files with 42 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import { Button, buttonVariants } from '@cherrystudio/ui/components/primitives/button'
import type { Button } from '@cherrystudio/ui/components/primitives/button'
import { buttonVariants } from '@cherrystudio/ui/components/primitives/button'
import { cn } from '@cherrystudio/ui/utils/index'
import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react'
import * as React from 'react'

View File

@ -9,6 +9,7 @@ export type MigrationStage =
| 'backup_progress'
| 'backup_confirmed'
| 'migration'
| 'migration_completed'
| 'completed'
| 'error'

View File

@ -242,9 +242,9 @@ export function registerMigrationIpcHandlers(): void {
if (result.success) {
updateProgress({
stage: 'completed',
stage: 'migration_completed',
overallProgress: 100,
currentMessage: 'Migration completed successfully! Click restart to continue.',
currentMessage: 'Migration completed successfully! Please confirm to continue.',
migrators: currentProgress.migrators.map((m) => ({
...m,
status: 'completed'

View File

@ -14,7 +14,7 @@ import { MigrationIpcChannels } from './types'
const logger = loggerService.withContext('MigrationApp')
const MigrationApp: React.FC = () => {
const { progress, lastError } = useMigrationProgress()
const { progress, lastError, confirmComplete } = useMigrationProgress()
const actions = useMigrationActions()
const [isLoading, setIsLoading] = useState(false)
@ -60,6 +60,7 @@ const MigrationApp: React.FC = () => {
case 'backup_confirmed':
return 1
case 'migration':
case 'migration_completed':
return 2
case 'completed':
return 3
@ -160,6 +161,13 @@ const MigrationApp: React.FC = () => {
<Button disabled>...</Button>
</ButtonRow>
)
case 'migration_completed':
return (
<ButtonRow>
<div></div>
<Button onClick={confirmComplete}></Button>
</ButtonRow>
)
case 'completed':
return (
<ButtonRow>
@ -251,7 +259,7 @@ const MigrationApp: React.FC = () => {
</InfoCard>
<ProgressContainer>
<Progress
percent={Math.round(progress.overallProgress * 100)}
percent={Math.round(progress.overallProgress)}
strokeColor={getProgressColor()}
trailColor="#f0f0f0"
/>
@ -262,6 +270,21 @@ const MigrationApp: React.FC = () => {
</div>
)}
{progress.stage === 'migration_completed' && (
<div style={{ width: '100%', maxWidth: '600px', margin: '0 auto' }}>
<InfoCard variant="success">
<InfoTitle></InfoTitle>
<InfoDescription></InfoDescription>
</InfoCard>
<ProgressContainer>
<Progress percent={100} strokeColor={getProgressColor()} trailColor="#f0f0f0" />
</ProgressContainer>
<div style={{ marginTop: '20px', height: '200px', overflowY: 'auto' }}>
<MigratorProgressList migrators={progress.migrators} overallProgress={progress.overallProgress} />
</div>
</div>
)}
{progress.stage === 'completed' && (
<InfoCard variant="success">
<InfoTitle></InfoTitle>

View File

@ -56,6 +56,15 @@ export function useMigrationProgress() {
}
}, [])
// Local state transition for confirming migration completion (frontend only)
const confirmComplete = useCallback(() => {
setProgress((prev) => ({
...prev,
stage: 'completed',
currentMessage: 'Migration completed successfully! Click restart to continue.'
}))
}, [])
// Stage helpers
const isInProgress = progress.stage === 'migration'
const isCompleted = progress.stage === 'completed'
@ -68,7 +77,8 @@ export function useMigrationProgress() {
isInProgress,
isCompleted,
isError,
canCancel
canCancel,
confirmComplete
}
}

View File

@ -9,6 +9,7 @@ export type MigrationStage =
| 'backup_progress'
| 'backup_confirmed'
| 'migration'
| 'migration_completed'
| 'completed'
| 'error'