fix: init

This commit is contained in:
liujuping 2022-12-05 17:54:04 +08:00
parent d3f8a96e72
commit bf0ffc55fb
6 changed files with 33 additions and 12 deletions

View File

@ -59,7 +59,7 @@ export class Skeleton {
readonly stages: Area<StageConfig, Stage>;
constructor(readonly editor: Editor) {
constructor(readonly editor: Editor, readonly name: string = 'unknown') {
makeObservable(this);
this.leftArea = new Area(
this,

View File

@ -20,7 +20,6 @@ export class EditorView extends Component<any, any> {
render() {
const innerSkeleton = this.ctx.skeleton[skeletonSymbol];
// debugger;
return (
<Workbench
skeleton={innerSkeleton}

View File

@ -1,3 +1,4 @@
import { globalContext } from '@alilc/lowcode-editor-core';
import {
Skeleton as InnerSkeleton,
IWidgetBaseConfig,
@ -6,11 +7,25 @@ import {
} from '@alilc/lowcode-editor-skeleton';
import { skeletonSymbol } from './symbols';
export default class Skeleton {
private readonly [skeletonSymbol]: InnerSkeleton;
const innerSkeletonSymbol = Symbol('skeleton');
constructor(skeleton: InnerSkeleton) {
this[skeletonSymbol] = skeleton;
export default class Skeleton {
private readonly [innerSkeletonSymbol]: InnerSkeleton;
get [skeletonSymbol]() {
if (this.workspaceMode) {
return this[innerSkeletonSymbol];
}
const workSpace = globalContext.get('workSpace');
if (workSpace.isActive) {
return workSpace.window.innerSkeleton;
}
return this[innerSkeletonSymbol];
}
constructor(skeleton: InnerSkeleton, readonly workspaceMode: boolean = false) {
this[innerSkeletonSymbol] = skeleton;
}
/**

View File

@ -34,6 +34,7 @@ export class BasicContext {
designer;
registerInnerPlugins: any;
innerSetters: any;
innerSkeleton: any;
constructor(workSpace: WorkSpace, name: string, public editorWindow?: EditorWindow) {
const editor = new Editor(name, true);
@ -46,7 +47,7 @@ export class BasicContext {
// if (editorWindow) {
// }
const innerSkeleton = new InnerSkeleton(editor);
const innerSkeleton = new InnerSkeleton(editor, name);
editor.set('skeleton' as any, innerSkeleton);
const designer: Designer = new Designer({
@ -62,16 +63,18 @@ export class BasicContext {
const hotkey = new Hotkey(name);
const innerSetters = new InnerSetters(name);
const setters = new Setters(innerSetters, true);
const material = new Material(editor, true);
const material = new Material(editor, true, name);
const project = new Project(innerProject, true);
const config = engineConfig;
const event = new Event(editor, { prefix: 'common' });
const logger = getLogger({ level: 'warn', bizName: 'common' });
const skeleton = new Skeleton(innerSkeleton, true);
editor.set('setters', setters);
editor.set('project', project);
editor.set('material', material);
this.innerSetters = innerSetters;
this.skeleton = innerSkeleton;
this.innerSkeleton = innerSkeleton;
this.skeleton = skeleton;
this.plugins = plugins;
this.innerProject = innerProject;
this.project = project;

View File

@ -21,7 +21,7 @@ export class EditorView extends Component<any, any> {
render() {
const { active } = this.props;
const editorView = this.props.editorView;
const skeleton = editorView.skeleton;
const skeleton = editorView.innerSkeleton;
if (!editorView.isInit) {
return null;
}

View File

@ -17,7 +17,7 @@ export class EditorWindow {
initViewTypes = async () => {
const editorViews = this.resource.editorViews;
for (let i = 0; i < editorViews.length; i++) {
for (let i = editorViews.length - 1; i >= 0; i--) {
const name = editorViews[i].name;
await this.initViewType(name);
if (!this.editorView) {
@ -28,7 +28,7 @@ export class EditorWindow {
execViewTypesInit = async () => {
const editorViews = this.resource.editorViews;
for (let i = 0; i < editorViews.length; i++) {
for (let i = editorViews.length - 1; i >= 0; i--) {
const name = editorViews[i].name;
this.changeViewType(name);
await this.editorViews.get(name)?.init();
@ -68,6 +68,10 @@ export class EditorWindow {
return this.editorView?.innerProject;
}
get innerSkeleton() {
return this.editorView?.innerSkeleton;
}
get innerSetters() {
return this.editorView?.innerSetters;
}