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[] {
return this.designer.project.documents
.map(doc => {
// TODO: not use actived,
if (doc.actived && doc.simulator?.sensorAvailable) {
if (doc.active && doc.simulator?.sensorAvailable) {
return doc.simulator;
}
return null;

View File

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

View File

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

View File

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

View File

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

View File

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