Skip to content

Commit

Permalink
💡 docs(pro-editor): 补充store 相关公共方法注释
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jun 14, 2023
1 parent 62238b9 commit 77ccfe1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/ProEditor/store/slices/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,26 @@ const initialCanvasState: CanvasSliceState = {
};

export interface CanvasPublicAction {
/**
* 取消选中 Canvas
*/
deselectCanvas: () => void;
/**
* 更新视口
* @param viewPort - 视口的部分属性
*/
updateViewport: (viewPort: Partial<Viewport>) => void;
/**
* 更新 Canvas 交互状态
* @param interaction - 交互状态
* @param action - 用户操作的部分参数
*/
updateCanvasInteraction: (
interaction: InteractStatus,
action?: Partial<UserActionParams>,
) => void;
}

export interface CanvasSlice extends CanvasPublicAction, CanvasSliceState {
internalUpdateCanvasInteract: (
interaction: InteractStatus,
Expand Down
12 changes: 12 additions & 0 deletions src/ProEditor/store/slices/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,24 @@ export interface ActionOptions {
payload?: Partial<UserActionParams>;
}

/**
* 公共配置操作接口
*/
export interface ConfigPublicAction {
/**
* 导出配置
*/
exportConfig: () => void;
/**
* 重置配置
*/
resetConfig: () => void;
/**
* 更新配置
* @template T - 配置对象类型
* @param {Partial<T>} config - 需要更新的配置对象
* @param {ActionOptions} [options] - 配置项
*/
updateConfig: <T>(config: Partial<T>, options?: ActionOptions) => void;
}

Expand Down
1 change: 1 addition & 0 deletions src/ProEditor/store/slices/configPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ConfigPanelPublicAction {
*/
togglePanelExpand: (nextExpandState?: boolean) => void;
}

export interface ConfigPanelSlice extends ConfigPanelPublicAction {
updatePanelPosition: (position: Partial<Position>) => void;
updatePanelSize: (sizeDelta: Partial<NumberSize>) => void;
Expand Down
16 changes: 15 additions & 1 deletion src/ProEditor/store/slices/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ const initialGeneralState: GeneralSliceState = {

// ======== action ======== //

/**
* 通用公共动作
*/
export interface GeneralPublicAction {
/**
* 撤销操作
*/
undo: () => void;
/**
* 重做操作
*/
redo: () => void;
/**
* 撤销栈
*/
undoStack: () => StackItem[];
/**
* 重做栈
*/
redoStack: () => StackItem[];
}

export interface GeneralSlice extends GeneralPublicAction, GeneralSliceState {}

export const generalSlice: StateCreator<
Expand Down

0 comments on commit 77ccfe1

Please sign in to comment.