mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-05 19:11:52 +00:00
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: 谨欣 <echo.cmy@antgroup.com> Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com> Co-authored-by: yanzhiyong <932374019@qq.com>
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { AutoChart, BackEndChartType, getChartType } from '@/components/chart/autoChart';
|
||||
import { formatSql } from '@/utils';
|
||||
import { Datum } from '@antv/ava';
|
||||
import { Table, Tabs, TabsProps } from 'antd';
|
||||
import React from 'react';
|
||||
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]
|
||||
? Object.keys(data?.[0])?.map((item) => {
|
||||
? Object.keys(data?.[0])?.map(item => {
|
||||
return {
|
||||
title: item,
|
||||
dataIndex: item,
|
||||
@@ -23,7 +22,7 @@ function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType;
|
||||
const SqlItem = {
|
||||
key: 'sql',
|
||||
label: 'SQL',
|
||||
children: <CodePreview language="sql" code={formatSql(sql ?? '', 'mysql') as string} />,
|
||||
children: <CodePreview language='sql' code={formatSql(sql ?? '', 'mysql') as string} />,
|
||||
};
|
||||
const DataItem = {
|
||||
key: 'data',
|
||||
@@ -32,7 +31,7 @@ function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType;
|
||||
};
|
||||
const TabItems: TabsProps['items'] = type === 'response_table' ? [DataItem, SqlItem] : [ChartItem, SqlItem, DataItem];
|
||||
|
||||
return <Tabs defaultActiveKey={type === 'response_table' ? 'data' : 'chart'} items={TabItems} size="small" />;
|
||||
return <Tabs defaultActiveKey={type === 'response_table' ? 'data' : 'chart'} items={TabItems} size='small' />;
|
||||
}
|
||||
|
||||
export default ChartView;
|
||||
|
Reference in New Issue
Block a user