!2218 修复:预览图默认西南及真实带线框颜色校验更改

pull/2220/head
林伟强 1 year ago committed by ChenX
parent aac767d484
commit 85b6b8bf31

@ -17,19 +17,26 @@ import "../../UI/Css/style.less";
import "../../UI/Css/switchTheme.less";
import { ShareViewLayout } from "./ShareViewLayout";
import { ViewAngleTypes, ViewStyleTypes } from "./ShareViewRules";
import { ICabinetFormatData } from "./ShareViewService";
import { ShareViewStore } from "./ShareViewStore";
import { ChangeThemeColor, GetBoxCovers, resetBoxView } from "./ShareViewUtil";
Cache.enabled = true;
interface ILoadData
{
cadFile: CADFiler;
urlSearch: URLSearchParams;
}
//禁止用户选中
document.addEventListener("selectionchange", () =>
{
let s = document.getSelection();
const s = document.getSelection();
if (s.anchorNode !== s.focusNode) s.empty();
else if (s.rangeCount > 0)
{
let range = s.getRangeAt(0);
const range = s.getRangeAt(0);
if (range.startContainer.nodeName === "#text" && s.focusNode.parentElement.contentEditable !== "true" && s.focusNode.parentElement.parentElement.contentEditable !== "true")
//#IZM3T
s.empty();
@ -117,9 +124,9 @@ document.addEventListener("keydown", (e: KeyboardEvent) =>
//接受所有输入框的快捷键(因为我们的输入框不多,如果输入框要避免响应,那么必须监听键盘按下事件,并且阻止默认和防止冒泡)
// hotkeys.filter = e => true;//我们将在inputhint中修改这个
window.onload = function ()
window.onload = async function ()
{
let el = document.getElementById("loader-wrapper");
const el = document.getElementById("loader-wrapper");
// el.remove();
function isWebGLAvailable()
{
@ -140,7 +147,7 @@ window.onload = function ()
const browser = detect();
if (browser.name === "chrome" || browser.name === "edge-chromium")
{
let ver = parseInt(browser.version.split(".")[0]);
const ver = parseInt(browser.version.split(".")[0]);
return ver > 85;
}
return true; //其他浏览器??
@ -148,8 +155,8 @@ window.onload = function ()
return false;
}
let isWebGlSupport = isWebGLAvailable();
let isChromeVerSupport = CheckChromeVer();
const isWebGlSupport = isWebGLAvailable();
const isChromeVerSupport = CheckChromeVer();
if (!isWebGlSupport || !isChromeVerSupport)
{
document.body.innerText = isWebGlSupport ? "您的浏览器版本过低!" : "您的浏览器不支持WebGL!";
@ -161,9 +168,9 @@ window.onload = function ()
font-size: 30px;
flex-direction: column;
`;
let herfEl = document.createElement("a");
const herfEl = document.createElement("a");
herfEl.innerText = "点击下载谷歌浏览器!";
let linkUrl = "https://www.google.cn/chrome/";
const linkUrl = "https://www.google.cn/chrome/";
herfEl.href = linkUrl;
document.body.append(herfEl);
window.open(linkUrl);
@ -189,62 +196,69 @@ window.onload = function ()
HostApplicationServices.ProxyObject = userConfig;
let layout = new ShareViewLayout();
const layout = new ShareViewLayout();
// 修改默认为概念渲染
commandMachine.ExecCommand(CommandNames.Conceptual);
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
try
{
LoadData().then(cadFile =>
const { cadFile, urlSearch } = await LoadData();
if (cadFile)
{
if (cadFile)
commandMachine.ExecCommand(CommandNames.Swiso); // 预览图默认西南
await layout.app.LoadFile(cadFile);
setTimeout(async () =>
{
// commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测
layout.app.LoadFile(cadFile).then(async () =>
const cabinetObj: ICabinetFormatData = {};
await GetBoxCovers((url, item, index) =>
{
setTimeout(async () =>
{
let obj = {};
await GetBoxCovers((url, item, index) =>
{
const roomName = item.roomName || '未命名';
let el = {
roomName: roomName,
item: item,
img: url,
index: index,
};
obj[roomName] ? obj[roomName].push(el) : obj[roomName] = [el];
});
ChangeThemeColor("light");
layout.app.BoxCtrl.SetCabinetFormatData(obj);
layout.app.BoxCtrl.SetBoxVisible(layout.app.BoxCtrl.BoxList.length - 1, false);
boxStore.RoomName = Object.keys(obj)[0];
// 展示第一个房间所有柜子
if (Object.keys(obj)[0])
{
const indexes = [];
obj[Object.keys(obj)[0]].forEach(item =>
{
indexes.push(item.index);
layout.app.BoxCtrl.SetBoxVisible(item.index, true);
});
boxStore.Index = indexes;
}
layout.app.Viewer.OnSize();
layout.app.Viewer.Render();
resetBoxView();
el.remove();
}, 1000);
const roomName = item.roomName || '未命名';
const cabinetItemData = {
roomName: roomName,
item: item,
img: url,
index: index,
};
cabinetObj[roomName] ? cabinetObj[roomName].push(cabinetItemData) : cabinetObj[roomName] = [cabinetItemData];
});
} else
{
ChangeThemeColor("light");
layout.app.BoxCtrl.SetCabinetFormatData(cabinetObj);
layout.app.BoxCtrl.SetBoxVisible(layout.app.BoxCtrl.BoxList.length - 1, false);
shareViewStore.RoomName = Object.keys(cabinetObj)[0];
// 展示第一个房间所有柜子
if (Object.keys(cabinetObj)[0])
{
const indexes: number[] = [];
cabinetObj[Object.keys(cabinetObj)[0]].forEach(item =>
{
indexes.push(item.index);
layout.app.BoxCtrl.SetBoxVisible(item.index, true);
});
shareViewStore.Index = indexes;
}
//预览图生成后视角跟随url
shareViewStore.viewUploadProps = {
...shareViewStore.viewUploadProps,
Viewport: safeEval(urlSearch.get("Viewport")),
};
const { Viewport } = shareViewStore.viewUploadProps;
const viewDirectionIndex = ViewAngleTypes.findIndex((v) => v.viewDirection === Viewport);
if (viewDirectionIndex > -1) commandMachine.ExecCommand(ViewAngleTypes[viewDirectionIndex].command);
else commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测
layout.app.Viewer.OnSize();
layout.app.Viewer.Render();
resetBoxView();
el.remove();
}
});
}, 1000);
}
else
el.remove();
} catch {
}
@ -261,64 +275,61 @@ window.onload = function ()
// };
async function LoadData()
async function LoadData(): Promise<{ cadFile: CADFiler; urlSearch: URLSearchParams; }>
{
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
let urlSearch = new URLSearchParams(location.search);
let viewId = urlSearch.get('view_id');
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
const urlSearch = new URLSearchParams(location.search);
const viewId = urlSearch.get('view_id');
InitShareConfiguration(urlSearch);
//需要先设置带线框颜色与视图样式
InitPartShareConfiguration(urlSearch);
if (viewId)
{
let res = await fetch(CURRENT_HOST + '/CAD-viewerDetail?view_id=' + viewId, {
const res = await fetch(CURRENT_HOST + '/CAD-viewerDetail?view_id=' + viewId, {
method: "GET",
// mode: "cors",
// credentials: "include",
// body:JSON.stringify({ view_id: viewId }),
});
let data = JSON.parse(await res.text());
const data = JSON.parse(await res.text());
if (data.err_code === RequestStatus.Ok)
{
// userConfig.uese = data.fileInfo.uese;
let file = JSON.parse(inflateBase64(data.fileInfo.file));
const file = JSON.parse(inflateBase64(data.fileInfo.file));
document.title = data.fileInfo.name;
if (data.fileInfo.props && Object.prototype.toString.call(data.fileInfo.props) === '[object Object]')
{
boxStore.Props = data.fileInfo.props;
shareViewStore.Props = data.fileInfo.props;
}
return new CADFiler(file);
return { cadFile: new CADFiler(file), urlSearch };
} else
{
boxStore.ViewIDErrorMsg = `${data.err_code}: ${data.err_msg}`;
shareViewStore.ViewIDErrorMsg = `${data.err_code}: ${data.err_msg}`;
}
} else
{
boxStore.ViewIDErrorMsg = `url缺少view_id参数`;
shareViewStore.ViewIDErrorMsg = `url缺少view_id参数`;
}
}
/*
//分享图纸url设置
//分享图纸url设置(视图样式及真实带线框颜色)
*/
function InitShareConfiguration(urlSearch: URLSearchParams)
function InitPartShareConfiguration(urlSearch: URLSearchParams)
{
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
boxStore.viewUploadProps = {
...boxStore.viewUploadProps,
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
shareViewStore.viewUploadProps = {
...shareViewStore.viewUploadProps,
VisualStyle: safeEval(urlSearch.get("VisualStyle")),
Viewport: safeEval(urlSearch.get("Viewport")),
Physical2EdgeColor: safeEval(urlSearch.get("Physical2EdgeColor")),
};
const { Viewport, VisualStyle, Physical2EdgeColor } = boxStore.viewUploadProps;
const { VisualStyle, Physical2EdgeColor } = shareViewStore.viewUploadProps;
const viewDirectionIndex = ViewAngleTypes.findIndex((v) => v.viewDirection === Viewport);
if (viewDirectionIndex > -1) commandMachine.ExecCommand(ViewAngleTypes[viewDirectionIndex].command);
else commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测
if (Physical2EdgeColor !== null) HostApplicationServices.Physical2EdgeColor = Physical2EdgeColor;
const viewStyleIndex = ViewStyleTypes.findIndex((v) => v.renderType === VisualStyle);
if (viewStyleIndex > -1) commandMachine.ExecCommand(ViewStyleTypes[viewStyleIndex].cmd);
if (Physical2EdgeColor) HostApplicationServices.Physical2EdgeColor = Physical2EdgeColor;
else commandMachine.ExecCommand(CommandNames.Conceptual);//默认概念样式
}

@ -45,7 +45,7 @@ export class ShareViewService extends ApplicationService
{
// WebSocket: WebSocketClientServer = null;
BoxCtrl: BoxService;
BoxCtrl: ShareService;
constructor()
{
super();
@ -273,7 +273,7 @@ export class ShareViewService extends ApplicationService
async LoadFile(f: CADFiler)
{
this.OpenFile(f);
this.BoxCtrl = new BoxService();
this.BoxCtrl = new ShareService();
await this.BoxCtrl.Init();
}
}
@ -285,11 +285,24 @@ class IgnoreAutoSave extends AutoSaveServer
export type BoxInfo = { [EBoardKeyList.RoomName]?: string;[EBoardKeyList.CabinetName]?: string; };
export class BoxService
export interface ICabinetFormatData
{
[key: number]: ICabinetItemData[];
}
export interface ICabinetItemData
{
roomName: string;
item: BoxInfo;
img: string;
index: number;
}
export class ShareService
{
_BoxList: BoxInfo[] = [];
_BoxDict: { [key: string]: Entity[]; } = {};
_CabinetFormatData: any = {};
_CabinetFormatData: ICabinetFormatData;
get CabinetFormatData()
{
return this._CabinetFormatData;
@ -298,7 +311,7 @@ export class BoxService
{
return this._BoxList;
}
async Init()
Init()
{
let ens: Entity[] = [];
for (let e of app.Database.ModelSpace.Entitys)
@ -363,17 +376,19 @@ export class BoxService
});
}
SetCabinetFormatData(data)
SetCabinetFormatData(data: ICabinetFormatData)
{
this._CabinetFormatData = data;
}
FilterEntities(index, predicate: (Entity) => boolean)
{
let key = this.GetEntityGroupKey(this.BoxList[index]);
return this._BoxDict[key].filter(predicate);
}
GetEntities(index)
//弃用
// FilterEntities(index, predicate: (Entity) => boolean)
// {
// let key = this.GetEntityGroupKey(this.BoxList[index]);
// return this._BoxDict[key].filter(predicate);
// }
GetEntities(index: number)
{
let key = this.GetEntityGroupKey(this.BoxList[index]);
return this._BoxDict[key];

@ -109,9 +109,8 @@ async function CanvasToBlob(canvas: HTMLCanvasElement): Promise<Blob>
}
export async function GetBoxCovers(callback: (url: string, item: BoxInfo, index) => void)
export async function GetBoxCovers(callback: (url: string, item: BoxInfo, index: number) => void)
{
let list = [];
const canvas = shareViewApp.Viewer.Renderer.domElement;
shareViewApp.Viewer.OnSize(100, 100);
for (let index = 0; index < shareViewApp.BoxCtrl.BoxList.length; index++)
@ -126,7 +125,6 @@ export async function GetBoxCovers(callback: (url: string, item: BoxInfo, index)
let item = shareViewApp.BoxCtrl.BoxList[index];
callback(url, item, index);
}
return list;
}
// 获取物料明细
@ -353,10 +351,10 @@ export function SPGetSpiteSize(board: Board)
// 物料明细表滚动
export function MaterialDetailScrollTo()
{
const boxStore = ShareViewStore.GetInstance();
if (boxStore.SelectedBoard && document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index))
const shareViewStore = ShareViewStore.GetInstance();
if (shareViewStore.SelectedBoard && document.querySelector('.sp-anchor-' + shareViewStore.SelectedBoard.objectId.Index))
{
document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index).scrollIntoView(true);
document.querySelector('.sp-anchor-' + shareViewStore.SelectedBoard.objectId.Index).scrollIntoView(true);
}
}

@ -10,19 +10,19 @@ import { ShareViewStore } from '../ShareViewStore';
const BoardHideIcon = () =>
{
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
// 隐藏板
function SetBoxVisibleHide()
{
boxStore.Index.forEach((el) =>
shareViewStore.Index.forEach((el) =>
{
shareViewApp.BoxCtrl.GetEntities(el).forEach((i) =>
{
// i.Visible = false;
if (i instanceof Board)
{
if (i.objectId.Index == boxStore.SelectedBoard.objectId.Index)
if (i.objectId.Index == shareViewStore.SelectedBoard.objectId.Index)
{
i.Visible = false;
// 排钻显示
@ -43,7 +43,7 @@ const BoardHideIcon = () =>
}
});
});
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
shareViewApp.Viewer.UpdateRender();
}
@ -52,7 +52,7 @@ const BoardHideIcon = () =>
return (
<>
{
boxStore.SelectedBoard ? (
shareViewStore.SelectedBoard ? (
<div onClick={SetBoxVisibleHide} className='sp-board-hide-icon'>
<Icon icon="eye-off" ></Icon>
</div>

@ -7,21 +7,21 @@ import { SPGetSpiteSize } from "../ShareViewUtil";
const BoardMessageWidget = (() =>
{
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
return useObserver(
() =>
{
if (boxStore.SelectedBoard)
if (shareViewStore.SelectedBoard)
{
const size = SPGetSpiteSize(boxStore.SelectedBoard);
const size = SPGetSpiteSize(shareViewStore.SelectedBoard);
return (
<div className="sp-board-msg">
<div>{boxStore.SelectedBoard.Name}</div>
<div>{shareViewStore.SelectedBoard.Name}</div>
<div>{size.height}</div>
<div>{size.width}</div>
<div>{size.thickness}</div>
<div>{boxStore.SelectedBoard.BoardProcessOption.color}</div>
<div>{shareViewStore.SelectedBoard.BoardProcessOption.color}</div>
</div>
);
} else

@ -2,7 +2,7 @@ import { Icon } from "@blueprintjs/core";
import React, { forwardRef, useImperativeHandle, useState } from "react";
import { CommandNames } from "../../../Common/CommandNames";
import { commandMachine } from "../../../Editor/CommandMachine";
import { shareViewApp } from "../ShareViewService";
import { ICabinetFormatData, shareViewApp } from "../ShareViewService";
import { ShareViewStore } from "../ShareViewStore";
import { resetBoxView } from "../ShareViewUtil";
import { CheckedSvg, CheckEmptySvg } from "./CommonSvgs";
@ -21,16 +21,16 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
const [visible, setVisible] = useState(false);
const [selectedTab, setSelectedTab] = useState('');
const [list, setList] = useState<any>({});
const [list, setList] = useState<ICabinetFormatData>({});
const [key, setKey] = useState<number>(0);
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
const [selectAll, setSelectAll] = useState(false);
// 判断是否全选状态
function isSelectAll(roomName: string)
{
let obj = shareViewApp.BoxCtrl.CabinetFormatData || {};
if (obj[roomName].length != boxStore.Index.length)
if (obj[roomName].length != shareViewStore.Index.length)
{
setSelectAll(false);
} else
@ -38,7 +38,7 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
let flag = true;
for (const el of obj[roomName])
{
if (!boxStore.Index.includes(el.index))
if (!shareViewStore.Index.includes(el.index))
{
flag = false;
break;
@ -52,12 +52,12 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
show: async () =>
{
let obj = shareViewApp.BoxCtrl.CabinetFormatData || {};
let cabinetObj = shareViewApp.BoxCtrl.CabinetFormatData || {};
const len = shareViewApp.BoxCtrl.BoxList.length;
if (len && Object.keys(list).length === 0)
{
setSelectedTab(Object.keys(obj)[0]);
setList(obj);
setSelectedTab(Object.keys(cabinetObj)[0]);
setList(cabinetObj);
setVisible(true);
} else if (Object.keys(list).length)
{
@ -66,7 +66,7 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
SPToaster.show({ message: "没有柜体" });
}
isSelectAll(boxStore.RoomName);
isSelectAll(shareViewStore.RoomName);
},
})
);
@ -112,14 +112,14 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
await commandMachine.ExecCommand(CommandNames.SelectAll);
await commandMachine.ExecCommand(CommandNames.HideSelect);
// await commandMachine.ExecCommand(CommandNames.Swiso); //切换柜体不切换默认视图
boxStore.Index.forEach((el) =>
shareViewStore.Index.forEach((el) =>
{
shareViewApp.BoxCtrl.SetBoxVisible(el, true);
});
shareViewApp.Editor.UpdateScreen();
resetBoxView();
setKey(key + 1);
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
}
return (
@ -158,14 +158,14 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
indexes.push(item.index);
});
}
boxStore.Index = indexes;
boxStore.RoomName = selectedTab;
shareViewStore.Index = indexes;
shareViewStore.RoomName = selectedTab;
await showCabinet();
setSelectAll(!selectAll);
}
}}>
{
selectAll ? <CheckedSvg></CheckedSvg> : <CheckEmptySvg></CheckEmptySvg>
selectAll ? <CheckedSvg /> : <CheckEmptySvg />
}
</span>
@ -199,28 +199,28 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
return (
<div key={`${item.item.cabinetName}_${key}`}
className={`sp-tab-view-item
${boxStore.RoomName == selectedTab && boxStore.Index.includes(item.index) ? 'active' : ''}`}
${shareViewStore.RoomName == selectedTab && shareViewStore.Index.includes(item.index) ? 'active' : ''}`}
onClick={async () =>
{
if (boxStore.RoomName == item.roomName)
if (shareViewStore.RoomName == item.roomName)
{
if (boxStore.Index.includes(item.index))
if (shareViewStore.Index.includes(item.index))
{
if (boxStore.Index.length > 1)
if (shareViewStore.Index.length > 1)
{
boxStore.Index.splice(boxStore.Index.indexOf(item.index), 1);
shareViewStore.Index.splice(shareViewStore.Index.indexOf(item.index), 1);
}
} else
{
boxStore.Index.push(item.index);
shareViewStore.Index.push(item.index);
}
} else
{
boxStore.RoomName = item.roomName;
boxStore.Index = [item.index];
shareViewStore.RoomName = item.roomName;
shareViewStore.Index = [item.index];
}
await showCabinet();
setSelectAll(boxStore.Index.length == list[item.roomName].length);
setSelectAll(shareViewStore.Index.length == list[item.roomName].length);
}}
>
<div className="sp-tab-view-item-logo">

@ -14,11 +14,11 @@ const ExplosionMapWidget: React.FC<IProps> = forwardRef((props, ref) =>
{
const [state, setState] = useState(false);
const loadingRef = useRef(false);
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
async function changeDoorState(num: number)
{
for (const i of boxStore.Index)
for (const i of shareViewStore.Index)
{
await ExplosionView(i, num);
}
@ -26,7 +26,7 @@ const ExplosionMapWidget: React.FC<IProps> = forwardRef((props, ref) =>
async function openOrClose()
{
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
if (loadingRef.current) return;
props.loading(true);
loadingRef.current = true;

@ -28,7 +28,7 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
// 判断是否加载过
const flagRef = useRef<boolean>(false);
const bottomSheetRef = useRef<any>(null);
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
useImperativeHandle(ref, () => (
{
@ -37,7 +37,7 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
flagRef.current = true;
// const temp = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(ShareViewStore.GetInstance().index)) || [];
const temp = [];
boxStore.Index.forEach((i) =>
shareViewStore.Index.forEach((i) =>
{
const { boardList, hardwareCompositeList, hardwareToplineList } = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(i));
let cabinetName = '';
@ -123,9 +123,9 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
function checkBoardHasSelected(item: Board)
{
if (boxStore.SelectedBoard)
if (shareViewStore.SelectedBoard)
{
return boxStore.SelectedBoard == item;
return shareViewStore.SelectedBoard == item;
} else
{
return false;
@ -160,13 +160,13 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
<div className="sp-material-sheet-title-box">
<span
className="sp-material-sheet-material-name"
>{boxStore.RoomName} </span>
>{shareViewStore.RoomName} </span>
<span
className="sp-material-sheet-cancel"
onClick={() =>
{
shareViewApp.Editor.SelectCtrl.Cancel();
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
}}
></span>
<i className="sp-material-sheet-drag"
@ -219,10 +219,10 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
if (checkBoardHasSelected(item))
{
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
} else
{
boxStore.SelectedBoard = item;
shareViewStore.SelectedBoard = item;
}
}}
>

@ -38,7 +38,7 @@ function ShareViewUI()
const cabinetBottomSheetRef = useRef<any>(null);
const explosionMapWidgetRef = useRef<any>(null);
const materialBottomSheetRef = useRef<any>(null);
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
// 按下 esc
function escKeyDown(event)
@ -72,7 +72,7 @@ function ShareViewUI()
// 检查是否有门
function checkHasDoor()
{
for (const el of boxStore.Index)
for (const el of shareViewStore.Index)
{
let list = shareViewApp.BoxCtrl.GetEntities(el)
.filter((ent) => IsDrawer(ent) || IsLattice(ent) || IsDoor(ent) || IsHandle(ent) || (ent instanceof Hole && ent.ColorIndex !== 4));
@ -134,7 +134,7 @@ function ShareViewUI()
shareViewApp.Editor.GetStringService.Cancel();
} else
{
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
commandMachine.ExecCommand(CommandNames.SelectAll).then(() =>
{
ForbiddenToaster(async () =>
@ -159,7 +159,7 @@ function ShareViewUI()
await checkDoorAnimationEnd();
setDoorOpen(false);
}
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
await SwitchDoor(!doorShow);
setLoading(false);
setDoorShow(!doorShow);
@ -175,28 +175,28 @@ function ShareViewUI()
// 还原之前的主题背景色
function resetPrevTheme()
{
if (boxStore.ThemeLog)
if (shareViewStore.ThemeLog)
{
boxStore.Theme = boxStore.ThemeLog;
ChangeThemeColor(boxStore.ThemeLog);
shareViewStore.Theme = shareViewStore.ThemeLog;
ChangeThemeColor(shareViewStore.ThemeLog);
}
}
// 标注显示 隐藏
async function dimBrsShowOrHide()
{
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
if (dimBrsState)
{
resetPrevTheme();
await DeleteBoxDim();
} else
{
if (boxStore.Theme == 'light')
if (shareViewStore.Theme == 'light')
{
boxStore.ThemeLog = boxStore.Theme;
shareViewStore.ThemeLog = shareViewStore.Theme;
ChangeThemeColor('dark');
boxStore.Theme = "dark";
shareViewStore.Theme = "dark";
}
await CreateBoxDim();
}
@ -206,7 +206,7 @@ function ShareViewUI()
// 还原
async function resetAll()
{
boxStore.SelectedBoard = null;
shareViewStore.SelectedBoard = null;
if (dimBrsState)
{
await DeleteBoxDim();
@ -216,7 +216,7 @@ function ShareViewUI()
await explosionMapWidgetRef.current.reset();
await showDoor();
commandMachine.ExecCommand(CommandNames.Esc);
boxStore.Index.forEach(el =>
shareViewStore.Index.forEach(el =>
{
shareViewApp.BoxCtrl.SetBoxVisible(el, true);
});
@ -233,14 +233,14 @@ function ShareViewUI()
{
return (
<>
{boxStore.Props.showBom == false ? null : (
{shareViewStore.Props.showBom == false ? null : (
<div
// className={`${selectMaterial ? 'active' : ''}`}
onClick={() =>
{
materialBottomSheetRef.current.show();
}}
>{boxStore.Props.showBom}</div>
>{shareViewStore.Props.showBom}</div>
)}
</>
);
@ -251,7 +251,7 @@ function ShareViewUI()
return (
<React.Fragment>
<Provider store={ShareViewStore}>
<ViewIDErrorWidget></ViewIDErrorWidget>
<ViewIDErrorWidget />
<div className={`sp-loading-mask ${loading ? 'open' : ''}`}></div>
<div className="sp-bottom-container">
<div
@ -280,19 +280,20 @@ function ShareViewUI()
></div>
</div>
{/* 侧边栏 */}
<SideBar></SideBar>
<SideBar />
{/* 选中的板信息 */}
<BoardMessageWidget></BoardMessageWidget>
<BoardMessageWidget />
{/* 顶部栏 */}
<div className="sp-top-container">
<ViewAngle closeDoor={closeDoor} currentViewDirection={boxStore.viewUploadProps.Viewport} />
<ViewAngle closeDoor={closeDoor} currentViewDirection={shareViewStore.viewUploadProps.Viewport} />
<ViewStyle
reset={async () =>
{
await closeDoor();
await explosionMapWidgetRef.current.reset();
}}
currentRenderType={boxStore.viewUploadProps.VisualStyle} />
currentRenderType={shareViewStore.viewUploadProps.VisualStyle}
/>
<div className={`sp-top-btn ${dimBrsState ? 'active' : ''}`} onClick={dimBrsShowOrHide}></div>
{/* <div className="sp-top-btn">编号</div> */}
</div>
@ -313,14 +314,14 @@ function ShareViewUI()
await showDoor();
setDimBrsState(false);
}} ref={cabinetBottomSheetRef}
></CabinetBottomSheet>
/>
<MaterialBottomSheet
cancelCallback={() =>
{
// setSelectMaterial(false);
}}
ref={materialBottomSheetRef}
></MaterialBottomSheet>
/>
</Provider>
</React.Fragment>
);

@ -11,8 +11,8 @@ const SideBar = () =>
{
return (
<div className="sp-side-container">
<ThemeButton></ThemeButton>
<ShareWidget></ShareWidget>
<ThemeButton />
<ShareWidget />
{
[
{
@ -43,11 +43,13 @@ const SideBar = () =>
shareViewApp.Viewer.UpdateRender();
resetBoxView();
}}
>{item.name}</span>
>
{item.name}
</span>
);
})
}
<BoardHideIcon></BoardHideIcon>
<BoardHideIcon />
</div>
);
};

@ -6,19 +6,19 @@ import { ChangeThemeColor } from "../ShareViewUtil";
function ThemeButton()
{
const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
function changeTheme()
{
const t = boxStore.Theme === 'light' ? 'dark' : 'light';
boxStore.Theme = t;
boxStore.ThemeLog = '';
const t = shareViewStore.Theme === 'light' ? 'dark' : 'light';
shareViewStore.Theme = t;
shareViewStore.ThemeLog = '';
ChangeThemeColor(t);
shareViewApp.Editor.UpdateScreen();
}
return useObserver(() =>
{
return (
<div className="sp-view-angle-icon" onClick={changeTheme}>{boxStore.Theme == "light" ? '白' : '黑'}</div>
<div className="sp-view-angle-icon" onClick={changeTheme}>{shareViewStore.Theme == "light" ? '白' : '黑'}</div>
);
});

@ -14,7 +14,7 @@ const ViewStyle: React.FC<IProps> = forwardRef((props) =>
{
const [visible, setVisible] = useState<boolean>(false);
const [selected, setSelected] = useState<string>('概念');
const selectDivRef = useRef<any>();
const selectDivRef = useRef<HTMLDivElement>();
const hideSelect = (e) =>
{

Loading…
Cancel
Save