diff --git a/src/MarkMap.vue b/src/MarkMap.vue index 0ad1043..33cce04 100644 --- a/src/MarkMap.vue +++ b/src/MarkMap.vue @@ -26,7 +26,16 @@ export default { if (assets.styles) loadCSS(assets.styles); if (assets.scripts) loadJS(assets.scripts, { getMarkmap: () => window.markmap }); - Markmap.create('#markmap', null, root); + const savedState = JSON.parse(localStorage.getItem('markmap-state')); + const markmapState = savedState ? savedState : root; + + const markmap = Markmap.create('#markmap', null, markmapState); + + for (const item of document.getElementsByTagName('circle')) { + item.addEventListener('click', () => { + localStorage.setItem('markmap-state', JSON.stringify(markmap.state.data)); + }); + } }); } }; diff --git a/src/index.md b/src/index.md index 1f87ad5..dd52ad6 100644 --- a/src/index.md +++ b/src/index.md @@ -8,7 +8,7 @@ import MarkMap from './MarkMap.vue';