mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
27 lines
608 B
TypeScript
27 lines
608 B
TypeScript
import { debounce, throttle} from 'lodash'
|
|
import { useSnapshotStore } from '@/store'
|
|
|
|
export default () => {
|
|
const snapshotStore = useSnapshotStore()
|
|
|
|
// 添加历史快照(历史记录)
|
|
const addHistorySnapshot = debounce(function() {
|
|
snapshotStore.addSnapshot()
|
|
}, 300, { trailing: true })
|
|
|
|
// 重做
|
|
const redo = throttle(function() {
|
|
snapshotStore.reDo()
|
|
}, 100, { leading: true, trailing: false })
|
|
|
|
// 撤销
|
|
const undo = throttle(function() {
|
|
snapshotStore.unDo()
|
|
}, 100, { leading: true, trailing: false })
|
|
|
|
return {
|
|
addHistorySnapshot,
|
|
redo,
|
|
undo,
|
|
}
|
|
} |