mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
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:
parent
d79602325d
commit
db10bdd539
@ -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'
|
||||
|
||||
@ -9,6 +9,7 @@ export type MigrationStage =
|
||||
| 'backup_progress'
|
||||
| 'backup_confirmed'
|
||||
| 'migration'
|
||||
| 'migration_completed'
|
||||
| 'completed'
|
||||
| 'error'
|
||||
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ export type MigrationStage =
|
||||
| 'backup_progress'
|
||||
| 'backup_confirmed'
|
||||
| 'migration'
|
||||
| 'migration_completed'
|
||||
| 'completed'
|
||||
| 'error'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user