import React, { useState } from 'react' import './index.less' import EditorComponent from '../../components/RichEditor' import CodeHighlight from './CodeHighlight' import { Button } from 'antd' type DemoProps = { data: any report: any exec?: () => void preActive?: (data: any) => boolean | void } const language: any = { shell: 'PowerShell', java: 'java', python: 'python' } // 示例演示 const Demo: React.FC = (props) => { const { data = {}, report, exec, preActive } = props const { title = '', code = '', codeLanguage, buttonName = '', showCode = false, required = false } = data // 用来判断是否点击过按钮 const [hasClick, setHasClick] = useState(0) const submit = async () => { if (preActive && preActive(data)) return setHasClick((pre) => ++pre) report() exec?.() } return (
示例演示
{ showCode && }
) } export default Demo