!1974 优化:保存BBS输入框宽度

pull/1966/MERGE
黄诗津 2 years ago committed by ChenX
parent 899cf030c5
commit 540054aa4c

@ -36,7 +36,7 @@ export interface IUCSGridConfig extends IBaseOption
export class UserConfig implements IConfigStore export class UserConfig implements IConfigStore
{ {
private readonly _version = 29; //🌟🌟每次更新必须向上添加一次版本号🌟🌟 private readonly _version = 30; //🌟🌟每次更新必须向上添加一次版本号🌟🌟
_renderType: RenderType = RenderType.Wireframe; _renderType: RenderType = RenderType.Wireframe;
@observable maxSize: IMaxSizeProps = { @observable maxSize: IMaxSizeProps = {
isShow: false, isShow: false,
@ -86,6 +86,7 @@ export class UserConfig implements IConfigStore
@observable cabinetSpacing: number = 1000; //柜子移动到0点配置 柜子间距 @observable cabinetSpacing: number = 1000; //柜子移动到0点配置 柜子间距
@observable ConceptualEdgeColor = 7;//概念线框的颜色 @observable ConceptualEdgeColor = 7;//概念线框的颜色
@observable Physical2EdgeColor = 7;//真实视图带线框的线框颜色 默认白色 @observable Physical2EdgeColor = 7;//真实视图带线框的线框颜色 默认白色
@observable titleWidthMap: Map<string, number> = new Map();//保存BBS输入框宽度,刷新后重置
@observable autoSaveConfig = { @observable autoSaveConfig = {
enable: true, enable: true,
time: 1, time: 1,
@ -229,6 +230,7 @@ export class UserConfig implements IConfigStore
this.isOpenAxisSwitch = true; this.isOpenAxisSwitch = true;
this.isOpenCameraSetting = true; this.isOpenCameraSetting = true;
this.dxfImportBlock = false; this.dxfImportBlock = false;
this.titleWidthMap = new Map();
} }
SaveConfig() SaveConfig()
{ {
@ -274,7 +276,8 @@ export class UserConfig implements IConfigStore
UCSGridConfig: toJS(this.UCSGridConfig), UCSGridConfig: toJS(this.UCSGridConfig),
isOpenAxisSwitch: this.isOpenAxisSwitch, isOpenAxisSwitch: this.isOpenAxisSwitch,
isOpenCameraSetting: this.isOpenCameraSetting, isOpenCameraSetting: this.isOpenCameraSetting,
dxfImportBlock: this.dxfImportBlock dxfImportBlock: this.dxfImportBlock,
titleWidthMap: Object.fromEntries(this.titleWidthMap.entries())
} }
}; };
} }
@ -407,6 +410,10 @@ export class UserConfig implements IConfigStore
this.ConceptualEdgeColor = config.option.ConceptualEdgeColor; this.ConceptualEdgeColor = config.option.ConceptualEdgeColor;
this.Physical2EdgeColor = config.option.Physical2EdgeColor; this.Physical2EdgeColor = config.option.Physical2EdgeColor;
} }
if (config.option.version > 29)
{
this.titleWidthMap = new Map(Object.entries(config.option.titleWidthMap));
}
} }
} }

