refactor: 修改 actived typo

This commit is contained in:
lihao.ylh 2021-09-01 16:28:50 +08:00
parent 88f5677682
commit a10641daff
6 changed files with 23 additions and 18 deletions

View File

@ -146,8 +146,7 @@ export default class DragResizeEngine {
private getMasterSensors(): ISimulatorHost[] { private getMasterSensors(): ISimulatorHost[] {
return this.designer.project.documents return this.designer.project.documents
.map(doc => { .map(doc => {
// TODO: not use actived, if (doc.active && doc.simulator?.sensorAvailable) {
if (doc.actived && doc.simulator?.sensorAvailable) {
return doc.simulator; return doc.simulator;
} }
return null; return null;

View File

@ -1053,7 +1053,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
scrollToNode(node: Node, detail?: any /* , tryTimes = 0 */) { scrollToNode(node: Node, detail?: any /* , tryTimes = 0 */) {
this.tryScrollAgain = null; this.tryScrollAgain = null;
if (this.sensing) { if (this.sensing) {
// actived sensor // active sensor
return; return;
} }

View File

@ -308,8 +308,8 @@ export class Designer {
getSuitableInsertion( getSuitableInsertion(
insertNode?: Node | NodeSchema | NodeSchema[], insertNode?: Node | NodeSchema | NodeSchema[],
): { target: ParentalNode; index?: number } | null { ): { target: ParentalNode; index?: number } | null {
const activedDoc = this.project.currentDocument; const activeDoc = this.project.currentDocument;
if (!activedDoc) { if (!activeDoc) {
return null; return null;
} }
if ( if (
@ -318,11 +318,11 @@ export class Designer {
this.getComponentMeta(insertNode[0].componentName).isModal this.getComponentMeta(insertNode[0].componentName).isModal
) { ) {
return { return {
target: activedDoc.rootNode as ParentalNode, target: activeDoc.rootNode as ParentalNode,
}; };
} }
const focusNode = activedDoc.focusNode!; const focusNode = activeDoc.focusNode!;
const nodes = activedDoc.selection.getNodes(); const nodes = activeDoc.selection.getNodes();
const refNode = nodes.find(item => focusNode.contains(item)); const refNode = nodes.find(item => focusNode.contains(item));
let target; let target;
let index: number | undefined; let index: number | undefined;

View File

@ -195,7 +195,7 @@ export class Dragon {
private sensors: ISensor[] = []; private sensors: ISensor[] = [];
/** /**
* current actived sensor, * current active sensor,
*/ */
@obx.ref private _activeSensor: ISensor | undefined; @obx.ref private _activeSensor: ISensor | undefined;
@ -619,8 +619,7 @@ export class Dragon {
new Set( new Set(
this.designer.project.documents this.designer.project.documents
.map((doc) => { .map((doc) => {
// TODO: not use actived, if (doc.active && doc.simulator?.sensorAvailable) {
if (doc.actived && doc.simulator?.sensorAvailable) {
return doc.simulator; return doc.simulator;
} }
return null; return null;

View File

@ -446,10 +446,17 @@ export class DocumentModel {
/** /**
* suspensed * suspensed
*/ */
get actived(): boolean { get active(): boolean {
return !this._suspensed; return !this._suspensed;
} }
/**
* @deprecated
*/
get actived(): boolean {
return this.active;
}
/** /**
* *
*/ */
@ -476,7 +483,7 @@ export class DocumentModel {
this.setSuspense(true); this.setSuspense(true);
} }
active() { activate() {
this.setSuspense(false); this.setSuspense(false);
} }

View File

@ -28,7 +28,7 @@ export class Project {
} }
@computed get currentDocument() { @computed get currentDocument() {
return this.documents.find((doc) => doc.actived); return this.documents.find((doc) => doc.active);
} }
@obx private _config: any = {}; @obx private _config: any = {};
@ -67,7 +67,7 @@ export class Project {
*/ */
setSchema(schema?: ProjectSchema) { setSchema(schema?: ProjectSchema) {
// FIXME: 这里的行为和 getSchema 并不对等,感觉不太对 // FIXME: 这里的行为和 getSchema 并不对等,感觉不太对
const doc = this.documents.find((doc) => doc.actived); const doc = this.documents.find((doc) => doc.active);
doc && doc.import(schema?.componentsTree[0]); doc && doc.import(schema?.componentsTree[0]);
} }
@ -231,13 +231,13 @@ export class Project {
return doc.open(); return doc.open();
} }
checkExclusive(actived: DocumentModel) { checkExclusive(activeDoc: DocumentModel) {
this.documents.forEach((doc) => { this.documents.forEach((doc) => {
if (doc !== actived) { if (doc !== activeDoc) {
doc.suspense(); doc.suspense();
} }
}); });
this.emitter.emit('current-document.change', actived); this.emitter.emit('current-document.change', activeDoc);
} }
closeOthers(opened: DocumentModel) { closeOthers(opened: DocumentModel) {