From 5f8b70aac2bfdd6ea4401355cb19484ddbb344a6 Mon Sep 17 00:00:00 2001 From: purocean Date: Sat, 29 May 2021 18:53:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=84=91=E5=9B=BE=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E7=9A=84=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/plugins/mind-map.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/plugins/mind-map.ts b/frontend/src/plugins/mind-map.ts index 085b03ca..4d39e523 100644 --- a/frontend/src/plugins/mind-map.ts +++ b/frontend/src/plugins/mind-map.ts @@ -4,6 +4,8 @@ import { Plugin } from '@/useful/plugin' import crypto from '@/useful/crypto' import { dataURItoBlobLink, openInNewWindow } from '@/useful/utils' +const layoutStorageKey = 'mind-map-layout' + const renderRule: Renderer.RenderRule = (tokens, idx, options, { source }, slf) => { const token = tokens[idx] const nextToken = tokens[idx + 1] @@ -100,7 +102,7 @@ const render = async (ele: HTMLElement) => { km.disable() try { await km.importData('text', code) - km.useTemplate('default') + km.useTemplate(localStorage.getItem(layoutStorageKey) || 'default') } catch (error) { await km.importData('text', '转换错误\n 1. 请保证大纲只有一个根项目\n 2. 请保证大纲层级正确') km.useTemplate('structure') @@ -115,7 +117,9 @@ const render = async (ele: HTMLElement) => { const tpl = km.getTemplate() const index = tplList.indexOf(tpl) const nextIndex = index > tplList.length - 2 ? 0 : index + 1 - km.useTemplate(tplList[nextIndex]) + const layout = tplList[nextIndex] + localStorage.setItem(layoutStorageKey, layout) + km.useTemplate(layout) km.execCommand('camera') }