feat: fix the problem of plugin outline tree in workspace mode

This commit is contained in:
liujuping 2023-02-14 16:16:00 +08:00 committed by 林熠
parent 2f69837002
commit 631b566932
2 changed files with 6 additions and 18 deletions

View File

@ -11,6 +11,10 @@ export interface ITreeBoard {
export class TreeMaster {
readonly pluginContext: IPublicModelPluginContext;
private boards = new Set<ITreeBoard>();
private treeMap = new Map<string, Tree>();
constructor(pluginContext: IPublicModelPluginContext) {
this.pluginContext = pluginContext;
let startTime: any;
@ -70,8 +74,6 @@ export class TreeMaster {
}
}
private boards = new Set<ITreeBoard>();
addBoard(board: ITreeBoard) {
this.boards.add(board);
}
@ -84,8 +86,6 @@ export class TreeMaster {
// todo others purge
}
private treeMap = new Map<string, Tree>();
get currentTree(): Tree | null {
const doc = this.pluginContext.project.getCurrentDocument();
if (doc) {
@ -100,15 +100,3 @@ export class TreeMaster {
return null;
}
}
const mastersMap = new Map<string, TreeMaster>();
export function getTreeMaster(pluginContext: IPublicModelPluginContext): TreeMaster {
const key = pluginContext.project.currentDocument?.id || 'unknown';
let master = mastersMap.get(key);
if (!master) {
master = new TreeMaster(pluginContext);
pluginContext.logger.info('TreeMaster is created');
mastersMap.set(key, master);
}
return master;
}

View File

@ -3,7 +3,7 @@ import { IconOutline } from './icons/outline';
import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/lowcode-types';
import { enUS, zhCN } from './locale';
import { MasterPaneName, BackupPaneName } from './helper/consts';
import { getTreeMaster } from './controllers/tree-master';
import { TreeMaster } from './controllers/tree-master';
import { PaneController } from './controllers/pane-controller';
export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
@ -26,7 +26,7 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
masterPane: false,
backupPane: false,
};
const treeMaster = getTreeMaster(ctx);
const treeMaster = new TreeMaster(ctx);
let masterPaneController: PaneController | null = null;
let backupPaneController: PaneController | null = null;
return {