|
|
|
@ -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);//默认概念样式
|
|
|
|
|
}
|
|
|
|
|