feat: error handling

This commit is contained in:
hyper
2026-02-27 21:02:33 +08:00
parent 24c797abc6
commit 47c15e933c
2 changed files with 165 additions and 97 deletions
+17 -1
View File
@@ -56,6 +56,8 @@ export interface DeckState {
// 导出状态
isExporting: boolean;
exportProgress: number; // 0-100
exportError: string | null;
// 打印设置
printOrientation: 'portrait' | 'landscape';
@@ -106,6 +108,9 @@ export interface DeckActions {
// 导出操作
setExporting: (exporting: boolean) => void;
exportDeck: () => void;
setExportProgress: (progress: number) => void;
setExportError: (error: string | null) => void;
clearExportError: () => void;
// 打印设置
setPrintOrientation: (orientation: 'portrait' | 'landscape') => void;
@@ -147,6 +152,8 @@ export function createDeckStore(
isLoading: false,
error: null,
isExporting: false,
exportProgress: 0,
exportError: null,
printOrientation: 'portrait',
printOddPageOffsetX: 0,
printOddPageOffsetY: 0
@@ -289,9 +296,15 @@ export function createDeckStore(
const setExporting = (exporting: boolean) => setState({ isExporting: exporting });
const exportDeck = () => {
setState({ isExporting: true });
setState({ isExporting: true, exportProgress: 0, exportError: null });
};
const setExportProgress = (progress: number) => setState({ exportProgress: progress });
const setExportError = (error: string | null) => setState({ exportError: error });
const clearExportError = () => setState({ exportError: null });
const setPrintOrientation = (orientation: 'portrait' | 'landscape') => {
setState({ printOrientation: orientation });
};
@@ -332,6 +345,9 @@ export function createDeckStore(
copyCode,
setExporting,
exportDeck,
setExportProgress,
setExportError,
clearExportError,
setPrintOrientation,
setPrintOddPageOffsetX,
setPrintOddPageOffsetY