Compare commits
8 Commits
771e290fb9
...
aeaeb9aec5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aeaeb9aec5 | ||
|
|
35934f8088 | ||
|
|
b27bf2c83b | ||
|
|
c923e9e54d | ||
|
|
5d10902e10 | ||
|
|
697802a2af | ||
|
|
6e4ce87844 | ||
|
|
71496de8e3 |
@@ -5,8 +5,8 @@ DB_PATH=
|
||||
|
||||
# login: show login page
|
||||
# fixed: auto login with FIXED_LOGIN_USERNAME and open model library directly
|
||||
APP_AUTH_MODE=login
|
||||
FIXED_LOGIN_USERNAME=
|
||||
APP_AUTH_MODE=fixed
|
||||
FIXED_LOGIN_USERNAME=admin
|
||||
FIXED_LOGIN_ROLE=user
|
||||
ALLOW_USER_EDIT_SYSTEM_LIBRARY=false
|
||||
|
||||
|
||||
140
package-lock.json
generated
140
package-lock.json
generated
@@ -1114,20 +1114,6 @@
|
||||
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/three": {
|
||||
"version": "0.184.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.184.1.tgz",
|
||||
"integrity": "sha512-6q4VdiqVsrTRqmk62/BnlcAvIrnDM0zf2ZDVKI5kZiniWrSaOHaQzmbp+BNzoggc/8tgW412pL//wZIxu2PPTA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"fflate": "~0.8.2",
|
||||
"meshoptimizer": "~1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/webxr": {
|
||||
"version": "0.5.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
|
||||
@@ -1146,6 +1132,12 @@
|
||||
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@webgpu/types": {
|
||||
"version": "0.1.70",
|
||||
"resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.70.tgz",
|
||||
"integrity": "sha512-LFiNHHKMvmAEvwVew3JLJmTdShhbdwRFSImUshGhE2mGE8ybQzIo63l5uRp+YKnNx+8Qno8Kf6gN+DKMreIJCA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/abstract-logging": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz",
|
||||
@@ -2320,12 +2312,6 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/meshoptimizer": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz",
|
||||
"integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
|
||||
@@ -3088,11 +3074,6 @@
|
||||
"resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz",
|
||||
"integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g=="
|
||||
},
|
||||
"node_modules/three": {
|
||||
"version": "0.184.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.184.0.tgz",
|
||||
"integrity": "sha512-wtTRjG92pM5eUg/KuUnHsqSAlPM296brTOcLgMRqEeylYTh/CdtvKUvCyyCQTzFuStieWxvZb8mVTMvdPyUpxg=="
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.16",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz",
|
||||
@@ -3766,11 +3747,6 @@
|
||||
"@esbuild/win32-x64": "0.25.12"
|
||||
}
|
||||
},
|
||||
"node_modules/w2ui": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w2ui/-/w2ui-2.0.0.tgz",
|
||||
"integrity": "sha512-oMvLitt2jMholqCpX0mDZ0b70ITjlLpfV56gswk7/cD2oPmlibV+DqcizESSs3+t5VJHiG0Xlcb23e4AoCN1Qw=="
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
@@ -3882,17 +3858,42 @@
|
||||
"dependencies": {
|
||||
"jquery": "^3.7.1",
|
||||
"jstree": "^3.3.17",
|
||||
"three": "^0.184.0",
|
||||
"w2ui": "^2.0.0"
|
||||
"three": "^0.183.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/jstree": "^3.3.46",
|
||||
"@types/three": "^0.184.1",
|
||||
"@types/three": "^0.183.0",
|
||||
"@vitejs/plugin-basic-ssl": "^1.2.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.7"
|
||||
}
|
||||
},
|
||||
"web/node_modules/@types/three": {
|
||||
"version": "0.183.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.183.1.tgz",
|
||||
"integrity": "sha512-f2Pu5Hrepfgavttdye3PsH5RWyY/AvdZQwIVhrc4uNtvF7nOWJacQKcoVJn0S4f0yYbmAE6AR+ve7xDcuYtMGw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"@webgpu/types": "*",
|
||||
"fflate": "~0.8.2",
|
||||
"meshoptimizer": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"web/node_modules/meshoptimizer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.0.1.tgz",
|
||||
"integrity": "sha512-Vix+QlA1YYT3FwmBBZ+49cE5y/b+pRrcXKqGpS5ouh33d3lSp2PoTpCw19E0cKDFWalembrHnIaZetf27a+W2g==",
|
||||
"dev": true
|
||||
},
|
||||
"web/node_modules/three": {
|
||||
"version": "0.183.2",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.183.2.tgz",
|
||||
"integrity": "sha512-di3BsL2FEQ1PA7Hcvn4fyJOlxRRgFYBpMTcyOgkwJIaDOdJMebEFPA+t98EvjuljDx4hNulAGwF6KIjtwI5jgQ=="
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -4475,20 +4476,6 @@
|
||||
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/three": {
|
||||
"version": "0.184.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.184.1.tgz",
|
||||
"integrity": "sha512-6q4VdiqVsrTRqmk62/BnlcAvIrnDM0zf2ZDVKI5kZiniWrSaOHaQzmbp+BNzoggc/8tgW412pL//wZIxu2PPTA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"fflate": "~0.8.2",
|
||||
"meshoptimizer": "~1.1.1"
|
||||
}
|
||||
},
|
||||
"@types/webxr": {
|
||||
"version": "0.5.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
|
||||
@@ -4502,6 +4489,12 @@
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"@webgpu/types": {
|
||||
"version": "0.1.70",
|
||||
"resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.70.tgz",
|
||||
"integrity": "sha512-LFiNHHKMvmAEvwVew3JLJmTdShhbdwRFSImUshGhE2mGE8ybQzIo63l5uRp+YKnNx+8Qno8Kf6gN+DKMreIJCA==",
|
||||
"dev": true
|
||||
},
|
||||
"abstract-logging": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz",
|
||||
@@ -4824,7 +4817,7 @@
|
||||
"@types/node": "^24.0.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cos-nodejs-sdk-v5": "^2.15.4",
|
||||
"dotenv": "*",
|
||||
"dotenv": "^17.4.2",
|
||||
"fastify": "^5.2.1",
|
||||
"nanoid": "^5.0.9",
|
||||
"tsx": "^4.19.2",
|
||||
@@ -4837,14 +4830,41 @@
|
||||
"requires": {
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/jstree": "^3.3.46",
|
||||
"@types/three": "^0.184.1",
|
||||
"@types/three": "^0.183.0",
|
||||
"@vitejs/plugin-basic-ssl": "^1.2.0",
|
||||
"jquery": "^3.7.1",
|
||||
"jstree": "^3.3.17",
|
||||
"three": "^0.184.0",
|
||||
"three": "^0.183.2",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.7",
|
||||
"w2ui": "^2.0.0"
|
||||
"vite": "^6.0.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/three": {
|
||||
"version": "0.183.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.183.1.tgz",
|
||||
"integrity": "sha512-f2Pu5Hrepfgavttdye3PsH5RWyY/AvdZQwIVhrc4uNtvF7nOWJacQKcoVJn0S4f0yYbmAE6AR+ve7xDcuYtMGw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"@webgpu/types": "*",
|
||||
"fflate": "~0.8.2",
|
||||
"meshoptimizer": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"meshoptimizer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.0.1.tgz",
|
||||
"integrity": "sha512-Vix+QlA1YYT3FwmBBZ+49cE5y/b+pRrcXKqGpS5ouh33d3lSp2PoTpCw19E0cKDFWalembrHnIaZetf27a+W2g==",
|
||||
"dev": true
|
||||
},
|
||||
"three": {
|
||||
"version": "0.183.2",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.183.2.tgz",
|
||||
"integrity": "sha512-di3BsL2FEQ1PA7Hcvn4fyJOlxRRgFYBpMTcyOgkwJIaDOdJMebEFPA+t98EvjuljDx4hNulAGwF6KIjtwI5jgQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
@@ -5360,12 +5380,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"meshoptimizer": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz",
|
||||
"integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==",
|
||||
"dev": true
|
||||
},
|
||||
"mime": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
|
||||
@@ -5868,11 +5882,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"three": {
|
||||
"version": "0.184.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.184.0.tgz",
|
||||
"integrity": "sha512-wtTRjG92pM5eUg/KuUnHsqSAlPM296brTOcLgMRqEeylYTh/CdtvKUvCyyCQTzFuStieWxvZb8mVTMvdPyUpxg=="
|
||||
},
|
||||
"tinyglobby": {
|
||||
"version": "0.2.16",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz",
|
||||
@@ -6205,11 +6214,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"w2ui": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w2ui/-/w2ui-2.0.0.tgz",
|
||||
"integrity": "sha512-oMvLitt2jMholqCpX0mDZ0b70ITjlLpfV56gswk7/cD2oPmlibV+DqcizESSs3+t5VJHiG0Xlcb23e4AoCN1Qw=="
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
"dependencies": {
|
||||
"jquery": "^3.7.1",
|
||||
"jstree": "^3.3.17",
|
||||
"three": "^0.184.0",
|
||||
"w2ui": "^2.0.0"
|
||||
"three": "^0.183.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/jstree": "^3.3.46",
|
||||
"@types/three": "^0.184.1",
|
||||
"@types/three": "^0.183.0",
|
||||
"@vitejs/plugin-basic-ssl": "^1.2.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.7"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import "jstree/dist/themes/default/style.min.css";
|
||||
import "w2ui/w2ui-2.0.min.css";
|
||||
import "./vendor/w2ui/w2ui.css";
|
||||
import "./styles/base.css";
|
||||
import { api } from "./services/api";
|
||||
import { getToken, setCurrentUser, setSession, clearSession } from "./services/authState";
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
.app-shell {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-rows: 42px 1fr;
|
||||
/* grid-template-rows: 42px 1fr; */
|
||||
}
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
/* display: flex; */
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
@@ -50,6 +51,7 @@
|
||||
display: grid;
|
||||
grid-template-rows: auto auto 1fr auto;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.content-toolbar {
|
||||
@@ -80,17 +82,17 @@
|
||||
|
||||
.filter-toolbar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(120px, 160px) minmax(120px, 160px) minmax(200px, 1fr) auto;
|
||||
grid-template-columns: minmax(120px, 200px) minmax(120px, 200px) minmax(200px, 200px) minmax(50px, 80px) minmax(50px, 80px);
|
||||
align-items: end;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
background: #f8fafb;
|
||||
/* background: #f8fafb; */
|
||||
border-bottom: 1px solid #d8e0e8;
|
||||
}
|
||||
|
||||
.filter-toolbar label {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
/* display: grid;
|
||||
gap: 3px; */
|
||||
}
|
||||
|
||||
.filter-toolbar span {
|
||||
@@ -129,21 +131,21 @@
|
||||
|
||||
.thumb {
|
||||
position: relative;
|
||||
height: 150px;
|
||||
min-height: 150px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background:
|
||||
/* background:
|
||||
linear-gradient(45deg, #edf2f5 25%, transparent 25%),
|
||||
linear-gradient(-45deg, #edf2f5 25%, transparent 25%),
|
||||
linear-gradient(45deg, transparent 75%, #edf2f5 75%),
|
||||
linear-gradient(-45deg, transparent 75%, #edf2f5 75%),
|
||||
#f8fafb;
|
||||
#f8fafb; */
|
||||
background-position: 0 0, 0 6px, 6px -6px, -6px 0;
|
||||
background-size: 12px 12px;
|
||||
border: 1px solid #d3dde5;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
padding: 4px;
|
||||
/* padding: 4px; */
|
||||
}
|
||||
|
||||
.thumb-actions {
|
||||
@@ -253,6 +255,7 @@ dd {
|
||||
|
||||
.pagination-total,
|
||||
.pagination-range {
|
||||
display: none;
|
||||
color: #647586;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -331,7 +334,7 @@ dd {
|
||||
}
|
||||
|
||||
.keyword-filter {
|
||||
grid-column: 1 / -1;
|
||||
/* grid-column: 1 / -1; */
|
||||
}
|
||||
|
||||
.pagination {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { w2layout, w2ui } from "w2ui";
|
||||
import { w2layout, w2ui } from "../../vendor/w2ui";
|
||||
import { getCurrentUser, clearSession } from "../../services/authState";
|
||||
import { loadFolders } from "./modules/folders";
|
||||
import { bindModelActions } from "./modules/models";
|
||||
@@ -31,14 +31,11 @@ export async function renderApp() {
|
||||
<template id="modelPanelTemplate">
|
||||
<main class="content-pane">
|
||||
<div class="content-toolbar">
|
||||
<div>
|
||||
<h2>模型列表</h2>
|
||||
</div>
|
||||
<div class="content-actions">
|
||||
${isAdmin ? `<button id="manageUsersBtn" type="button">人员权限</button>` : ""}
|
||||
${isAdmin ? `<button id="manageDictionariesBtn" type="button">字典维护</button>` : ""}
|
||||
<button id="addProcessModelBtn" type="button" hidden>上传工艺模型</button>
|
||||
<button id="addModelBtn" class="primary-btn" type="button" hidden>增加模型</button>
|
||||
${isAdmin ? `<button id="addProcessModelBtn" type="button" hidden>上传工艺模型</button>` : ""}
|
||||
${isAdmin ? `<button id="addModelBtn1" class="primary-btn" type="button" hidden>增加模型</button>` : ""}
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-toolbar">
|
||||
@@ -59,6 +56,7 @@ export async function renderApp() {
|
||||
<input id="keywordFilter" placeholder="模型名 / 文件名 / 属性" />
|
||||
</label>
|
||||
<button id="resetFilterBtn" type="button">重置</button>
|
||||
<button id="addModelBtn" class="primary-btn" type="button">增加模型</button>
|
||||
</div>
|
||||
<div id="modelGrid" class="model-grid"></div>
|
||||
<footer id="modelPagination" class="pagination"></footer>
|
||||
@@ -92,8 +90,8 @@ function renderWorkspaceLayout() {
|
||||
panels: [
|
||||
{
|
||||
type: "left",
|
||||
size: 300,
|
||||
minSize: 220,
|
||||
size: 180,
|
||||
minSize: 150,
|
||||
resizable: true,
|
||||
overflow: "hidden",
|
||||
html: treeTemplate.innerHTML
|
||||
|
||||
@@ -24,6 +24,7 @@ export async function openDictionaryManager(onChanged?: () => Promise<void> | vo
|
||||
title: "品牌 / 类型维护",
|
||||
width: 680,
|
||||
height: 520,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<div class="dictionary-manager">
|
||||
${dictionaryPanelHtml("brands", "品牌")}
|
||||
|
||||
@@ -22,11 +22,31 @@ type UploadModelPayload = {
|
||||
};
|
||||
|
||||
const defaultOperationTree = JSON.stringify({ OperationTree: "[]" });
|
||||
const requestSceneModelMessageType = "DMT_MODEL_LIBRARY_REQUEST_SCENE_MODEL";
|
||||
const sceneModelMessageType = "DMT_MODEL_LIBRARY_SCENE_MODEL";
|
||||
const sceneModelErrorMessageType = "DMT_MODEL_LIBRARY_SCENE_MODEL_ERROR";
|
||||
|
||||
type SceneModelMessagePayload = {
|
||||
modelName?: string;
|
||||
fileName?: string;
|
||||
modelBuffer?: ArrayBuffer;
|
||||
operationTreeJson?: string;
|
||||
};
|
||||
|
||||
type SceneModelMessage = {
|
||||
type?: string;
|
||||
payload?: SceneModelMessagePayload;
|
||||
message?: string;
|
||||
};
|
||||
|
||||
let dictionariesLoaded = false;
|
||||
let dictionariesLoading: Promise<void> | null = null;
|
||||
let sceneModelBridgeBound = false;
|
||||
|
||||
export function bindModelActions() {
|
||||
const isAdmin = getCurrentUser()?.role === "admin";
|
||||
bindSceneModelBridge();
|
||||
ensureImportSceneModelButton();
|
||||
if (isAdmin) {
|
||||
document.querySelector("#manageUsersBtn")?.addEventListener("click", async () => {
|
||||
try {
|
||||
@@ -211,7 +231,7 @@ function renderModelCard(item: ModelItem) {
|
||||
const prop = item.properties ?? {};
|
||||
const thumb = item.thumbnail_url
|
||||
? `<img src="${item.thumbnail_url}" alt="" />`
|
||||
: `<div class="thumb-placeholder">GLB</div>`;
|
||||
: `<div class="thumb-placeholder">暂无预览图</div>`;
|
||||
return `
|
||||
<article class="model-card" data-model-id="${item.id}">
|
||||
<div class="model-info">
|
||||
@@ -242,8 +262,90 @@ function syncSelectedFolderActions() {
|
||||
const canWrite = Boolean(currentFolder?.permissions.write);
|
||||
const addModelBtn = document.querySelector<HTMLButtonElement>("#addModelBtn");
|
||||
const addProcessModelBtn = document.querySelector<HTMLButtonElement>("#addProcessModelBtn");
|
||||
const importSceneModelBtn = document.querySelector<HTMLButtonElement>("#importSceneModelBtn");
|
||||
if (addModelBtn) addModelBtn.hidden = !canWrite;
|
||||
if (addProcessModelBtn) addProcessModelBtn.hidden = !canWrite;
|
||||
if (importSceneModelBtn) importSceneModelBtn.hidden = !canWrite;
|
||||
}
|
||||
|
||||
function ensureImportSceneModelButton() {
|
||||
if (document.querySelector("#importSceneModelBtn")) return;
|
||||
const addModelBtn = document.querySelector<HTMLButtonElement>("#addModelBtn");
|
||||
if (!addModelBtn) return;
|
||||
const button = document.createElement("button");
|
||||
button.id = "importSceneModelBtn";
|
||||
button.type = "button";
|
||||
button.textContent = "导入场景模型";
|
||||
button.addEventListener("click", requestSceneModelImport);
|
||||
addModelBtn.insertAdjacentElement("afterend", button);
|
||||
}
|
||||
|
||||
function bindSceneModelBridge() {
|
||||
if (sceneModelBridgeBound) return;
|
||||
sceneModelBridgeBound = true;
|
||||
window.addEventListener("message", (event) => {
|
||||
const data = event.data as SceneModelMessage;
|
||||
if (data?.type !== sceneModelMessageType && data?.type !== sceneModelErrorMessageType) return;
|
||||
if (!isAllowedParentOrigin(event.origin)) return;
|
||||
void handleSceneModelMessage(data);
|
||||
});
|
||||
}
|
||||
|
||||
function requestSceneModelImport() {
|
||||
if (!appState.selectedFolderId) {
|
||||
notify("请先选择目录");
|
||||
return;
|
||||
}
|
||||
if (!window.parent || window.parent === window) {
|
||||
notify("请在 DMT 主程序中使用导入场景模型");
|
||||
return;
|
||||
}
|
||||
window.parent.postMessage({
|
||||
type: requestSceneModelMessageType
|
||||
}, resolveParentOrigin());
|
||||
notify("已请求主程序导出当前选中模型");
|
||||
}
|
||||
|
||||
async function handleSceneModelMessage(data: SceneModelMessage) {
|
||||
if (data.type === sceneModelErrorMessageType) {
|
||||
notifyError(data.message || "主程序导出模型失败");
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = data.payload;
|
||||
if (!payload?.modelBuffer) {
|
||||
notifyError("主程序返回的模型数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
const fileName = ensureGlbFileName(payload.fileName || payload.modelName || "scene-model.glb");
|
||||
const file = new File([payload.modelBuffer], fileName, { type: "model/gltf-binary" });
|
||||
await openProcessModelUploadDialog({
|
||||
file,
|
||||
modelName: payload.modelName || modelNameFromFile(fileName),
|
||||
operationTreeJson: payload.operationTreeJson || defaultOperationTree
|
||||
});
|
||||
}
|
||||
|
||||
function isAllowedParentOrigin(origin: string) {
|
||||
const expectedOrigin = resolveParentOrigin();
|
||||
return expectedOrigin === "*" || origin === expectedOrigin;
|
||||
}
|
||||
|
||||
function resolveParentOrigin() {
|
||||
try {
|
||||
const meta = import.meta as ImportMeta & { env?: Record<string, string | undefined> };
|
||||
const configuredOrigin = meta.env?.VITE_DMT_PARENT_ORIGIN;
|
||||
if (configuredOrigin) return configuredOrigin;
|
||||
if (document.referrer) return new URL(document.referrer).origin;
|
||||
} catch {
|
||||
return "*";
|
||||
}
|
||||
return "*";
|
||||
}
|
||||
|
||||
function ensureGlbFileName(fileName: string) {
|
||||
return fileName.toLowerCase().endsWith(".glb") ? fileName : `${fileName}.glb`;
|
||||
}
|
||||
|
||||
export async function uploadModelToBackend(payload: UploadModelPayload) {
|
||||
@@ -289,6 +391,7 @@ async function openUploadModelDialog() {
|
||||
title: "增加模型",
|
||||
width: 560,
|
||||
height: 520,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<form id="modelUploadPopupForm" class="popup-form upload-popup-form">
|
||||
<label>
|
||||
@@ -364,6 +467,7 @@ export async function openProcessModelUploadDialog(input?: {
|
||||
title: "上传工艺模型",
|
||||
width: 640,
|
||||
height: 650,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<form id="processModelUploadPopupForm" class="popup-form upload-popup-form">
|
||||
<div class="upload-target-path">
|
||||
@@ -554,6 +658,7 @@ async function editModel(id: number) {
|
||||
title: "编辑模型",
|
||||
width: 520,
|
||||
height: 390,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<form id="modelEditPopupForm" class="popup-form">
|
||||
<label><span>模型名称</span><input name="name" value="${escapeHtml(oldName)}" /></label>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { w2popup } from "w2ui";
|
||||
import { w2popup } from "../../../vendor/w2ui";
|
||||
import type { Object3D, PerspectiveCamera, Scene, Texture, WebGLRenderer } from "three";
|
||||
import type { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
||||
import type { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
||||
@@ -64,6 +64,14 @@ export type PreviewImportScenePayload = {
|
||||
selectedCraftPlayData: P_OPERATION | null;
|
||||
};
|
||||
|
||||
type ParentImportScenePayload = {
|
||||
model: Pick<ModelItem, "id" | "name" | "original_filename" | "file_url">;
|
||||
modelUrl: string;
|
||||
basePointEnabled: boolean;
|
||||
basePoint: PreviewResolvedBasePoint;
|
||||
rawOperationTree: string;
|
||||
};
|
||||
|
||||
export type ModelPreviewOptions = {
|
||||
onImportScene?: (payload: PreviewImportScenePayload) => Promise<void> | void;
|
||||
};
|
||||
@@ -97,6 +105,7 @@ export function openModelPreview(
|
||||
width: 860,
|
||||
height: 620,
|
||||
modal: true,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<div class="preview-shell">
|
||||
<aside class="preview-process-panel">
|
||||
@@ -214,6 +223,43 @@ export function createImportScenePayload(options: {
|
||||
|
||||
export function emitImportScenePayload(payload: PreviewImportScenePayload) {
|
||||
window.dispatchEvent(new CustomEvent<PreviewImportScenePayload>("dmt:import-scene", { detail: payload }));
|
||||
if (window.parent && window.parent !== window) {
|
||||
try {
|
||||
window.parent.postMessage({
|
||||
type: "DMT_MODEL_LIBRARY_IMPORT_SCENE",
|
||||
payload: buildParentImportScenePayload(payload)
|
||||
}, resolveParentOrigin());
|
||||
} catch (error) {
|
||||
notifyError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildParentImportScenePayload(payload: PreviewImportScenePayload): ParentImportScenePayload {
|
||||
return {
|
||||
model: {
|
||||
id: payload.model.id,
|
||||
name: payload.model.name,
|
||||
original_filename: payload.model.original_filename,
|
||||
file_url: payload.model.file_url
|
||||
},
|
||||
modelUrl: payload.modelUrl,
|
||||
basePointEnabled: payload.basePointEnabled,
|
||||
basePoint: payload.basePoint,
|
||||
rawOperationTree: payload.rawOperationTree
|
||||
};
|
||||
}
|
||||
|
||||
function resolveParentOrigin() {
|
||||
try {
|
||||
const meta = import.meta as ImportMeta & { env?: Record<string, string | undefined> };
|
||||
const configuredOrigin = meta.env?.VITE_DMT_PARENT_ORIGIN;
|
||||
if (configuredOrigin) return configuredOrigin;
|
||||
if (document.referrer) return new URL(document.referrer).origin;
|
||||
} catch {
|
||||
return "*";
|
||||
}
|
||||
return "*";
|
||||
}
|
||||
|
||||
function parseModelOperations(value: string): PreviewOperation[] {
|
||||
|
||||
@@ -16,6 +16,7 @@ export async function openUserManager() {
|
||||
title: "人员权限管理",
|
||||
width: 980,
|
||||
height: 560,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<div class="user-manager">
|
||||
<header class="user-manager-head">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
:root {
|
||||
font-family: "Microsoft YaHei", Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
color: #1c2733;
|
||||
background: #eef2f5;
|
||||
}
|
||||
@@ -8,7 +7,9 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 62.5%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
min-width: 320px;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { w2alert, w2confirm, w2popup } from "w2ui";
|
||||
import { w2confirm, w2popup, w2utils } from "../vendor/w2ui";
|
||||
|
||||
type PopupActionEvent = {
|
||||
detail: {
|
||||
@@ -10,7 +10,11 @@ type PopupActionEvent = {
|
||||
};
|
||||
|
||||
export function notify(message: string, title = "提示") {
|
||||
w2alert(message, title);
|
||||
w2utils.alert({
|
||||
box: "body",
|
||||
title,
|
||||
text: message
|
||||
});
|
||||
}
|
||||
|
||||
export function notifyError(error: unknown) {
|
||||
@@ -34,6 +38,7 @@ export function formDialog<T>(options: {
|
||||
title: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
blockPage?: boolean;
|
||||
body: string;
|
||||
onOpen?: () => void;
|
||||
onSubmit: () => Promise<T> | T;
|
||||
@@ -53,6 +58,7 @@ export function formDialog<T>(options: {
|
||||
height: options.height ?? 300,
|
||||
modal: true,
|
||||
body: options.body,
|
||||
blockPage: options.blockPage ?? false,
|
||||
actions: {
|
||||
取消() {
|
||||
closeWith(null);
|
||||
@@ -92,6 +98,7 @@ export async function promptDialog(options: {
|
||||
return formDialog<string>({
|
||||
title: options.title,
|
||||
height: 210,
|
||||
blockPage: false,
|
||||
body: `
|
||||
<div class="popup-form">
|
||||
<label>
|
||||
|
||||
63
web/src/vendor/w2ui.ts
vendored
Normal file
63
web/src/vendor/w2ui.ts
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// 与主程序 src/publicJs/w2ui 保持同步的模型库本地副本,这里只做类型适配。
|
||||
// @ts-expect-error w2ui 本地 JS 暂无配套 d.ts,运行时由 Vite 正常打包。
|
||||
import * as w2uiLocal from "./w2ui/w2ui.es6.js";
|
||||
|
||||
type W2EventHandler = (event: unknown) => void;
|
||||
type W2EventHost = {
|
||||
on(eventName: string, handler: W2EventHandler): W2EventHost;
|
||||
};
|
||||
|
||||
type W2Popup = {
|
||||
open(options: {
|
||||
title?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
modal?: boolean;
|
||||
blockPage?: boolean;
|
||||
body?: string;
|
||||
actions?: Record<string, () => void | Promise<void>>;
|
||||
}): {
|
||||
self: W2EventHost;
|
||||
};
|
||||
close(): void;
|
||||
};
|
||||
|
||||
type W2Utils = {
|
||||
alert(options: {
|
||||
box?: string | HTMLElement;
|
||||
title?: string;
|
||||
text?: string;
|
||||
}): unknown;
|
||||
};
|
||||
|
||||
type W2LayoutOptions = {
|
||||
name: string;
|
||||
padding?: number;
|
||||
panels: Array<{
|
||||
type: "left" | "right" | "top" | "bottom" | "main" | "preview";
|
||||
size?: number | string;
|
||||
minSize?: number;
|
||||
maxSize?: number | false;
|
||||
resizable?: boolean;
|
||||
overflow?: string;
|
||||
html?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
type W2Layout = {
|
||||
render(target: HTMLElement): void;
|
||||
destroy(): void;
|
||||
};
|
||||
|
||||
const local = w2uiLocal as Record<string, unknown>;
|
||||
|
||||
export const w2popup = local.w2popup as W2Popup;
|
||||
export const w2layout = local.w2layout as new (options: W2LayoutOptions) => W2Layout;
|
||||
export const w2ui = local.w2ui as Record<string, { destroy?: () => void } | undefined>;
|
||||
export const w2utils = local.w2utils as W2Utils;
|
||||
export const w2alert = local.w2alert as (message: string, title?: string) => unknown;
|
||||
export const w2confirm = local.w2confirm as (
|
||||
message: string | { msg: string; title?: string; yes?: string; no?: string },
|
||||
title?: string,
|
||||
callback?: (action: string) => void
|
||||
) => unknown;
|
||||
4250
web/src/vendor/w2ui/w2ui.css
vendored
Normal file
4250
web/src/vendor/w2ui/w2ui.css
vendored
Normal file
File diff suppressed because one or more lines are too long
24634
web/src/vendor/w2ui/w2ui.es6.js
vendored
Normal file
24634
web/src/vendor/w2ui/w2ui.es6.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,34 @@
|
||||
import { defineConfig } from "vite";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, "../..");
|
||||
const httpsConfig = {
|
||||
key: fs.readFileSync(path.join(rootDir, "certs/localhost+2-key.pem")),
|
||||
cert: fs.readFileSync(path.join(rootDir, "certs/localhost+2.pem"))
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 5174,
|
||||
strictPort: true,
|
||||
https: httpsConfig,
|
||||
headers: {
|
||||
// 关键:添加 COEP 和 COOP
|
||||
"Cross-Origin-Embedder-Policy": "credentialless", // 或 "require-corp"
|
||||
"Cross-Origin-Opener-Policy": "same-origin",
|
||||
"Cross-Origin-Resource-Policy": "cross-origin", // 改为 cross-origin
|
||||
// 开发环境允许跨域
|
||||
"Access-Control-Allow-Origin": "https://localhost:3000", // 父页面的地址
|
||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type",
|
||||
"Access-Control-Allow-Credentials": "true"
|
||||
},
|
||||
proxy: {
|
||||
"/api": "http://localhost:3001",
|
||||
"/storage": "http://localhost:3001"
|
||||
"/api": "http://127.0.0.1:3001",
|
||||
"/storage": "http://127.0.0.1:3001"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user