introduction snapshot is translated as a snapshot, which is used to directly obtain the status of the page at a certain runtime. The snapshot before and after the operation is stored, so that the page state can be redone and undone easily. this article mainly introduces the principle of snapshot tool implementation and its use in the project. Design to implement the history, redo and undo of page state, you need to support the following properties and methods Properties History: stores the history of the page state, including the page initialization state to the previous page state undo record: stores each redone operation record, which is used to recover after undo current record: temporarily stores the current page state, which is mainly used to store it in the history after the next operation Last time to insert data: the insertion interval is too small and additional processing is required  // History  recordList: string[] = []  ​  // cancel the record, which is used to redo  redoList: string[] = []  ​  // the current record is temporarily stored in the currentRecord variable, and then stored in recordList when the user modifies it.  currentRecord = ''  ​  // time when the data was last inserted  time = 0 method Storage history push when the user acts, the history is updated. The following points need to be considered. when the current operation time is less than 100 ms from the last insertion time, the current record is replaced and the add is canceled if the current record has a value, the last operation…

November 16, 2023 0comments 815hotness 0likes Aaron Read all