From 85b6b8bf3199d74a83205664652fc2e17815a5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=BC=9F=E5=BC=BA?= Date: Tue, 16 May 2023 07:06:26 +0000 Subject: [PATCH] =?UTF-8?q?!2218=20=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=9B=BE=E9=BB=98=E8=AE=A4=E8=A5=BF=E5=8D=97=E5=8F=8A?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E5=B8=A6=E7=BA=BF=E6=A1=86=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/ShareView/ShareViewEntry.tsx | 167 ++++++++++-------- src/Add-on/ShareView/ShareViewService.ts | 39 ++-- src/Add-on/ShareView/ShareViewUtil.ts | 10 +- .../ShareView/components/BoardHideIcon.tsx | 10 +- .../components/BoardMessageWidget.tsx | 10 +- .../components/CabinetBottomSheet.tsx | 46 ++--- .../components/ExplosionMapWidget.tsx | 6 +- .../components/MaterialBottomSheet.tsx | 16 +- .../ShareView/components/ShareViewUI.tsx | 45 ++--- src/Add-on/ShareView/components/SideBar.tsx | 10 +- .../ShareView/components/ThemeButton.tsx | 10 +- src/Add-on/ShareView/components/ViewStyle.tsx | 2 +- 12 files changed, 199 insertions(+), 172 deletions(-) diff --git a/src/Add-on/ShareView/ShareViewEntry.tsx b/src/Add-on/ShareView/ShareViewEntry.tsx index db1a9a44e..8c4ea6c5a 100644 --- a/src/Add-on/ShareView/ShareViewEntry.tsx +++ b/src/Add-on/ShareView/ShareViewEntry.tsx @@ -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);//默认概念样式 } diff --git a/src/Add-on/ShareView/ShareViewService.ts b/src/Add-on/ShareView/ShareViewService.ts index 160a9e72c..d0533a061 100644 --- a/src/Add-on/ShareView/ShareViewService.ts +++ b/src/Add-on/ShareView/ShareViewService.ts @@ -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]; diff --git a/src/Add-on/ShareView/ShareViewUtil.ts b/src/Add-on/ShareView/ShareViewUtil.ts index 820ac3b40..1bb74d8bc 100644 --- a/src/Add-on/ShareView/ShareViewUtil.ts +++ b/src/Add-on/ShareView/ShareViewUtil.ts @@ -109,9 +109,8 @@ async function CanvasToBlob(canvas: HTMLCanvasElement): Promise } -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); } } diff --git a/src/Add-on/ShareView/components/BoardHideIcon.tsx b/src/Add-on/ShareView/components/BoardHideIcon.tsx index ce5e6eb37..6054f4817 100644 --- a/src/Add-on/ShareView/components/BoardHideIcon.tsx +++ b/src/Add-on/ShareView/components/BoardHideIcon.tsx @@ -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 ? (
diff --git a/src/Add-on/ShareView/components/BoardMessageWidget.tsx b/src/Add-on/ShareView/components/BoardMessageWidget.tsx index 71e8851d2..213429223 100644 --- a/src/Add-on/ShareView/components/BoardMessageWidget.tsx +++ b/src/Add-on/ShareView/components/BoardMessageWidget.tsx @@ -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 (
-
{boxStore.SelectedBoard.Name}
+
{shareViewStore.SelectedBoard.Name}
高度:{size.height}
宽度:{size.width}
厚度:{size.thickness}
-
颜色:{boxStore.SelectedBoard.BoardProcessOption.color}
+
颜色:{shareViewStore.SelectedBoard.BoardProcessOption.color}
); } else diff --git a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx index dc579f7df..060f430a5 100644 --- a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx +++ b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx @@ -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 = forwardRef((props, ref) => { const [visible, setVisible] = useState(false); const [selectedTab, setSelectedTab] = useState(''); - const [list, setList] = useState({}); + const [list, setList] = useState({}); const [key, setKey] = useState(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 = 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 = 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 = forwardRef((props, ref) => { SPToaster.show({ message: "没有柜体" }); } - isSelectAll(boxStore.RoomName); + isSelectAll(shareViewStore.RoomName); }, }) ); @@ -112,14 +112,14 @@ const CabinetBottomSheet: React.FC = 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 = forwardRef((props, ref) => indexes.push(item.index); }); } - boxStore.Index = indexes; - boxStore.RoomName = selectedTab; + shareViewStore.Index = indexes; + shareViewStore.RoomName = selectedTab; await showCabinet(); setSelectAll(!selectAll); } }}> { - selectAll ? : + selectAll ? : } 全选房间柜子 @@ -199,28 +199,28 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => return (
{ - 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); }} >
diff --git a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx b/src/Add-on/ShareView/components/ExplosionMapWidget.tsx index 011ea4a85..22252c3c3 100644 --- a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx +++ b/src/Add-on/ShareView/components/ExplosionMapWidget.tsx @@ -14,11 +14,11 @@ const ExplosionMapWidget: React.FC = 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 = forwardRef((props, ref) => async function openOrClose() { - boxStore.SelectedBoard = null; + shareViewStore.SelectedBoard = null; if (loadingRef.current) return; props.loading(true); loadingRef.current = true; diff --git a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx index 374857bc0..9972e84aa 100644 --- a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx +++ b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx @@ -28,7 +28,7 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => // 判断是否加载过 const flagRef = useRef(false); const bottomSheetRef = useRef(null); - const boxStore: ShareViewStore = ShareViewStore.GetInstance(); + const shareViewStore: ShareViewStore = ShareViewStore.GetInstance(); useImperativeHandle(ref, () => ( { @@ -37,7 +37,7 @@ const MaterialBottomSheet: React.FC = 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 = 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 = forwardRef((props, ref) =>
{boxStore.RoomName} 房间物料明细 + >{shareViewStore.RoomName} 房间物料明细 { shareViewApp.Editor.SelectCtrl.Cancel(); - boxStore.SelectedBoard = null; + shareViewStore.SelectedBoard = null; }} >取消选择 = forwardRef((props, ref) => { if (checkBoardHasSelected(item)) { - boxStore.SelectedBoard = null; + shareViewStore.SelectedBoard = null; } else { - boxStore.SelectedBoard = item; + shareViewStore.SelectedBoard = item; } }} > diff --git a/src/Add-on/ShareView/components/ShareViewUI.tsx b/src/Add-on/ShareView/components/ShareViewUI.tsx index a9678c341..bcec5a016 100644 --- a/src/Add-on/ShareView/components/ShareViewUI.tsx +++ b/src/Add-on/ShareView/components/ShareViewUI.tsx @@ -38,7 +38,7 @@ function ShareViewUI() const cabinetBottomSheetRef = useRef(null); const explosionMapWidgetRef = useRef(null); const materialBottomSheetRef = useRef(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 : (
{ materialBottomSheetRef.current.show(); }} - >物料明细{boxStore.Props.showBom}
+ >物料明细{shareViewStore.Props.showBom}
)} ); @@ -251,7 +251,7 @@ function ShareViewUI() return ( - +
还原
{/* 侧边栏 */} - + {/* 选中的板信息 */} - + {/* 顶部栏 */}
- + { await closeDoor(); await explosionMapWidgetRef.current.reset(); }} - currentRenderType={boxStore.viewUploadProps.VisualStyle} /> + currentRenderType={shareViewStore.viewUploadProps.VisualStyle} + />
标注
{/*
编号
*/}
@@ -313,14 +314,14 @@ function ShareViewUI() await showDoor(); setDimBrsState(false); }} ref={cabinetBottomSheetRef} - > + /> { // setSelectMaterial(false); }} ref={materialBottomSheetRef} - > + />
); diff --git a/src/Add-on/ShareView/components/SideBar.tsx b/src/Add-on/ShareView/components/SideBar.tsx index 9b50d7b32..47f1e1c04 100644 --- a/src/Add-on/ShareView/components/SideBar.tsx +++ b/src/Add-on/ShareView/components/SideBar.tsx @@ -11,8 +11,8 @@ const SideBar = () => { return (
- - + + { [ { @@ -43,11 +43,13 @@ const SideBar = () => shareViewApp.Viewer.UpdateRender(); resetBoxView(); }} - >{item.name} + > + {item.name} + ); }) } - +
); }; diff --git a/src/Add-on/ShareView/components/ThemeButton.tsx b/src/Add-on/ShareView/components/ThemeButton.tsx index 5a7b3aac9..74cf7f264 100644 --- a/src/Add-on/ShareView/components/ThemeButton.tsx +++ b/src/Add-on/ShareView/components/ThemeButton.tsx @@ -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 ( -
{boxStore.Theme == "light" ? '白' : '黑'}
+
{shareViewStore.Theme == "light" ? '白' : '黑'}
); }); diff --git a/src/Add-on/ShareView/components/ViewStyle.tsx b/src/Add-on/ShareView/components/ViewStyle.tsx index 01ae4b5a3..170c6c1c3 100644 --- a/src/Add-on/ShareView/components/ViewStyle.tsx +++ b/src/Add-on/ShareView/components/ViewStyle.tsx @@ -14,7 +14,7 @@ const ViewStyle: React.FC = forwardRef((props) => { const [visible, setVisible] = useState(false); const [selected, setSelected] = useState('概念'); - const selectDivRef = useRef(); + const selectDivRef = useRef(); const hideSelect = (e) => {