Merge pull request #8013 from YangFong/fix-interface-name

chore: 调整接口命名风格
This commit is contained in:
hsm-lv 2023-09-06 19:59:14 +08:00 committed by GitHub
commit aaa201f486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 15 deletions

View File

@ -21,7 +21,7 @@ import type {RendererEvent} from './utils/renderer-event';
import type {ListenerContext} from './actions/Action';
import type {ICmptAction} from './actions/CmptAction';
export interface wsObject {
export interface WsObject {
url: string;
responseKey?: string;
body?: any;
@ -32,7 +32,7 @@ export interface RendererEnv {
fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
isCancel: (val: any) => boolean;
wsFetcher: (
ws: wsObject,
ws: WsObject,
onMessage: (data: any) => void,
onError: (error: any) => void
) => void;

View File

@ -100,24 +100,24 @@ export interface RenderSchemaFilter {
(schema: Schema, renderer: RendererConfig, props?: any): Schema;
}
export interface wsObject {
export interface WsObject {
url: string;
responseKey?: string;
body?: any;
}
export interface FetcherConfig {
url: string;
method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'jsonp' | 'js';
data?: any;
config?: any;
}
export interface RenderOptions
extends Partial<Omit<RendererEnv, 'fetcher' | 'theme'>> {
session?: string;
theme?: string;
fetcher?: (config: fetcherConfig) => Promise<fetcherResult>;
}
export interface fetcherConfig {
url: string;
method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'jsonp' | 'js';
data?: any;
config?: any;
fetcher?: (config: FetcherConfig) => Promise<fetcherResult>;
}
const renderers: Array<RendererConfig> = [];
@ -238,7 +238,7 @@ export const defaultOptions: RenderOptions = {
},
// 使用 WebSocket 来实时获取数据
wsFetcher(
ws: wsObject,
ws: WsObject,
onMessage: (data: any) => void,
onError: (error: any) => void
) {

View File

@ -1,6 +1,6 @@
import omit from 'lodash/omit';
import {Api, ApiObject, EventTrack, fetcherResult, Payload} from '../types';
import {fetcherConfig} from '../factory';
import {FetcherConfig} from '../factory';
import {tokenize, dataMapping, escapeHtml} from './tpl-builtin';
import {evalExpression} from './tpl';
import {
@ -463,7 +463,7 @@ export function responseAdaptor(ret: fetcherResult, api: ApiObject) {
}
export function wrapFetcher(
fn: (config: fetcherConfig) => Promise<fetcherResult>,
fn: (config: FetcherConfig) => Promise<fetcherResult>,
tracker?: (eventTrack: EventTrack, data: any) => void
) {
// 避免重复处理
@ -597,7 +597,7 @@ export function wrapAdaptor(
* @returns
*/
export function jsFetcher(
fetcher: (config: fetcherConfig) => Promise<fetcherResult>,
fetcher: (config: FetcherConfig) => Promise<fetcherResult>,
api: ApiObject
): Promise<fetcherResult> {
return new Promise((resolve, reject) => {