feat: 🎸 与国凯的数据源保持一致,将 urlParams 所需的 search 参数直接传入

This commit is contained in:
牧毅 2020-08-30 01:56:53 +08:00
parent b9a562eeab
commit 19fabc1760
3 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
requestHandlersMap[ds.type] = {
type: 'JSExpression',
value: handlerName + (ds.type === 'urlParams' ? '({ search: this.props.location.search })' : ''),
value: handlerName + (ds.type === 'urlParams' ? '(this.props.location.search)' : ''),
};
next.chunks.push({

View File

@ -51,7 +51,7 @@ class Home$$Page extends Component {
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
runtimeConfig: true,
requestHandlersMap: {
urlParams: __$$urlParamsRequestHandler({ search: this.props.location.search }),
urlParams: __$$urlParamsRequestHandler(this.props.location.search),
fetch: __$$fetchRequestHandler,
},
});

View File

@ -1,7 +1,7 @@
import qs from 'query-string';
import { RequestHandler } from '../types';
export default function urlParamsHandler({ search }: { search: string | Record<string, unknown> }): RequestHandler {
export default function urlParamsHandler(search: string | Record<string, unknown>): RequestHandler {
const urlParams = typeof search === 'string' ? qs.parse(search) : search;
return async () => {