From abeb2ba83fc0a604be7703b9d802c884743f1088 Mon Sep 17 00:00:00 2001 From: "wuyue.xht" Date: Wed, 22 Apr 2020 18:45:11 +0800 Subject: [PATCH] feat: preview --- packages/plugin-sample-preview/src/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/plugin-sample-preview/src/index.tsx b/packages/plugin-sample-preview/src/index.tsx index 3ddff9d0d..cac06d8ca 100644 --- a/packages/plugin-sample-preview/src/index.tsx +++ b/packages/plugin-sample-preview/src/index.tsx @@ -10,7 +10,18 @@ const SamplePreview = ({ editor }: PluginProps) => { if (designer) { console.info('save schema:', designer.schema); localStorage.setItem('lce-dev-store', JSON.stringify(designer.schema)); - window.open('http://30.5.157.206:3333/', 'preview'); + fetch('http://30.5.157.206:3000/legao/save.json', { + method: 'POST', + body: JSON.stringify(designer.schema), + headers: new Headers({ + 'Content-Type': 'application/json', + }), + mode: 'cors', + }) + .then((res) => res.json()) + .then(() => { + window.open('http://30.5.157.206:3333/', 'preview'); + }); } };