@ -13,6 +13,7 @@ import { ProcessingGroupRecord } from '../../../DatabaseServices/ProcessingGroup
import { TemplateLatticeRecord } from '../../../DatabaseServices/Template/ProgramTempate/TemplateLatticeRecord'; import { TemplateLatticeRecord } from '../../../DatabaseServices/Template/ProgramTempate/TemplateLatticeRecord';
import { TemplateWineRackRecord } from '../../../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord'; import { TemplateWineRackRecord } from '../../../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord';
import { TemplateRecord } from '../../../DatabaseServices/Template/TemplateRecord'; import { TemplateRecord } from '../../../DatabaseServices/Template/TemplateRecord';
import { userConfig } from '../../../Editor/UserConfig';
import { IHardwareType } from '../../../Production/Product'; import { IHardwareType } from '../../../Production/Product';
import { bbsEditorStore, TotalTabbarTitlesInfos } from '../../Store/BBSEditorStore'; import { bbsEditorStore, TotalTabbarTitlesInfos } from '../../Store/BBSEditorStore';
import { LinesType } from '../../Store/BoardInterface'; import { LinesType } from '../../Store/BoardInterface';
@ -27,10 +28,34 @@ export interface SortBtnData
export const SelectElementIndex = [6, 22, 23, 27]; export const SelectElementIndex = [6, 22, 23, 27];
interface ITitleBannerProps
{
sortBtnData: SortBtnData[],
style: any,
handleOrder: Function,
AutoWidth: (title: [string, string]) => void,
TitleResize: (e: React.PointerEvent<HTMLDivElement>, title: string) => void;
}
@observer @observer
export class TitleBanner extends React.Component<{ sortBtnData: SortBtnData[], style: any, handleOrder: Function, AutoWidth: (title: [string, string]) => void, TitleResize: (e: React.PointerEvent<HTMLDivElement>, title: string) => void; }, {}> export class TitleBanner extends React.Component<ITitleBannerProps>
{ {
icon: IconName; icon: IconName;
titleRef = React.createRef<HTMLDivElement>();
componentDidMount()
{
for (let index of bbsEditorStore.tabbarIndexs)
{
if (bbsEditorStore.noResize.some(i => i === index)) continue;
let title = TotalTabbarTitlesInfos[index][1];
if (!userConfig.titleWidthMap.has(title))
{
let titleElement = this.titleRef.current.getElementsByClassName(title);
let width = (titleElement[0] as HTMLDivElement).offsetWidth;
userConfig.titleWidthMap.set(title, width);
}
}
}
getBtnData = (data: string) => getBtnData = (data: string) =>
{ {
let btn = this.props.sortBtnData.find((d) => d.text === data.trim()); let btn = this.props.sortBtnData.find((d) => d.text === data.trim());
@ -39,10 +64,24 @@ export class TitleBanner extends React.Component<{ sortBtnData: SortBtnData[], s
this.icon = btn.icon; this.icon = btn.icon;
return true; return true;
}; };
getWidthStyle = (title: string, index: number): React.CSSProperties =>
{
return SelectElementIndex.includes(index) ?
{
minWidth: 73,
display: "flex"
} :
{
minWidth: 62,
display: "flex",
width: userConfig.titleWidthMap.has(title) ? userConfig.titleWidthMap.get(title) : "auto"
};
};
render() render()
{ {
return ( return (
<div className="bbs-list-tr title" style={{ ...this.props.style, width: "fit-content", position: "relative" }}> <div className="bbs-list-tr title" style={{ ...this.props.style, width: "fit-content", position: "relative" }} ref={this.titleRef}>
<div className="bbs-list-th bbs-td" style={{ marginRight: 3 }}></div> <div className="bbs-list-th bbs-td" style={{ marginRight: 3 }}></div>
{ {
bbsEditorStore.tabbarIndexs.map((index) => bbsEditorStore.tabbarIndexs.map((index) =>
@ -95,7 +134,7 @@ export class TitleBanner extends React.Component<{ sortBtnData: SortBtnData[], s
<div <div
className={`bbs-list-th bbs-td ${TotalTabbarTitlesInfos[index][1]}`} className={`bbs-list-th bbs-td ${TotalTabbarTitlesInfos[index][1]}`}
key={index} key={index}
style={{ minWidth: SelectElementIndex.includes(index) ? 73 : 62, display: "flex" }} style={this.getWidthStyle(key, index)}
> >
{ {
this.getBtnData(TotalTabbarTitlesInfos[index][0]) ? this.getBtnData(TotalTabbarTitlesInfos[index][0]) ?

@ -31,11 +31,14 @@ import { TemplateWineRackRecord } from "../../../DatabaseServices/Template/Progr
import { TemplateRecord } from "../../../DatabaseServices/Template/TemplateRecord"; import { TemplateRecord } from "../../../DatabaseServices/Template/TemplateRecord";
import { CommandWrap } from "../../../Editor/CommandMachine"; import { CommandWrap } from "../../../Editor/CommandMachine";
import { SelectSetBase } from "../../../Editor/SelectBase"; import { SelectSetBase } from "../../../Editor/SelectBase";
import { userConfig } from "../../../Editor/UserConfig";
import { equaln } from "../../../Geometry/GeUtils"; import { equaln } from "../../../Geometry/GeUtils";
import { IHardwareType } from "../../../Production/Product"; import { IHardwareType } from "../../../Production/Product";
import { bbsEditorStore, TotalTabbarTitlesInfos } from "../../Store/BBSEditorStore"; import { bbsEditorStore, TotalTabbarTitlesInfos } from "../../Store/BBSEditorStore";
import { EFindType } from "../../Store/BoardFindInterface"; import { EFindType } from "../../Store/BoardFindInterface";
import { ComposingType, FaceDirection, LinesType } from "../../Store/BoardInterface"; import { ComposingType, FaceDirection, LinesType } from "../../Store/BoardInterface";
import { userConfigStore } from "../../Store/UserConfigStore";
import { BoardModalType } from "../Board/BoardModalType";
import { InitRectBoardDrillOption, SetRectHighDrill } from "../Board/CommonBoardOption"; import { InitRectBoardDrillOption, SetRectHighDrill } from "../Board/CommonBoardOption";
import { GetCompoentObjectIdString } from "../ComponentObjectId"; import { GetCompoentObjectIdString } from "../ComponentObjectId";
import { ModalFooter, ModalHeader } from "../Modal/ModalContainer"; import { ModalFooter, ModalHeader } from "../Modal/ModalContainer";
@ -305,6 +308,7 @@ export class LookOverBoardInfosModal extends React.Component<LookOverBoardInfosM
} }
componentWillUnmount() componentWillUnmount()
{ {
userConfigStore.SaveConfig(BoardModalType.UserConfig, userConfig, { toaster: false });
for (let f of this.removeFuncs) for (let f of this.removeFuncs)
f(); f();
this.removeFuncs.length = 0; this.removeFuncs.length = 0;
@ -839,6 +843,7 @@ export class LookOverBoardInfosModal extends React.Component<LookOverBoardInfosM
target.onmouseup = () => target.onmouseup = () =>
{ {
this.SetTitleWidthMap(title, (titleElement[0] as HTMLDivElement).offsetWidth);
ismove = false; ismove = false;
clearTimeout(timer); clearTimeout(timer);
target.releasePointerCapture(e.pointerId); target.releasePointerCapture(e.pointerId);
@ -877,6 +882,13 @@ export class LookOverBoardInfosModal extends React.Component<LookOverBoardInfosM
{ {
(currentTitle[i] as HTMLDivElement).style.width = maxLenght * 12 + "px"; (currentTitle[i] as HTMLDivElement).style.width = maxLenght * 12 + "px";
} }
this.SetTitleWidthMap(title[1], maxLenght * 12 + 2);
};
SetTitleWidthMap = (title: string, value: number) =>
{
if (userConfig.titleWidthMap.get(title) !== value)
userConfig.titleWidthMap.set(title, value);
}; };
getCalcStyles = (key: string): React.CSSProperties => getCalcStyles = (key: string): React.CSSProperties =>

Loading…
Cancel
Save