feat: function for chart data request

This commit is contained in:
chenos 2022-07-05 16:56:21 +08:00
parent 7c7fd1bb5e
commit ba5fb97d1e
2 changed files with 14 additions and 1 deletions

View File

@ -3,8 +3,9 @@ import * as components from '.';
import * as common from '../common'; import * as common from '../common';
import { SchemaComponentOptions } from '../core/SchemaComponentOptions'; import { SchemaComponentOptions } from '../core/SchemaComponentOptions';
import { useFilterActionProps } from './filter/useFilterActionProps'; import { useFilterActionProps } from './filter/useFilterActionProps';
import { requestChartData } from './g2plot/requestChartData';
export const AntdSchemaComponentProvider = (props) => { export const AntdSchemaComponentProvider = (props) => {
const { children } = props; const { children } = props;
return <SchemaComponentOptions scope={{ useFilterActionProps }} components={{ ...components, ...common } as any}>{children}</SchemaComponentOptions>; return <SchemaComponentOptions scope={{ requestChartData, useFilterActionProps }} components={{ ...components, ...common } as any}>{children}</SchemaComponentOptions>;
}; };

View File

@ -0,0 +1,12 @@
import { APIClient } from '../../../api-client';
export const requestChartData = (options) => {
return async function (this: { api: APIClient }) {
try {
const response = await this.api.request(options);
return response?.data?.data;
} catch (error) {
return [];
}
};
};