mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-20 04:18:05 +00:00
fix: 🐛 codeout btn fix
This commit is contained in:
parent
e65a038795
commit
afda7d4259
@ -48,6 +48,7 @@
|
|||||||
"@types/events": "^3.0.0",
|
"@types/events": "^3.0.0",
|
||||||
"@types/react": "^16.8.3",
|
"@types/react": "^16.8.3",
|
||||||
"@types/react-dom": "^16.8.2",
|
"@types/react-dom": "^16.8.2",
|
||||||
|
"@types/streamsaver": "^2.0.0",
|
||||||
"build-plugin-fusion": "^0.1.0",
|
"build-plugin-fusion": "^0.1.0",
|
||||||
"build-plugin-moment-locales": "^0.1.0",
|
"build-plugin-moment-locales": "^0.1.0",
|
||||||
"build-plugin-react-app": "^1.1.2",
|
"build-plugin-react-app": "^1.1.2",
|
||||||
|
|||||||
@ -2,25 +2,40 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button } from '@alifd/next';
|
import { Button } from '@alifd/next';
|
||||||
import { PluginProps } from '@ali/lowcode-types';
|
import { PluginProps, NpmInfo } from '@ali/lowcode-types';
|
||||||
import { Designer } from '@ali/lowcode-designer';
|
import { Designer } from '@ali/lowcode-designer';
|
||||||
import streamSaver from 'streamsaver';
|
import streamSaver from 'streamsaver';
|
||||||
|
|
||||||
import './codeout.scss';
|
import './codeout.scss';
|
||||||
|
|
||||||
|
interface BasicSection {
|
||||||
|
componentName: string;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
docUrl?: string;
|
||||||
|
screenshot?: string;
|
||||||
|
icon?: string;
|
||||||
|
tags?: string[];
|
||||||
|
devMode?: 'proCode' | 'lowCode';
|
||||||
|
npm: NpmInfo;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
const CODEOUT_SERVICE_HOST = '30.8.52.239:3000';
|
const CODEOUT_SERVICE_HOST = '30.8.52.239:3000';
|
||||||
|
|
||||||
const Codeout = ({ editor }: PluginProps) => {
|
const Codeout = ({ editor }: PluginProps) => {
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
const designer = editor.get(Designer);
|
const designer = editor.get(Designer);
|
||||||
if (designer) {
|
if (designer) {
|
||||||
const assets = editor.get('assets');
|
const assets = editor.get('assets') as { components: BasicSection[] };
|
||||||
console.log(assets.components);
|
const components = assets.components;
|
||||||
|
|
||||||
const componentsMap = assets.components.map((c) => ({
|
const componentsMap = components
|
||||||
componentName: c.componentName,
|
.filter((c) => !!c.npm)
|
||||||
...(c.npm || {}),
|
.map((c) => ({
|
||||||
}));
|
componentName: c.componentName,
|
||||||
|
...(c.npm || {}),
|
||||||
|
}));
|
||||||
|
|
||||||
const fullSchema = {
|
const fullSchema = {
|
||||||
...designer.schema,
|
...designer.schema,
|
||||||
@ -35,24 +50,26 @@ const Codeout = ({ editor }: PluginProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
console.info('codeout schema:', fullSchema);
|
console.info('codeout schema:', fullSchema);
|
||||||
// fetch(`http://${CODEOUT_SERVICE_HOST}/api/generate/project`, {
|
fetch(`http://${CODEOUT_SERVICE_HOST}/api/generate/project`, {
|
||||||
// method: 'POST',
|
method: 'POST',
|
||||||
// body: JSON.stringify({ schema: JSON.stringify(fullSchema) }),
|
body: JSON.stringify({ schema: JSON.stringify(fullSchema) }),
|
||||||
// headers: new Headers({
|
headers: new Headers({
|
||||||
// 'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// }),
|
}),
|
||||||
// mode: 'cors',
|
mode: 'cors',
|
||||||
// }).then((res) => {
|
}).then((res) => {
|
||||||
// const fileStream = streamSaver.createWriteStream('demoProject.zip');
|
const fileStream = streamSaver.createWriteStream('demoProject.zip');
|
||||||
// res.body.pipeTo(fileStream).then(
|
if (res.body !== null) {
|
||||||
// () => {
|
res.body.pipeTo(fileStream).then(
|
||||||
// console.log('success');
|
() => {
|
||||||
// },
|
console.log('success');
|
||||||
// (err) => {
|
},
|
||||||
// console.log(err);
|
(err) => {
|
||||||
// },
|
console.log(err);
|
||||||
// );
|
},
|
||||||
// });
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user