From d22814352b7185e7dca55ca80dd1131a5b4386fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Tue, 7 Sep 2021 06:30:41 +0000 Subject: [PATCH] =?UTF-8?q?!1608=20=E4=BC=98=E5=8C=96:=E7=BB=99=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E6=A0=B9=E6=8D=AE=E6=A0=8F=E7=9A=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/SyncData.ts | 8 ++++---- src/Editor/UserConfig.ts | 11 +++++++++-- src/Reactor/SyncDataReactor.ts | 6 +++--- src/UI/Components/ToolBar/ToolbarContainer.tsx | 5 +++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Add-on/SyncData.ts b/src/Add-on/SyncData.ts index 99b753fdc..6d6bf9007 100644 --- a/src/Add-on/SyncData.ts +++ b/src/Add-on/SyncData.ts @@ -1,11 +1,11 @@ import { Command } from "../Editor/CommandMachine"; -import { app } from "../ApplicationServices/Application"; +import { userConfig } from "../Editor/UserConfig"; export class Command_EnableSyncData implements Command { async exec() { - app.SyncDataReactor.Enable = true; + userConfig.synchronousEnable = true; } } @@ -13,7 +13,7 @@ export class Command_DisableSyncData implements Command { async exec() { - app.SyncDataReactor.Enable = false; + userConfig.synchronousEnable = false; } } @@ -21,6 +21,6 @@ export class Command_ToggleSyncData implements Command { exec() { - app.SyncDataReactor.Enable = !app.SyncDataReactor.Enable; + userConfig.synchronousEnable = !userConfig.synchronousEnable; } } diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index b1d2383ba..4afc53dbf 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -33,7 +33,7 @@ export interface ICursorConfig extends IBaseOption export class UserConfig implements IConfigStore { - private readonly _version = 18; + private readonly _version = 19; _renderType: RenderType = RenderType.Wireframe; @observable maxSize: IMaxSizeProps = { isShow: false, @@ -75,6 +75,7 @@ export class UserConfig implements IConfigStore @observable smalliconmode = false; //小图标模式 @observable dimensions: boolean = true; //显示板间尺寸 @observable switchBackground = true; //切换背景 + @observable synchronousEnable = false; //同步模式状态 @observable autoSaveConfig = { enable: true, time: 1, @@ -189,6 +190,7 @@ export class UserConfig implements IConfigStore this.smalliconmode = false; this.dimensions = true; this.switchBackground = false; + this.synchronousEnable = false; } SaveConfig() { @@ -220,7 +222,8 @@ export class UserConfig implements IConfigStore viewSize: toJS(this.viewSize), smalliconmode: this.smalliconmode, dimensions: this.dimensions, - switchBackground: this.switchBackground + switchBackground: this.switchBackground, + synchronousEnable: this.synchronousEnable, } }; } @@ -306,6 +309,10 @@ export class UserConfig implements IConfigStore { this.switchBackground = config.option.switchBackground; } + if (config.option.version > 18) + { + this.synchronousEnable = config.option.synchronousEnable; + } } } diff --git a/src/Reactor/SyncDataReactor.ts b/src/Reactor/SyncDataReactor.ts index 50ad11c7f..a2bd46772 100644 --- a/src/Reactor/SyncDataReactor.ts +++ b/src/Reactor/SyncDataReactor.ts @@ -7,6 +7,7 @@ import { CommandHistoryRecord } from "../DatabaseServices/CommandHistoryRecord"; import { CreateObjectData } from "../DatabaseServices/CreateObjectData"; import { Entity } from "../DatabaseServices/Entity/Entity"; import { RemoveObjectData } from "../DatabaseServices/RemoveObjectData"; +import { userConfig } from "../Editor/UserConfig"; export interface IncrementData { @@ -22,12 +23,11 @@ function IsSyncEntity(ent: CADObject): boolean export class SyncDataReactor { - Enable = false; constructor(private app: ApplicationService) { app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) => { - if (!this.Enable) return; + if (!userConfig.synchronousEnable) return; let changeEntitys: Entity[] = []; let deleteEntitys: Entity[] = []; @@ -55,7 +55,7 @@ export class SyncDataReactor { return (cmdName: string, historyRec: CommandHistoryRecord) => { - if (!this.Enable) return; + if (!userConfig.synchronousEnable) return; let createEntitys: Entity[] = []; let changeEntitys: Entity[] = []; diff --git a/src/UI/Components/ToolBar/ToolbarContainer.tsx b/src/UI/Components/ToolBar/ToolbarContainer.tsx index 49d195844..6467f7aea 100644 --- a/src/UI/Components/ToolBar/ToolbarContainer.tsx +++ b/src/UI/Components/ToolBar/ToolbarContainer.tsx @@ -5,6 +5,7 @@ import { end } from 'xaop'; import { app } from '../../../ApplicationServices/Application'; import { arrayRemoveIf } from '../../../Common/ArrayExt'; import { CommandNames } from '../../../Common/CommandNames'; +import { userConfig } from '../../../Editor/UserConfig'; import { IconEnum } from '../../IconEnum'; import { DownPanelStore, ToolBarType } from '../../Store/DownPanelStore'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; @@ -46,7 +47,7 @@ export class ToolbarContainer extends React.Component<{}, {}> { { if (isOk) { - if (app.SyncDataReactor.Enable) + if (userConfig.synchronousEnable) this.iconList.push({ svg: IconEnum.Synchronizing, title: "同步中", command: CommandNames.ToggleSyncData }); else this.iconList.push({ svg: IconEnum.Synchronous, title: "未同步", command: CommandNames.ToggleSyncData }); @@ -60,7 +61,7 @@ export class ToolbarContainer extends React.Component<{}, {}> { { let icon = this.iconList.find(icon => icon?.command === CommandNames.ToggleSyncData); if (icon) - if (app.SyncDataReactor.Enable) + if (userConfig.synchronousEnable) { icon.svg = IconEnum.Synchronizing; icon.title = "同步中";