jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
64 lines (63 loc) • 2.52 kB
TypeScript
import type moment from 'moment';
import type history from 'history';
import type { Axios } from 'axios';
import type { ICustomAction, IScopedContext, IServiceStore, RendererEnv, ScopedComponentType } from 'jamis-core';
import type { SchemaObjectScoped, TplSchema } from '../index';
import type * as amisLib from '../';
import type { ICRUDStore } from '../types';
export interface IRootScopedContext extends IScopedContext {
updateProps: (props: any, callback?: () => void) => void;
unmount: () => void;
}
export type SchemaTypeWithScoped = 'page' | 'form' | 'crud' | 'service' | 'table' | 'list';
export declare const injectGlobVal: (name: string, val: any) => void;
export declare class JarvisHelper {
BrowserHistory: history.Module;
amisLib: typeof amisLib;
moment: typeof moment;
axios: Axios;
amisScoped: IRootScopedContext;
rootRenderer: ScopedComponentType;
amisEnv: RendererEnv;
constructor();
/**
* 启用调试器
*/
enableDebug: () => void;
amisEmbed: (elemOrElemId: string | HTMLElement, schema: SchemaObjectScoped, props?: Record<string, any>, env?: Partial<RendererEnv>) => Promise<IRootScopedContext>;
/**
* 给全局window对象注入方法
*/
parseJSON: <T>(str: string, defVal: T | null) => T | null;
/**
* @deprecated 使用parseJSON替代
*/
jsonParseSafe: JarvisHelper['parseJSON'];
/**
* 自适应更新组件的数据域
* 1. 根据schema中的type去调用不同renderer的更新数据方法
* 2. 如果props.store.updateData存在, 则调用该方法
* 3. 其他情况打印错误日志并返回
*/
updateDataScope: (componentId: string, data: Record<string, any>) => void;
/**
* 自适应获取组件的数据域, 优先返回组件props.store.data, 没有时返回props.data
* 当获取不到组件, 或者$schema.type不存在时, 返回undefined
*/
getDataScope: <T = Record<string, any>>(componentId: string, defData?: T) => T | undefined;
/**
* 自动根据schemaType返回数据域store对象
*/
getFormStore: (componentId: string) => amisLib.IFormStore;
getPageStore: (componentId: string) => IServiceStore;
getCRUDStore: (componentId: string) => ICRUDStore;
/**
* 添加tpl调试日志
*/
logSchema: (...args: any[]) => TplSchema;
/**
* 调试打印事件动作, 查看事件携带的参数等
*/
logEvent: (tag?: string) => ICustomAction;
private getDataStore;
}