chore(deps): update deps

* replace fast-deep-equal with microdiff
* remove localforage (using useStorage instead)

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-18 15:25:49 +01:00
parent 90a2a6544d
commit 156287b9d2
6 changed files with 101 additions and 152 deletions

View File

@@ -1,13 +1,12 @@
<script lang="ts" setup>
import localforage from 'localforage'
import { useZoomPanHelper, FlowInstance, FlowExportObject, Node } from '~/index'
localforage.config({
name: 'vue-flow',
storeName: 'flows',
})
const flowKey = 'example-flow'
const state = useStorage(flowKey, {
elements: [],
position: [NaN, NaN],
zoom: 1,
} as FlowExportObject)
const getNodeId = () => `randomnode_${+new Date()}`
@@ -21,25 +20,17 @@ const props = defineProps<ControlsProps>()
const emit = defineEmits(['restore', 'add'])
const onSave = () => {
if (props.flowInstance) {
const flow = props.flowInstance.toObject()
localforage.setItem(flowKey, flow)
}
if (props.flowInstance) state.value = props.flowInstance.toObject()
}
const onRestore = () => {
const restoreFlow = async () => {
const flow: FlowExportObject | null = await localforage.getItem(flowKey)
const flow: FlowExportObject | null = state.value
console.log(flow)
if (flow) {
const [x = 0, y = 0] = flow.position
emit('restore', flow.elements ?? [])
transform({ x, y, zoom: flow.zoom || 0 })
}
if (flow) {
const [x = 0, y = 0] = flow.position
emit('restore', flow.elements ?? [])
transform({ x, y, zoom: flow.zoom || 0 })
}
restoreFlow()
}
const onAdd = () => {