fix: 代码结构调整

This commit is contained in:
guokai.jgk 2020-10-13 17:29:40 +08:00
parent 64a477cf35
commit af4bc83cc3
4 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,9 @@ export type DataType = 'jsonp' | 'json' | 'originaljsonp';
// 考虑一下 mtop 类型的问题,官方没有提供 ts 文件 // 考虑一下 mtop 类型的问题,官方没有提供 ts 文件
export function createMtopHandler<T = unknown>(config?: MTopConfig) { export function createMtopHandler<T = unknown>(config?: MTopConfig) {
if (config && Object.keys(config).length > 0) { if (config && Object.keys(config).length > 0) {
Object.keys(config).forEach((key: string) => mtopRequest.config(key, config[key])); Object.keys(config).forEach((key: string) =>
mtopRequest.config(key, config[key]),
);
} }
return async function(options: RuntimeOptionsConfig): Promise<{ data: T }> { return async function(options: RuntimeOptionsConfig): Promise<{ data: T }> {
const response = await mtopRequest.request<T>({ const response = await mtopRequest.request<T>({

View File

@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-types": "^1.0.10", "@ali/lowcode-types": "^0.8.13",
"query-string": "^6.13.1", "query-string": "^6.13.1",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -1,9 +1,7 @@
import qs from 'query-string'; import qs from 'query-string';
import { UrlParamsHandler } from '@ali/lowcode-types'; import { UrlParamsHandler } from '@ali/lowcode-types';
export function createUrlParamsHandler<T = unknown>( export function createUrlParamsHandler<T = unknown>(searchString: string | T = ''): UrlParamsHandler<T> {
searchString: string | T = '',
): UrlParamsHandler<T> {
return async function(): Promise<T> { return async function(): Promise<T> {
if (typeof searchString === 'string') { if (typeof searchString === 'string') {
const params = (qs.parse(searchString) as unknown) as T; const params = (qs.parse(searchString) as unknown) as T;