From 74bda21072b46a482aff11e21c0b01148b8cada2 Mon Sep 17 00:00:00 2001 From: MrKBear Date: Sat, 23 Apr 2022 17:42:02 +0800 Subject: [PATCH 1/3] Add behavior archive function --- source/Model/Archive.ts | 33 ++++++++++++++++++++++--- source/Model/Behavior.ts | 50 +++++++++++++++++++++++++++++++++++--- source/Model/CtrlObject.ts | 6 +++-- source/Model/Group.ts | 10 ++++++-- source/Model/Individual.ts | 2 +- source/Model/Parameter.ts | 3 ++- source/Model/Range.ts | 1 + 7 files changed, 92 insertions(+), 13 deletions(-) diff --git a/source/Model/Archive.ts b/source/Model/Archive.ts index 8f9e2d6..e446953 100644 --- a/source/Model/Archive.ts +++ b/source/Model/Archive.ts @@ -2,6 +2,9 @@ import { Emitter, EventType } from "@Model/Emitter"; import { IArchiveCtrlObject } from "@Model/CtrlObject"; import { Model } from "@Model/Model"; import { IArchiveLabel } from "@Model/Label"; +import { Group, IArchiveGroup } from "@Model/Group"; +import { IArchiveIndividual } from "@Model/Individual"; +import { IArchiveBehavior } from "@Model/Behavior"; interface IArchiveEvent { fileChange: Archive; @@ -11,6 +14,7 @@ interface IArchiveObject { nextIndividualId: number; objectPool: IArchiveCtrlObject[]; labelPool: IArchiveLabel[]; + behaviorPool: IArchiveBehavior[]; } class Archive< @@ -47,19 +51,42 @@ class Archive< // 存贮 CtrlObject const objectPool: IArchiveCtrlObject[] = []; model.objectPool.forEach(obj => { - objectPool.push(obj.toArchive()); + let archiveObject = obj.toArchive(); + + // 处理每个群的个体 + if (archiveObject.objectType === "G") { + const archiveGroup: IArchiveGroup = archiveObject as any; + const group: Group = obj as Group; + + const individuals: IArchiveIndividual[] = []; + group.individuals.forEach((item) => { + individuals.push(item.toArchive()); + }); + + archiveGroup.individuals = individuals; + } + + objectPool.push(archiveObject); }) // 存储 Label const labelPool: IArchiveLabel[] = []; model.labelPool.forEach(obj => { labelPool.push(obj.toArchive()); - }) + }); + // 存储全部行为 + const behaviorPool: IArchiveBehavior[] = []; + model.behaviorPool.forEach(obj => { + behaviorPool.push(obj.toArchive()); + }); + + // 生成存档对象 const fileData: IArchiveObject = { nextIndividualId: model.nextIndividualId, objectPool: objectPool, - labelPool: labelPool + labelPool: labelPool, + behaviorPool: behaviorPool }; console.log(fileData); diff --git a/source/Model/Behavior.ts b/source/Model/Behavior.ts index 7db5f66..ffdd9b4 100644 --- a/source/Model/Behavior.ts +++ b/source/Model/Behavior.ts @@ -3,7 +3,11 @@ import { v4 as uuid } from "uuid"; import type { Individual } from "@Model/Individual"; import type { Group } from "@Model/Group"; import type { Model } from "@Model/Model"; -import { getDefaultValue, IParameter, IParameterOption, IParameterValue } from "@Model/Parameter"; +import { + archiveObject2Parameter, + getDefaultValue, IArchiveParameterValue, IArchiveParseFn, + IParameter, IParameterOption, IParameterValue, parameter2ArchiveObject +} from "@Model/Parameter"; /** * 行为构造函数类型 @@ -113,6 +117,17 @@ class BehaviorRecorder< } } +interface IArchiveBehavior { + behaviorId: string; + name: string; + id: string; + color: number[]; + priority: number; + currentGroupKey: string[]; + deleteFlag: boolean; + parameter: IArchiveParameterValue; +} + /** * 群体的某种行为 */ @@ -189,6 +204,33 @@ class Behavior< return this.deleteFlag; } + public toArchive(): IArchiveBehavior { + return { + behaviorId: this.behaviorId, + name: this.name, + id: this.id, + color: this.color.concat([]), + priority: this.priority, + currentGroupKey: this.currentGroupKey.concat([]) as any, + deleteFlag: this.deleteFlag, + parameter: parameter2ArchiveObject( + this.parameter, this.parameterOption + ) + }; + } + + public fromArchive(archive: IArchiveBehavior, paster: IArchiveParseFn): void { + this.name = this.name, + this.id = this.id, + this.color = this.color.concat([]), + this.priority = this.priority, + this.currentGroupKey = this.currentGroupKey.concat([]) as any, + this.deleteFlag = this.deleteFlag, + this.parameter = archiveObject2Parameter( + archive.parameter, paster + ) as any; + } + /** * 加载时调用 */ @@ -241,6 +283,6 @@ class Behavior< type IRenderBehavior = BehaviorInfo | Behavior; export { - Behavior, BehaviorRecorder, IAnyBehavior, IAnyBehaviorRecorder, BehaviorInfo, IRenderBehavior -}; -export default { Behavior }; \ No newline at end of file + Behavior, BehaviorRecorder, IAnyBehavior, IAnyBehaviorRecorder, + BehaviorInfo, IRenderBehavior, IArchiveBehavior +}; \ No newline at end of file diff --git a/source/Model/CtrlObject.ts b/source/Model/CtrlObject.ts index 21a6f31..a0495dc 100644 --- a/source/Model/CtrlObject.ts +++ b/source/Model/CtrlObject.ts @@ -4,16 +4,18 @@ import type { IAnyObject, Model } from "@Model/Model"; import type { ObjectID } from "@Model/Model"; import { parameter2ArchiveObject, archiveObject2Parameter, - IArchiveParseFn, IObjectParamArchiveType, object2ArchiveObject + IArchiveParseFn, IObjectParamArchiveType, object2ArchiveObject, + IArchiveParameterValue, IParameter } from "@Model/Parameter"; interface IArchiveCtrlObject { + objectType: "R" | "G"; displayName: CtrlObject["displayName"]; color: CtrlObject["color"]; display: CtrlObject["display"]; update: CtrlObject["update"]; id: string; - renderParameter: any; + renderParameter: IArchiveParameterValue; deleteFlag: CtrlObject["deleteFlag"]; labels: IObjectParamArchiveType[]; } diff --git a/source/Model/Group.ts b/source/Model/Group.ts index bb3a970..fb3184e 100644 --- a/source/Model/Group.ts +++ b/source/Model/Group.ts @@ -4,7 +4,11 @@ import type { Behavior, IAnyBehavior } from "@Model/Behavior"; import { Label } from "@Model/Label"; import { Range } from "@Model/Range"; import { Model, ObjectID } from "@Model/Model"; -import { getDefaultValue, IArchiveParseFn, IObjectParamArchiveType, object2ArchiveObject } from "@Model/Parameter"; +import { IArchiveIndividual } from "@Model/Individual"; +import { + getDefaultValue, IArchiveParseFn, + IObjectParamArchiveType, object2ArchiveObject +} from "@Model/Parameter"; enum GenMod { Point = "p", @@ -12,6 +16,7 @@ enum GenMod { } interface IArchiveGroup { + individuals: IArchiveIndividual[]; genMethod: Group["genMethod"]; genPoint: Group["genPoint"]; genRange: IObjectParamArchiveType | undefined; @@ -421,6 +426,7 @@ class Group extends CtrlObject { public override toArchive(): IArchiveCtrlObject & IArchiveGroup { return { ...super.toArchive(), + objectType: "G", genMethod: this.genMethod, genPoint: this.genPoint.concat([]), genRange: object2ArchiveObject(this.genRange) as IObjectParamArchiveType, @@ -456,4 +462,4 @@ class Group extends CtrlObject { } } -export { Group, GenMod }; \ No newline at end of file +export { Group, GenMod, IArchiveGroup }; \ No newline at end of file diff --git a/source/Model/Individual.ts b/source/Model/Individual.ts index 96637fd..27fcb9c 100644 --- a/source/Model/Individual.ts +++ b/source/Model/Individual.ts @@ -243,4 +243,4 @@ class Individual { } } -export { Individual }; \ No newline at end of file +export { Individual, IArchiveIndividual }; \ No newline at end of file diff --git a/source/Model/Parameter.ts b/source/Model/Parameter.ts index 82aba18..6e4dc33 100644 --- a/source/Model/Parameter.ts +++ b/source/Model/Parameter.ts @@ -358,5 +358,6 @@ export { IParamType, IParamValue, isObjectType, isVectorType, getDefaultValue, IParameterOptionItem, IParameter, IParameterOption, IParameterValue, object2ArchiveObject, parameter2ArchiveObject, archiveObject2Parameter, - IArchiveParseFn, IObjectParamArchiveType, isArchiveObjectType + IArchiveParseFn, IObjectParamArchiveType, isArchiveObjectType, + IArchiveParameterValue } \ No newline at end of file diff --git a/source/Model/Range.ts b/source/Model/Range.ts index 7c0b39b..fece5d7 100644 --- a/source/Model/Range.ts +++ b/source/Model/Range.ts @@ -34,6 +34,7 @@ class Range extends CtrlObject { public override toArchive(): IArchiveCtrlObject & IArchiveRange { return { ...super.toArchive(), + objectType: "R", position: this.position.concat([]), radius: this.radius.concat([]) }; -- 2.45.2 From 430d8a725494bd22427dffcb0dc5b14f264cefb4 Mon Sep 17 00:00:00 2001 From: MrKBear Date: Sat, 23 Apr 2022 19:52:56 +0800 Subject: [PATCH 2/3] Add model archive function --- source/Component/HeaderBar/HeaderBar.tsx | 2 +- source/Context/Status.tsx | 4 +- source/Model/Archive.ts | 200 ++++++++++++++++++++--- source/Model/Behavior.ts | 12 +- source/Model/Group.ts | 5 + source/Model/Individual.ts | 10 +- source/Model/Parameter.ts | 29 ++-- 7 files changed, 213 insertions(+), 49 deletions(-) diff --git a/source/Component/HeaderBar/HeaderBar.tsx b/source/Component/HeaderBar/HeaderBar.tsx index b287681..8322029 100644 --- a/source/Component/HeaderBar/HeaderBar.tsx +++ b/source/Component/HeaderBar/HeaderBar.tsx @@ -123,7 +123,7 @@ class HeaderWindowsAction extends Component { * 头部信息栏 */ @useSettingWithEvent("language") -@useStatusWithEvent("fileChange") +@useStatusWithEvent("fileSave") class HeaderBar extends Component { public render(): ReactNode { diff --git a/source/Context/Status.tsx b/source/Context/Status.tsx index bc857ec..b9fa62f 100644 --- a/source/Context/Status.tsx +++ b/source/Context/Status.tsx @@ -30,7 +30,7 @@ function randomColor(unNormal: boolean = false) { } interface IStatusEvent { - fileChange: void; + fileSave: void; renderLoop: number; physicsLoop: number; mouseModChange: void; @@ -145,7 +145,7 @@ class Status extends Emitter { this.on("behaviorAttrChange", updateBehaviorParameter); // 映射文件状态改变事件 - this.archive.on("fileChange", () => this.emit("fileChange")); + this.archive.on("fileSave", () => this.emit("fileSave")); } public bindRenderer(renderer: AbstractRenderer) { diff --git a/source/Model/Archive.ts b/source/Model/Archive.ts index e446953..a0e1f84 100644 --- a/source/Model/Archive.ts +++ b/source/Model/Archive.ts @@ -1,13 +1,17 @@ import { Emitter, EventType } from "@Model/Emitter"; -import { IArchiveCtrlObject } from "@Model/CtrlObject"; +import { CtrlObject, IArchiveCtrlObject } from "@Model/CtrlObject"; import { Model } from "@Model/Model"; -import { IArchiveLabel } from "@Model/Label"; +import { IArchiveLabel, Label } from "@Model/Label"; import { Group, IArchiveGroup } from "@Model/Group"; -import { IArchiveIndividual } from "@Model/Individual"; -import { IArchiveBehavior } from "@Model/Behavior"; +import { Range } from "@Model/Range"; +import { IArchiveIndividual, Individual } from "@Model/Individual"; +import { Behavior, IArchiveBehavior } from "@Model/Behavior"; +import { getBehaviorById } from "@Behavior/Behavior"; +import { IArchiveParseFn, IObjectParamArchiveType, IRealObjectType } from "@Model/Parameter"; interface IArchiveEvent { - fileChange: Archive; + fileSave: Archive; + fileLoad: Archive; } interface IArchiveObject { @@ -17,10 +21,7 @@ interface IArchiveObject { behaviorPool: IArchiveBehavior[]; } -class Archive< - M extends any = any, - E extends Record = {} -> extends Emitter { +class Archive extends Emitter { /** * 是否为新文件 @@ -43,10 +44,9 @@ class Archive< public fileData?: M; /** - * 保存文件 - * 模型转换为文件 + * 将模型转换为存档对象 */ - public save(model: Model): string { + public parseModel2Archive(model: Model): string { // 存贮 CtrlObject const objectPool: IArchiveCtrlObject[] = []; @@ -89,21 +89,179 @@ class Archive< behaviorPool: behaviorPool }; - console.log(fileData); - console.log({value: JSON.stringify(fileData)}); + return JSON.stringify(fileData); + } + + /** + * 加载存档到模型 + */ + public loadArchiveIntoModel(model: Model, data: string): void { + + // 解析为 JSON 对象 + const archive: IArchiveObject = JSON.parse(data); + console.log(archive); + + // 实例化全部对象 + const objectPool: CtrlObject[] = []; + const individualPool: Individual[] = []; + archive.objectPool.forEach((obj) => { + + let ctrlObject: CtrlObject | undefined = undefined; + + // 处理群 + if (obj.objectType === "G") { + const archiveGroup: IArchiveGroup = obj as any; + const newGroup = new Group(model); + + // 实例化全部个体 + const individuals: Array = []; + archiveGroup.individuals.forEach((item) => { + const newIndividual = new Individual(newGroup); + newIndividual.id = item.id; + individuals.push(newIndividual); + individualPool.push(newIndividual); + }) + + newGroup.cacheIndividualsArray = individuals; + ctrlObject = newGroup; + } + + // 处理范围 + if (obj.objectType === "R") { + ctrlObject = new Range(model); + } + + if (ctrlObject) { + ctrlObject.id = obj.id; + objectPool.push(ctrlObject); + } + }); + + // 实例化全部标签 + const labelPool: Label[] = []; + archive.labelPool.forEach((item) => { + const newLabel = new Label(model); + newLabel.id = item.id; + labelPool.push(newLabel); + }); + + // 实例化全部行为 + const behaviorPool: Behavior[] = []; + archive.behaviorPool.forEach((item) => { + const recorder = getBehaviorById(item.behaviorId); + const newBehavior = recorder.new(); + newBehavior.id = item.id; + behaviorPool.push(newBehavior); + }); + + // 内置标签集合 + const buildInLabel = [model.allGroupLabel, model.allRangeLabel, model.currentGroupLabel] + + const search: (pool: T[], archive: IObjectParamArchiveType) => T | undefined = + (pool, archive) => { + for (let i = 0; i < pool.length; i++) { + if (pool[i].id === archive.__LIVING_TOGETHER_OBJECT_ID) { + return pool[i]; + } + } + + return undefined; + }; + + const searchAll: (archive: IObjectParamArchiveType) => IRealObjectType | undefined = + (archive) => { + return void 0 ?? + search(individualPool, archive) ?? + search(objectPool, archive) ?? + search(labelPool, archive) ?? + search(buildInLabel, archive) ?? + search(behaviorPool, archive); + } + + // 实例搜索函数 + const parseFunction: IArchiveParseFn = (archive) => { + + switch (archive.__LIVING_TOGETHER_OBJECT_TYPE) { + + // 在个体池搜索 + case "Individual": + return search(individualPool, archive) ?? searchAll(archive); + + // 对象类型在对象池中搜索 + case "Range": + case "Group": + return search(objectPool, archive) ?? searchAll(archive); + + // 在标签池搜索 + case "Label": + return search(labelPool, archive) ?? search(buildInLabel, archive) ?? searchAll(archive); + + // 在标签池搜索 + case "Behavior": + return search(behaviorPool, archive) ?? searchAll(archive); + + // 在全部池子搜索 + default: + return searchAll(archive); + } + } + + // 加载对象的属性 + model.objectPool = objectPool.map((obj, index) => { + + // 加载属性 + obj.fromArchive(archive.objectPool[index], parseFunction); + + // 加载个体属性 + if (obj instanceof Group) { + + const archiveGroup: IArchiveGroup = archive.objectPool[index] as any; + + obj.individuals = new Set(obj.cacheIndividualsArray.map((item, i) => { + item.fromArchive(archiveGroup.individuals[i], parseFunction); + return item; + })); + } + + return obj; + }); + + // 加载标签属性 + model.labelPool = labelPool.map((item, index) => { + item.fromArchive(archive.labelPool[index]); + return item; + }); + + // 加载行为属性 + model.behaviorPool = behaviorPool.map((item, index) => { + item.fromArchive(archive.behaviorPool[index], parseFunction); + return item; + }); + } + + /** + * 保存文件 + * 模型转换为文件 + */ + public save(model: Model): void { + + console.log(this.parseModel2Archive(model)); this.isSaved = true; - this.emit( ...["fileChange", this] as any ); - - return ""; + this.emit("fileSave", this); } /** * 加载文件为模型 - * return Model + * @return Model */ - public load(model: Model, data: string) {}; + public load(model: Model, data: string) { + + this.loadArchiveIntoModel(model, data); + + this.isSaved = true; + this.emit("fileLoad", this); + }; } -export { Archive }; -export default Archive; \ No newline at end of file +export { Archive }; \ No newline at end of file diff --git a/source/Model/Behavior.ts b/source/Model/Behavior.ts index ffdd9b4..0b84206 100644 --- a/source/Model/Behavior.ts +++ b/source/Model/Behavior.ts @@ -220,12 +220,12 @@ class Behavior< } public fromArchive(archive: IArchiveBehavior, paster: IArchiveParseFn): void { - this.name = this.name, - this.id = this.id, - this.color = this.color.concat([]), - this.priority = this.priority, - this.currentGroupKey = this.currentGroupKey.concat([]) as any, - this.deleteFlag = this.deleteFlag, + this.name = archive.name, + this.id = archive.id, + this.color = archive.color.concat([]), + this.priority = archive.priority, + this.currentGroupKey = archive.currentGroupKey.concat([]) as any, + this.deleteFlag = archive.deleteFlag, this.parameter = archiveObject2Parameter( archive.parameter, paster ) as any; diff --git a/source/Model/Group.ts b/source/Model/Group.ts index fb3184e..024b737 100644 --- a/source/Model/Group.ts +++ b/source/Model/Group.ts @@ -37,6 +37,11 @@ class Group extends CtrlObject { */ public individuals: Set = new Set(); + /** + * 缓存的 individuals 数组, 用于存档加载 + */ + public cacheIndividualsArray: Array = []; + /** * 个体生成方式 */ diff --git a/source/Model/Individual.ts b/source/Model/Individual.ts index 27fcb9c..d8685c7 100644 --- a/source/Model/Individual.ts +++ b/source/Model/Individual.ts @@ -234,11 +234,11 @@ class Individual { } } - this.id = this.id, - this.position = this.position.concat([]), - this.velocity = this.velocity.concat([]), - this.acceleration = this.acceleration.concat([]), - this.force = this.force.concat([]), + this.id = archive.id, + this.position = archive.position.concat([]), + this.velocity = archive.velocity.concat([]), + this.acceleration = archive.acceleration.concat([]), + this.force = archive.force.concat([]), this.metaData = metaData; } } diff --git a/source/Model/Parameter.ts b/source/Model/Parameter.ts index 6e4dc33..510b325 100644 --- a/source/Model/Parameter.ts +++ b/source/Model/Parameter.ts @@ -3,10 +3,11 @@ import { Range } from "@Model/Range"; import { Label } from "@Model/Label"; import { Behavior, IAnyBehavior } from "@Model/Behavior"; import { Individual } from "@Model/Individual"; +import { CtrlObject } from "@Model/CtrlObject"; type IObjectParamArchiveType = { __LIVING_TOGETHER_OBJECT_ID: string; - __LIVING_TOGETHER_OBJECT_TYPE: string; + __LIVING_TOGETHER_OBJECT_TYPE: "Individual" | "Range" | "Group" | "Label" | "Behavior"; } type IObjectParamCacheType = { @@ -225,36 +226,36 @@ function getDefaultValue

(option: IParameterOption

): IP return defaultObj; } -type IRealObjectType = Range | Group | Label | IAnyBehavior; +type IRealObjectType = Range | Group | Label | IAnyBehavior | Individual | CtrlObject; type IArchiveParseFn = (archive: IObjectParamArchiveType) => IRealObjectType | undefined; function object2ArchiveObject(object: IRealObjectType | IRealObjectType[] | any, testArray: boolean = true): IObjectParamArchiveType | IObjectParamArchiveType[] | undefined { if (object instanceof Individual) { return { - __LIVING_TOGETHER_OBJECT_ID: "Individual", - __LIVING_TOGETHER_OBJECT_TYPE: object.id + __LIVING_TOGETHER_OBJECT_ID: object.id, + __LIVING_TOGETHER_OBJECT_TYPE: "Individual" } } else if (object instanceof Range) { return { - __LIVING_TOGETHER_OBJECT_ID: "Range", - __LIVING_TOGETHER_OBJECT_TYPE: object.id + __LIVING_TOGETHER_OBJECT_ID: object.id, + __LIVING_TOGETHER_OBJECT_TYPE: "Range" } } else if (object instanceof Group) { return { - __LIVING_TOGETHER_OBJECT_ID: "Group", - __LIVING_TOGETHER_OBJECT_TYPE: object.id + __LIVING_TOGETHER_OBJECT_ID: object.id, + __LIVING_TOGETHER_OBJECT_TYPE: "Group" } } else if (object instanceof Label) { return { - __LIVING_TOGETHER_OBJECT_ID: "Label", - __LIVING_TOGETHER_OBJECT_TYPE: object.id + __LIVING_TOGETHER_OBJECT_ID: object.id, + __LIVING_TOGETHER_OBJECT_TYPE: "Label" } } else if (object instanceof Behavior) { return { - __LIVING_TOGETHER_OBJECT_ID: "Behavior", - __LIVING_TOGETHER_OBJECT_TYPE: object.id + __LIVING_TOGETHER_OBJECT_ID: object.id, + __LIVING_TOGETHER_OBJECT_TYPE: "Behavior" } } else if (Array.isArray(object) && testArray) { const hasValue = (item: any): item is IObjectParamArchiveType => !!item; @@ -322,7 +323,7 @@ function archiveObject2Parameter

(parameter[key] as any) = { picker: picker ? parse(picker) : picker, - objects: objects ? parse(objects) : objects + objects: objects ? Array.isArray(objects) ? objects.map(item => parse(item)) : parse(objects) : objects } } @@ -359,5 +360,5 @@ export { IParameterOptionItem, IParameter, IParameterOption, IParameterValue, object2ArchiveObject, parameter2ArchiveObject, archiveObject2Parameter, IArchiveParseFn, IObjectParamArchiveType, isArchiveObjectType, - IArchiveParameterValue + IArchiveParameterValue, IRealObjectType } \ No newline at end of file -- 2.45.2 From b498f0e0a4c7d4baf3cb8c1924461c9ea09c3a6d Mon Sep 17 00:00:00 2001 From: MrKBear Date: Sat, 23 Apr 2022 20:32:04 +0800 Subject: [PATCH 3/3] Add archive event --- source/Context/Status.tsx | 13 +++++++++++++ source/Page/SimulatorDesktop/SimulatorDesktop.tsx | 6 ++++-- source/Page/SimulatorWeb/SimulatorWeb.tsx | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/Context/Status.tsx b/source/Context/Status.tsx index b9fa62f..69f0dea 100644 --- a/source/Context/Status.tsx +++ b/source/Context/Status.tsx @@ -31,6 +31,7 @@ function randomColor(unNormal: boolean = false) { interface IStatusEvent { fileSave: void; + fileLoad: void; renderLoop: number; physicsLoop: number; mouseModChange: void; @@ -146,6 +147,18 @@ class Status extends Emitter { // 映射文件状态改变事件 this.archive.on("fileSave", () => this.emit("fileSave")); + + // 处理存档加载事件 + this.archive.on("fileLoad", () => { + + // 触发对象修改 + this.emit("objectChange"); + this.emit("labelChange"); + this.emit("behaviorChange"); + + // 映射 + this.emit("fileLoad"); + }) } public bindRenderer(renderer: AbstractRenderer) { diff --git a/source/Page/SimulatorDesktop/SimulatorDesktop.tsx b/source/Page/SimulatorDesktop/SimulatorDesktop.tsx index 55a6a50..7cb8347 100644 --- a/source/Page/SimulatorDesktop/SimulatorDesktop.tsx +++ b/source/Page/SimulatorDesktop/SimulatorDesktop.tsx @@ -55,8 +55,10 @@ class SimulatorDesktop extends Component { }) }; - (window as any).setting = this.setting; - (window as any).status = this.status; + (window as any).LT = { + status: this.status, + setting: this.setting + }; this.electron = {} as ISimulatorAPI; if ((window as any).API) { diff --git a/source/Page/SimulatorWeb/SimulatorWeb.tsx b/source/Page/SimulatorWeb/SimulatorWeb.tsx index 0414893..44b475d 100644 --- a/source/Page/SimulatorWeb/SimulatorWeb.tsx +++ b/source/Page/SimulatorWeb/SimulatorWeb.tsx @@ -76,7 +76,7 @@ class SimulatorWeb extends Component { } // 鱼群模型测试 - if (true) { + if (false) { let fish1 = this.status.newGroup(); let fish2 = this.status.newGroup(); let shark = this.status.newGroup(); -- 2.45.2