feat: 🎸 增加icon获取api

This commit is contained in:
凤矗 2020-05-05 14:33:07 +08:00
parent f04204162e
commit f1a082369d

View File

@ -7,6 +7,7 @@ import {
PropsList, PropsList,
NodeData, NodeData,
TitleContent, TitleContent,
I18nData,
SlotSchema, SlotSchema,
PageSchema, PageSchema,
ComponentSchema, ComponentSchema,
@ -19,6 +20,7 @@ import { Prop } from './props/prop';
import { ComponentMeta } from '../../component-meta'; import { ComponentMeta } from '../../component-meta';
import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group'; import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
import { TransformStage } from './transform-stage'; import { TransformStage } from './transform-stage';
import { ReactElement } from 'react';
/** /**
* *
@ -122,7 +124,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return 0; return 0;
} }
@computed get title(): TitleContent { @computed get title(): string | I18nData | ReactElement {
let t = this.getExtraProp('title'); let t = this.getExtraProp('title');
if (!t && this.componentMeta.descriptor) { if (!t && this.componentMeta.descriptor) {
t = this.getProp(this.componentMeta.descriptor, false); t = this.getProp(this.componentMeta.descriptor, false);
@ -136,6 +138,10 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return this.componentMeta.title; return this.componentMeta.title;
} }
get icon() {
return this.componentMeta.icon;
}
constructor(readonly document: DocumentModel, nodeSchema: Schema) { constructor(readonly document: DocumentModel, nodeSchema: Schema) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
this.id = id || `node$${document.nextId()}`; this.id = id || `node$${document.nextId()}`;