!1608 优化:给左侧根据栏的同步按钮添加同步配置

pull/1625/MERGE
黄诗津 3 years ago committed by ChenX
parent d79d688330
commit d22814352b

@ -1,11 +1,11 @@
import { Command } from "../Editor/CommandMachine"; import { Command } from "../Editor/CommandMachine";
import { app } from "../ApplicationServices/Application"; import { userConfig } from "../Editor/UserConfig";
export class Command_EnableSyncData implements Command export class Command_EnableSyncData implements Command
{ {
async exec() async exec()
{ {
app.SyncDataReactor.Enable = true; userConfig.synchronousEnable = true;
} }
} }
@ -13,7 +13,7 @@ export class Command_DisableSyncData implements Command
{ {
async exec() async exec()
{ {
app.SyncDataReactor.Enable = false; userConfig.synchronousEnable = false;
} }
} }
@ -21,6 +21,6 @@ export class Command_ToggleSyncData implements Command
{ {
exec() exec()
{ {
app.SyncDataReactor.Enable = !app.SyncDataReactor.Enable; userConfig.synchronousEnable = !userConfig.synchronousEnable;
} }
} }

@ -33,7 +33,7 @@ export interface ICursorConfig extends IBaseOption
export class UserConfig implements IConfigStore export class UserConfig implements IConfigStore
{ {
private readonly _version = 18; private readonly _version = 19;
_renderType: RenderType = RenderType.Wireframe; _renderType: RenderType = RenderType.Wireframe;
@observable maxSize: IMaxSizeProps = { @observable maxSize: IMaxSizeProps = {
isShow: false, isShow: false,
@ -75,6 +75,7 @@ export class UserConfig implements IConfigStore
@observable smalliconmode = false; //小图标模式 @observable smalliconmode = false; //小图标模式
@observable dimensions: boolean = true; //显示板间尺寸 @observable dimensions: boolean = true; //显示板间尺寸
@observable switchBackground = true; //切换背景 @observable switchBackground = true; //切换背景
@observable synchronousEnable = false; //同步模式状态
@observable autoSaveConfig = { @observable autoSaveConfig = {
enable: true, enable: true,
time: 1, time: 1,
@ -189,6 +190,7 @@ export class UserConfig implements IConfigStore
this.smalliconmode = false; this.smalliconmode = false;
this.dimensions = true; this.dimensions = true;
this.switchBackground = false; this.switchBackground = false;
this.synchronousEnable = false;
} }
SaveConfig() SaveConfig()
{ {
@ -220,7 +222,8 @@ export class UserConfig implements IConfigStore
viewSize: toJS(this.viewSize), viewSize: toJS(this.viewSize),
smalliconmode: this.smalliconmode, smalliconmode: this.smalliconmode,
dimensions: this.dimensions, 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; this.switchBackground = config.option.switchBackground;
} }
if (config.option.version > 18)
{
this.synchronousEnable = config.option.synchronousEnable;
}
} }
} }

@ -7,6 +7,7 @@ import { CommandHistoryRecord } from "../DatabaseServices/CommandHistoryRecord";
import { CreateObjectData } from "../DatabaseServices/CreateObjectData"; import { CreateObjectData } from "../DatabaseServices/CreateObjectData";
import { Entity } from "../DatabaseServices/Entity/Entity"; import { Entity } from "../DatabaseServices/Entity/Entity";
import { RemoveObjectData } from "../DatabaseServices/RemoveObjectData"; import { RemoveObjectData } from "../DatabaseServices/RemoveObjectData";
import { userConfig } from "../Editor/UserConfig";
export interface IncrementData export interface IncrementData
{ {
@ -22,12 +23,11 @@ function IsSyncEntity(ent: CADObject): boolean
export class SyncDataReactor export class SyncDataReactor
{ {
Enable = false;
constructor(private app: ApplicationService) constructor(private app: ApplicationService)
{ {
app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) => app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) =>
{ {
if (!this.Enable) return; if (!userConfig.synchronousEnable) return;
let changeEntitys: Entity[] = []; let changeEntitys: Entity[] = [];
let deleteEntitys: Entity[] = []; let deleteEntitys: Entity[] = [];
@ -55,7 +55,7 @@ export class SyncDataReactor
{ {
return (cmdName: string, historyRec: CommandHistoryRecord) => return (cmdName: string, historyRec: CommandHistoryRecord) =>
{ {
if (!this.Enable) return; if (!userConfig.synchronousEnable) return;
let createEntitys: Entity[] = []; let createEntitys: Entity[] = [];
let changeEntitys: Entity[] = []; let changeEntitys: Entity[] = [];

@ -5,6 +5,7 @@ import { end } from 'xaop';
import { app } from '../../../ApplicationServices/Application'; import { app } from '../../../ApplicationServices/Application';
import { arrayRemoveIf } from '../../../Common/ArrayExt'; import { arrayRemoveIf } from '../../../Common/ArrayExt';
import { CommandNames } from '../../../Common/CommandNames'; import { CommandNames } from '../../../Common/CommandNames';
import { userConfig } from '../../../Editor/UserConfig';
import { IconEnum } from '../../IconEnum'; import { IconEnum } from '../../IconEnum';
import { DownPanelStore, ToolBarType } from '../../Store/DownPanelStore'; import { DownPanelStore, ToolBarType } from '../../Store/DownPanelStore';
import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface';
@ -46,7 +47,7 @@ export class ToolbarContainer extends React.Component<{}, {}> {
{ {
if (isOk) if (isOk)
{ {
if (app.SyncDataReactor.Enable) if (userConfig.synchronousEnable)
this.iconList.push({ svg: IconEnum.Synchronizing, title: "同步中", command: CommandNames.ToggleSyncData }); this.iconList.push({ svg: IconEnum.Synchronizing, title: "同步中", command: CommandNames.ToggleSyncData });
else else
this.iconList.push({ svg: IconEnum.Synchronous, title: "未同步", command: CommandNames.ToggleSyncData }); 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); let icon = this.iconList.find(icon => icon?.command === CommandNames.ToggleSyncData);
if (icon) if (icon)
if (app.SyncDataReactor.Enable) if (userConfig.synchronousEnable)
{ {
icon.svg = IconEnum.Synchronizing; icon.svg = IconEnum.Synchronizing;
icon.title = "同步中"; icon.title = "同步中";

Loading…
Cancel
Save