mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 05:39:05 +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 { cn } from '@cherrystudio/ui/utils/index'
|
||||||
import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react'
|
import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export type MigrationStage =
|
|||||||
| 'backup_progress'
|
| 'backup_progress'
|
||||||
| 'backup_confirmed'
|
| 'backup_confirmed'
|
||||||
| 'migration'
|
| 'migration'
|
||||||
|
| 'migration_completed'
|
||||||
| 'completed'
|
| 'completed'
|
||||||
| 'error'
|
| 'error'
|
||||||
|
|
||||||
|
|||||||
@ -242,9 +242,9 @@ export function registerMigrationIpcHandlers(): void {
|
|||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
updateProgress({
|
updateProgress({
|
||||||
stage: 'completed',
|
stage: 'migration_completed',
|
||||||
overallProgress: 100,
|
overallProgress: 100,
|
||||||
currentMessage: 'Migration completed successfully! Click restart to continue.',
|
currentMessage: 'Migration completed successfully! Please confirm to continue.',
|
||||||
migrators: currentProgress.migrators.map((m) => ({
|
migrators: currentProgress.migrators.map((m) => ({
|
||||||
...m,
|
...m,
|
||||||
status: 'completed'
|
status: 'completed'
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { MigrationIpcChannels } from './types'
|
|||||||
const logger = loggerService.withContext('MigrationApp')
|
const logger = loggerService.withContext('MigrationApp')
|
||||||
|
|
||||||
const MigrationApp: React.FC = () => {
|
const MigrationApp: React.FC = () => {
|
||||||
const { progress, lastError } = useMigrationProgress()
|
const { progress, lastError, confirmComplete } = useMigrationProgress()
|
||||||
const actions = useMigrationActions()
|
const actions = useMigrationActions()
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ const MigrationApp: React.FC = () => {
|
|||||||
case 'backup_confirmed':
|
case 'backup_confirmed':
|
||||||
return 1
|
return 1
|
||||||
case 'migration':
|
case 'migration':
|
||||||
|
case 'migration_completed':
|
||||||
return 2
|
return 2
|
||||||
case 'completed':
|
case 'completed':
|
||||||
return 3
|
return 3
|
||||||
@ -160,6 +161,13 @@ const MigrationApp: React.FC = () => {
|
|||||||
<Button disabled>迁移进行中...</Button>
|
<Button disabled>迁移进行中...</Button>
|
||||||
</ButtonRow>
|
</ButtonRow>
|
||||||
)
|
)
|
||||||
|
case 'migration_completed':
|
||||||
|
return (
|
||||||
|
<ButtonRow>
|
||||||
|
<div></div>
|
||||||
|
<Button onClick={confirmComplete}>确定</Button>
|
||||||
|
</ButtonRow>
|
||||||
|
)
|
||||||
case 'completed':
|
case 'completed':
|
||||||
return (
|
return (
|
||||||
<ButtonRow>
|
<ButtonRow>
|
||||||
@ -251,7 +259,7 @@ const MigrationApp: React.FC = () => {
|
|||||||
</InfoCard>
|
</InfoCard>
|
||||||
<ProgressContainer>
|
<ProgressContainer>
|
||||||
<Progress
|
<Progress
|
||||||
percent={Math.round(progress.overallProgress * 100)}
|
percent={Math.round(progress.overallProgress)}
|
||||||
strokeColor={getProgressColor()}
|
strokeColor={getProgressColor()}
|
||||||
trailColor="#f0f0f0"
|
trailColor="#f0f0f0"
|
||||||
/>
|
/>
|
||||||
@ -262,6 +270,21 @@ const MigrationApp: React.FC = () => {
|
|||||||
</div>
|
</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' && (
|
{progress.stage === 'completed' && (
|
||||||
<InfoCard variant="success">
|
<InfoCard variant="success">
|
||||||
<InfoTitle>迁移完成</InfoTitle>
|
<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
|
// Stage helpers
|
||||||
const isInProgress = progress.stage === 'migration'
|
const isInProgress = progress.stage === 'migration'
|
||||||
const isCompleted = progress.stage === 'completed'
|
const isCompleted = progress.stage === 'completed'
|
||||||
@ -68,7 +77,8 @@ export function useMigrationProgress() {
|
|||||||
isInProgress,
|
isInProgress,
|
||||||
isCompleted,
|
isCompleted,
|
||||||
isError,
|
isError,
|
||||||
canCancel
|
canCancel,
|
||||||
|
confirmComplete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export type MigrationStage =
|
|||||||
| 'backup_progress'
|
| 'backup_progress'
|
||||||
| 'backup_confirmed'
|
| 'backup_confirmed'
|
||||||
| 'migration'
|
| 'migration'
|
||||||
|
| 'migration_completed'
|
||||||
| 'completed'
|
| 'completed'
|
||||||
| 'error'
|
| 'error'
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user