fix(web): Fix sql format error (#1319)

This commit is contained in:
Hzh_97
2024-03-21 17:41:25 +08:00
committed by GitHub
parent 86a7b6c6f3
commit 04322de4f3
49 changed files with 69256 additions and 236 deletions

View File

@@ -1,9 +1,9 @@
import { Datum } from '@antv/ava';
import { Table, Tabs, TabsProps } from 'antd';
import React from 'react';
import { format } from 'sql-formatter';
import { AutoChart, BackEndChartType, getChartType } from '@/components/chart/autoChart';
import { CodePreview } from './code-preview';
import { formatSql } from '@/utils';
function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType; sql: string }) {
const columns = data?.[0]
@@ -20,10 +20,11 @@ function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType;
label: 'Chart',
children: <AutoChart data={data} chartType={getChartType(type)} />,
};
const SqlItem = {
key: 'sql',
label: 'SQL',
children: <CodePreview language="sql" code={format(sql ?? '', { language: 'mysql' }) as string} />,
children: <CodePreview language="sql" code={formatSql(sql)} />,
};
const DataItem = {
key: 'data',