From f445ffe7970f8b5a5465658dd1fef7bc11e9b26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E5=B8=8C?= Date: Thu, 16 Jul 2020 20:48:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20demo=20=E6=9E=84=E9=80=A0=20componentsM?= =?UTF-8?q?ap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/demo/src/editor/plugins/codeout.tsx | 48 +++++++++++--------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/packages/demo/src/editor/plugins/codeout.tsx b/packages/demo/src/editor/plugins/codeout.tsx index d537961fe..6fcaeee5b 100644 --- a/packages/demo/src/editor/plugins/codeout.tsx +++ b/packages/demo/src/editor/plugins/codeout.tsx @@ -14,6 +14,14 @@ const Codeout = ({ editor }: PluginProps) => { const handleClick = () => { const designer = editor.get(Designer); if (designer) { + const assets = editor.get('assets'); + console.log(assets.components); + + const componentsMap = assets.components.map((c) => ({ + componentName: c.componentName, + ...(c.npm || {}), + })); + const fullSchema = { ...designer.schema, config: { @@ -23,30 +31,28 @@ const Codeout = ({ editor }: PluginProps) => { meta: { name: 'demoproject', }, + componentsMap, }; console.info('codeout schema:', fullSchema); - // localStorage.setItem('lce-dev-store', JSON.stringify(designer.schema)); - fetch(`http://${CODEOUT_SERVICE_HOST}/api/generate/project`, { - method: 'POST', - body: JSON.stringify({ schema: JSON.stringify(fullSchema) }), - headers: new Headers({ - 'Content-Type': 'application/json', - }), - mode: 'cors', - }).then((res) => { - console.log(res); - - const fileStream = streamSaver.createWriteStream('demoProject.zip'); - res.body.pipeTo(fileStream).then( - () => { - console.log('success'); - }, - (err) => { - console.log(err); - }, - ); - }); + // fetch(`http://${CODEOUT_SERVICE_HOST}/api/generate/project`, { + // method: 'POST', + // body: JSON.stringify({ schema: JSON.stringify(fullSchema) }), + // headers: new Headers({ + // 'Content-Type': 'application/json', + // }), + // mode: 'cors', + // }).then((res) => { + // const fileStream = streamSaver.createWriteStream('demoProject.zip'); + // res.body.pipeTo(fileStream).then( + // () => { + // console.log('success'); + // }, + // (err) => { + // console.log(err); + // }, + // ); + // }); } };