@lcap/asl
Version:
NetEase Application Specific Language
236 lines (235 loc) • 6.29 kB
TypeScript
import { LEVEL_ENUM, Page, Element, Lifecycle, ActionOptions } from '..';
import Block from './Block';
import { ElementToVueOptions } from './Element';
/**
* 子页面类,前端路由控制
*/
export declare class View extends Block {
/**
* 概念类型
*/
readonly level: LEVEL_ENUM;
/**
* 子页面 Id
*/
readonly id: string;
/**
* 子页面名称
*/
readonly name: string;
/**
* 前端路径,不带 page 名
*/
readonly path: string;
/**
* 前后端路径
* 由于 name 会改的关系,尽量不要用
* @deprecated
*/
readonly tempPath: string;
/**
* 唯一标识码
*/
readonly code: string;
/**
* 标题
*/
readonly title: string;
/**
* 面包屑
*/
readonly crumb: string;
/**
* 是否为默认跳转页
*/
readonly first: string;
/**
* 子页面 Id
*/
readonly parentId: string;
/**
* 附加的 script
*/
readonly script: string;
/**
* 页面 Id
*/
readonly pageId: string;
/**
* 页面模板 Id
*/
readonly pageTemplateId: number;
/**
* 所属页面
*/
readonly page: Page;
/**
* 父级子页面
*/
readonly parent: View;
/**
* 子页面
*/
readonly children: Array<View>;
/**
* 正在请求的 Promise
* 前端 UI 状态
*/
contentPromise: Promise<any>;
/**
* 输入参数
*/
/**
* 逻辑列表
*/
/**
* 树组件的子节点字段
*/
readonly moreChildrenFields: Array<string>;
/**
* @param source 需要合并的部分参数
*/
constructor(source?: Partial<View>);
private _onChange;
/**
* 在 mergeBlock 的情况下使用
* 在 loadDetail 的情况下使用
* @returns
*/
load(): Promise<any>;
loadAll(): Promise<any>;
isContentLoaded(): boolean;
/**
* 后续改为根据 id 查找 Element
*/
attachNodePath(clear?: boolean): void;
/**
* 根据路径查找子节点
* @param nodePath 节点路径,/1/2 表示根节点的第1个子节点的第2个子节点
* @param node 查找的起始节点
* @examples
* - findElementByNodePath('', root) 指根节点本身
* - findElementByNodePath('/', root) 指根节点本身
* - findElementByNodePath('/0', root) 指第0个子节点
* - findElementByNodePath('/2/1', root) 指第2个子节点的第1个子节点
*/
findElementByNodePath(nodePath: string, node?: Element): Element;
/**
* 根据标签查找元素
* @param tag
*/
findElementByTag(tag: string): Element;
/**
* 根据属性查找元素
* @param name
* @param value
*/
findElementByAttr(name: string, value: string): Element;
addData(res: any): void;
importViewCreate(none?: void, actionOptions?: ActionOptions, then?: () => Promise<any>): Promise<this>;
/**
* 添加子页面
*/
create(none?: void, actionOptions?: ActionOptions, then?: () => Promise<any>): Promise<this>;
/**
* 删除子页面
*/
delete(none?: void, actionOptions?: ActionOptions): Promise<void>;
/**
* 修改子页面
*/
update(none?: void, actionOptions?: ActionOptions, then?: () => Promise<any>): Promise<this>;
/**
* 设置子页面名称
* 如果为顶级子页面,会同时设置 Page 的属性
* @param name 名称
*/
setName(name: string): Promise<void>;
/**
* 设置子页面标题
* 如果为顶级子页面,会同时设置 Page 的属性
* @param title 标题
*/
setTitle(title: string): Promise<void>;
/**
* 设置子页面面包屑
* @param crumb 面包屑
*/
setCrumb(crumb: string): Promise<void>;
/**
* 设置该子页面为默认跳转页
*/
setAsFirst(): Promise<void>;
canCancelFirst(): boolean;
setAsFirstFalse(): Promise<void>;
/**
* 添加子页面
* @param view
*/
importView(view: View): Promise<View>;
/**
* 添加子页面
* @param view
*/
addView(view: View): Promise<View>;
/**
* 从模板添加子页面
* @param view 页面名称或页面 Options
* @param templateId 页面模板 Id
*/
addViewFromTemplate(viewName: string | Partial<View>, templateId: number): Promise<View>;
/**
* 添加页面事件
*/
addLifecycle(data: Lifecycle, actionOptions?: ActionOptions): Promise<Lifecycle>;
/**
* 删除页面属性
*/
removeLifecycle(lifecycle: Lifecycle, actionOptions?: ActionOptions): Promise<void>;
/**
* 转换成 Vue 中需要的 JS 代码
* @TODO 这一版先做成 componentOptions 式的,后面再美化
*/
toScript(options?: ElementToVueOptions): string;
/**
* 转换成 Vue 文件
*/
toVue(options?: ElementToVueOptions): string;
/**
* 转换成设计器中使用的 Vue 文件
* @param options
*/
toDesignerVue(options?: ElementToVueOptions): string;
/**
* 转换成 VueOptions
* @TODO 后面 template 可以优化成 render 函数
*/
toVueOptions(options?: ElementToVueOptions): {
template: string;
script: string;
};
/**
* 合并代码
*/
mergeBlock({ code, nodePath, position, parentNodePath }: {
code: string;
nodePath: string;
position: string;
parentNodePath: string;
}, actionOptions?: ActionOptions, then?: () => Promise<any>): Promise<void>;
_removeDef($def: View['$def']): void;
undoMergeBlock(res: any): Promise<void>;
_addDef($def: View['$def']): void;
redoMergeBlock(res: any): Promise<void>;
private _syncDef;
/**
* 从后端 JSON 生成规范的 View 对象
* @param currentView 方便构建子对象时关联,主要在 load 中使用
*/
static from(source: any, parent: View, page: Page, currentView?: View): View;
/**
* 按照模板创建
*/
static fromTemplate(templateName: string, source: any, parent: View, page: Page, scope?: 'pc' | 'h5'): Promise<View>;
}
export default View;