返回 oh-my-ppt
progress.ts
根目录 / src / main / io / pptx-import / progress.ts
1 import type { PptxImportProgressPayload } from './types'
2
3 type PptxImportPostPersistStep =
4 | 'session-records'
5 | 'style-extraction'
6 | 'design-contract'
7 | 'design-contract-persist'
8 | 'style-skipped'
9 | 'completed'
10
11 const PPTX_IMPORT_POST_PERSIST_PROGRESS: Record<
12 PptxImportPostPersistStep,
13 Pick<PptxImportProgressPayload, 'stage' | 'progress' | 'label'>
14 > = {
15 'session-records': {
16 stage: 'database',
17 progress: 92,
18 label: '正在写入会话记录'
19 },
20 'style-extraction': {
21 stage: 'database',
22 progress: 94,
23 label: '正在抽取演示风格'
24 },
25 'design-contract': {
26 stage: 'database',
27 progress: 96,
28 label: '正在生成导入设计信息'
29 },
30 'design-contract-persist': {
31 stage: 'database',
32 progress: 98,
33 label: '正在写入设计信息'
34 },
35 'style-skipped': {
36 stage: 'database',
37 progress: 98,
38 label: '已跳过风格提取,正在完成导入'
39 },
40 completed: {
41 stage: 'completed',
42 progress: 100,
43 label: 'PPTX 导入完成'
44 }
45 }
46
47 export function createPptxImportPostPersistProgress(
48 step: PptxImportPostPersistStep,
49 totalPages: number
50 ): PptxImportProgressPayload {
51 return {
52 ...PPTX_IMPORT_POST_PERSIST_PROGRESS[step],
53 totalPages
54 }
55 }
56
56 lines TYPESCRIPT