feat: error handling
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user