web:fix init and build api

This commit is contained in:
pengfei.zhou 2020-03-30 15:18:35 +08:00
parent 050dfc46ae
commit bd5391a0ac
4 changed files with 14 additions and 9 deletions

View File

@ -5402,8 +5402,11 @@ ${content}
}
return Reflect.apply(sandbox.jsCallEntityMethod, this.panel, argumentsList);
}
init(frame, extra) {
this.invokeEntityMethod("__init__", frame, extra ? JSON.stringify(extra) : undefined);
init(extra) {
this.invokeEntityMethod("__init__", extra ? JSON.stringify(extra) : undefined);
}
build(frame) {
this.invokeEntityMethod("__build__", frame);
}
teardown() {
for (let plugin of this.pluginInstances.values()) {
@ -5453,7 +5456,7 @@ ${content}
divElement.style.height = '100%';
this.append(divElement);
this.context.rootNode.view = divElement;
this.context.init({
this.context.build({
width: divElement.offsetWidth,
height: divElement.offsetHeight,
});

File diff suppressed because one or more lines are too long

View File

@ -39,13 +39,15 @@ export class DoricContext {
return Reflect.apply(jsCallEntityMethod, this.panel, argumentsList)
}
init(frame: {
init(extra?: object) {
this.invokeEntityMethod("__init__", extra ? JSON.stringify(extra) : undefined)
}
build(frame: {
width: number,
height: number,
}, extra?: object) {
this.invokeEntityMethod("__init__", frame, extra ? JSON.stringify(extra) : undefined)
}) {
this.invokeEntityMethod("__build__", frame)
}
teardown() {
for (let plugin of this.pluginInstances.values()) {
plugin.onTearDown()

View File

@ -51,7 +51,7 @@ export class DoricElement extends HTMLElement {
divElement.style.height = '100%'
this.append(divElement)
this.context.rootNode.view = divElement
this.context.init({
this.context.build({
width: divElement.offsetWidth,
height: divElement.offsetHeight,
})