blob: f3611adca3f2c8531bb280d476bc85d35a103e95 [file] [log] [blame]
Jiarenxiang38dcb052025-03-13 16:40:09 +08001import React, { useEffect } from 'react';
2import { useIntl } from '@umijs/max';
3import { Modal, Tabs } from 'antd';
4import type { TabsProps } from 'antd';
5import Highlight from 'react-highlight';
6import 'highlight.js/styles/base16/material.css';
7
8interface PreviewTableProps {
9 open: boolean;
10 data?: any;
11 onHide: () => void;
12}
13
14const PreviewTableCode: React.FC<PreviewTableProps> = (props) => {
15 const intl = useIntl();
16 const panes: any = [];
17 const keys = Object.keys(props.data);
18 keys.forEach((key) => {
19 panes.push({
20 key: key + '1',
21 label: key.substring(key.lastIndexOf('/') + 1, key.indexOf('.vm')),
22 children: <Highlight className="java">{props.data[key]}</Highlight>,
23 } as TabsProps);
24 });
25
26 useEffect(() => {}, []);
27
28 return (
29 <Modal
30 width={900}
31 title={intl.formatMessage({
32 id: 'gen.preview',
33 defaultMessage: '预览',
34 })}
35 open={props.open}
36 destroyOnClose
37 footer={false}
38 onOk={() => {
39 props.onHide();
40 }}
41 onCancel={() => {
42 props.onHide();
43 }}
44 >
45 <Tabs defaultActiveKey="1" items={panes}></Tabs>
46 </Modal>
47 );
48};
49
50export default PreviewTableCode;