epic-designer
Version:
基于vue3的设计器,可视化开发页面表单
76 lines (75 loc) • 2.54 kB
TypeScript
import { ComponentSchema, DesignerState, PageSchema } from '../../types/src/index';
/**
* 历史记录模型 - 用于存储页面状态的快照
*/
export interface RecordModel {
/** 页面架构的JSON字符串表示 */
pageSchema: string;
/** 当前选中组件的ID,用于恢复选中状态 */
selectedId?: string;
/** 记录创建时间戳 */
timestamp: number;
/** 操作类型描述,如"添加组件"、"删除组件"等 */
type: string;
}
/**
* 撤销重做功能 - 提供完整的操作历史管理
* @description 通过保存页面状态的快照实现撤销和重做功能
* @param pageSchema - 当前页面架构对象(响应式)
* @param state - 设计器状态对象
* @param setSelectedNode - 设置当前选中节点的回调函数
* @returns 撤销重做相关的操作方法和状态
*/
export declare function useRevoke(pageSchema: PageSchema, state: DesignerState, setSelectedNode: (schema?: ComponentSchema) => void): {
currentRecord: import('vue').Ref<{
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
} | null, RecordModel | {
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
} | null>;
exportHistory: () => {
currentRecord: null | RecordModel;
recordList: RecordModel[];
undoList: RecordModel[];
};
getRedoCount: () => number;
getUndoCount: () => number;
importHistory: (historyData: {
currentRecord: null | RecordModel;
recordList: RecordModel[];
undoList: RecordModel[];
}) => void;
previewHistory: (record: RecordModel) => (() => void);
push: (type?: string, isImportant?: boolean) => void;
recordList: import('vue').Ref<{
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
}[], RecordModel[] | {
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
}[]>;
redo: () => boolean;
reset: () => void;
undo: () => boolean;
undoList: import('vue').Ref<{
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
}[], RecordModel[] | {
pageSchema: string;
selectedId?: string | undefined;
timestamp: number;
type: string;
}[]>;
};
export type Revoke = ReturnType<typeof useRevoke>;