完善模型库界面和开发配置

This commit is contained in:
zhangshun
2026-05-29 17:24:33 +08:00
parent 35934f8088
commit aeaeb9aec5
11 changed files with 44 additions and 24 deletions

View File

@@ -5,8 +5,8 @@ DB_PATH=
# login: show login page # login: show login page
# fixed: auto login with FIXED_LOGIN_USERNAME and open model library directly # fixed: auto login with FIXED_LOGIN_USERNAME and open model library directly
APP_AUTH_MODE=login APP_AUTH_MODE=fixed
FIXED_LOGIN_USERNAME= FIXED_LOGIN_USERNAME=admin
FIXED_LOGIN_ROLE=user FIXED_LOGIN_ROLE=user
ALLOW_USER_EDIT_SYSTEM_LIBRARY=false ALLOW_USER_EDIT_SYSTEM_LIBRARY=false

View File

@@ -1,11 +1,12 @@
.app-shell { .app-shell {
height: 100vh; height: 100vh;
display: grid; display: grid;
grid-template-rows: 42px 1fr; /* grid-template-rows: 42px 1fr; */
} }
.topbar { .topbar {
display: flex; /* display: flex; */
display: none;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 14px; gap: 14px;
@@ -50,6 +51,7 @@
display: grid; display: grid;
grid-template-rows: auto auto 1fr auto; grid-template-rows: auto auto 1fr auto;
overflow: hidden; overflow: hidden;
background: #fff;
} }
.content-toolbar { .content-toolbar {
@@ -80,17 +82,17 @@
.filter-toolbar { .filter-toolbar {
display: grid; 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; align-items: end;
gap: 8px; gap: 8px;
padding: 8px 12px; padding: 8px 12px;
background: #f8fafb; /* background: #f8fafb; */
border-bottom: 1px solid #d8e0e8; border-bottom: 1px solid #d8e0e8;
} }
.filter-toolbar label { .filter-toolbar label {
display: grid; /* display: grid;
gap: 3px; gap: 3px; */
} }
.filter-toolbar span { .filter-toolbar span {
@@ -129,21 +131,21 @@
.thumb { .thumb {
position: relative; position: relative;
height: 150px; min-height: 150px;
display: grid; display: grid;
place-items: center; place-items: center;
background: /* background:
linear-gradient(45deg, #edf2f5 25%, transparent 25%), linear-gradient(45deg, #edf2f5 25%, transparent 25%),
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%),
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-position: 0 0, 0 6px, 6px -6px, -6px 0;
background-size: 12px 12px; background-size: 12px 12px;
border: 1px solid #d3dde5; border: 1px solid #d3dde5;
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
padding: 4px; /* padding: 4px; */
} }
.thumb-actions { .thumb-actions {
@@ -253,6 +255,7 @@ dd {
.pagination-total, .pagination-total,
.pagination-range { .pagination-range {
display: none;
color: #647586; color: #647586;
font-size: 12px; font-size: 12px;
} }
@@ -331,7 +334,7 @@ dd {
} }
.keyword-filter { .keyword-filter {
grid-column: 1 / -1; /* grid-column: 1 / -1; */
} }
.pagination { .pagination {

View File

@@ -31,14 +31,11 @@ export async function renderApp() {
<template id="modelPanelTemplate"> <template id="modelPanelTemplate">
<main class="content-pane"> <main class="content-pane">
<div class="content-toolbar"> <div class="content-toolbar">
<div>
<h2>模型列表</h2>
</div>
<div class="content-actions"> <div class="content-actions">
${isAdmin ? `<button id="manageUsersBtn" type="button">人员权限</button>` : ""} ${isAdmin ? `<button id="manageUsersBtn" type="button">人员权限</button>` : ""}
${isAdmin ? `<button id="manageDictionariesBtn" type="button">字典维护</button>` : ""} ${isAdmin ? `<button id="manageDictionariesBtn" type="button">字典维护</button>` : ""}
<button id="addProcessModelBtn" type="button" hidden>上传工艺模型</button> ${isAdmin ? `<button id="addProcessModelBtn" type="button" hidden>上传工艺模型</button>` : ""}
<button id="addModelBtn" class="primary-btn" type="button" hidden>增加模型</button> ${isAdmin ? `<button id="addModelBtn1" class="primary-btn" type="button" hidden>增加模型</button>` : ""}
</div> </div>
</div> </div>
<div class="filter-toolbar"> <div class="filter-toolbar">
@@ -59,6 +56,7 @@ export async function renderApp() {
<input id="keywordFilter" placeholder="模型名 / 文件名 / 属性" /> <input id="keywordFilter" placeholder="模型名 / 文件名 / 属性" />
</label> </label>
<button id="resetFilterBtn" type="button">重置</button> <button id="resetFilterBtn" type="button">重置</button>
<button id="addModelBtn" class="primary-btn" type="button">增加模型</button>
</div> </div>
<div id="modelGrid" class="model-grid"></div> <div id="modelGrid" class="model-grid"></div>
<footer id="modelPagination" class="pagination"></footer> <footer id="modelPagination" class="pagination"></footer>
@@ -92,8 +90,8 @@ function renderWorkspaceLayout() {
panels: [ panels: [
{ {
type: "left", type: "left",
size: 300, size: 180,
minSize: 220, minSize: 150,
resizable: true, resizable: true,
overflow: "hidden", overflow: "hidden",
html: treeTemplate.innerHTML html: treeTemplate.innerHTML

View File

@@ -24,6 +24,7 @@ export async function openDictionaryManager(onChanged?: () => Promise<void> | vo
title: "品牌 / 类型维护", title: "品牌 / 类型维护",
width: 680, width: 680,
height: 520, height: 520,
blockPage: false,
body: ` body: `
<div class="dictionary-manager"> <div class="dictionary-manager">
${dictionaryPanelHtml("brands", "品牌")} ${dictionaryPanelHtml("brands", "品牌")}

View File

@@ -231,7 +231,7 @@ function renderModelCard(item: ModelItem) {
const prop = item.properties ?? {}; const prop = item.properties ?? {};
const thumb = item.thumbnail_url const thumb = item.thumbnail_url
? `<img src="${item.thumbnail_url}" alt="" />` ? `<img src="${item.thumbnail_url}" alt="" />`
: `<div class="thumb-placeholder">GLB</div>`; : `<div class="thumb-placeholder">暂无预览图</div>`;
return ` return `
<article class="model-card" data-model-id="${item.id}"> <article class="model-card" data-model-id="${item.id}">
<div class="model-info"> <div class="model-info">
@@ -391,6 +391,7 @@ async function openUploadModelDialog() {
title: "增加模型", title: "增加模型",
width: 560, width: 560,
height: 520, height: 520,
blockPage: false,
body: ` body: `
<form id="modelUploadPopupForm" class="popup-form upload-popup-form"> <form id="modelUploadPopupForm" class="popup-form upload-popup-form">
<label> <label>
@@ -466,6 +467,7 @@ export async function openProcessModelUploadDialog(input?: {
title: "上传工艺模型", title: "上传工艺模型",
width: 640, width: 640,
height: 650, height: 650,
blockPage: false,
body: ` body: `
<form id="processModelUploadPopupForm" class="popup-form upload-popup-form"> <form id="processModelUploadPopupForm" class="popup-form upload-popup-form">
<div class="upload-target-path"> <div class="upload-target-path">
@@ -656,6 +658,7 @@ async function editModel(id: number) {
title: "编辑模型", title: "编辑模型",
width: 520, width: 520,
height: 390, height: 390,
blockPage: false,
body: ` body: `
<form id="modelEditPopupForm" class="popup-form"> <form id="modelEditPopupForm" class="popup-form">
<label><span>模型名称</span><input name="name" value="${escapeHtml(oldName)}" /></label> <label><span>模型名称</span><input name="name" value="${escapeHtml(oldName)}" /></label>

View File

@@ -105,6 +105,7 @@ export function openModelPreview(
width: 860, width: 860,
height: 620, height: 620,
modal: true, modal: true,
blockPage: false,
body: ` body: `
<div class="preview-shell"> <div class="preview-shell">
<aside class="preview-process-panel"> <aside class="preview-process-panel">

View File

@@ -16,6 +16,7 @@ export async function openUserManager() {
title: "人员权限管理", title: "人员权限管理",
width: 980, width: 980,
height: 560, height: 560,
blockPage: false,
body: ` body: `
<div class="user-manager"> <div class="user-manager">
<header class="user-manager-head"> <header class="user-manager-head">

View File

@@ -1,6 +1,5 @@
:root { :root {
font-family: "Microsoft YaHei", Arial, sans-serif; font-family: "Microsoft YaHei", Arial, sans-serif;
font-size: 13px;
color: #1c2733; color: #1c2733;
background: #eef2f5; background: #eef2f5;
} }
@@ -8,7 +7,9 @@
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
html {
font-size: 62.5%;
}
body { body {
margin: 0; margin: 0;
min-width: 320px; min-width: 320px;

View File

@@ -38,6 +38,7 @@ export function formDialog<T>(options: {
title: string; title: string;
width?: number; width?: number;
height?: number; height?: number;
blockPage?: boolean;
body: string; body: string;
onOpen?: () => void; onOpen?: () => void;
onSubmit: () => Promise<T> | T; onSubmit: () => Promise<T> | T;
@@ -57,6 +58,7 @@ export function formDialog<T>(options: {
height: options.height ?? 300, height: options.height ?? 300,
modal: true, modal: true,
body: options.body, body: options.body,
blockPage: options.blockPage ?? false,
actions: { actions: {
() { () {
closeWith(null); closeWith(null);
@@ -96,6 +98,7 @@ export async function promptDialog(options: {
return formDialog<string>({ return formDialog<string>({
title: options.title, title: options.title,
height: 210, height: 210,
blockPage: false,
body: ` body: `
<div class="popup-form"> <div class="popup-form">
<label> <label>

View File

@@ -13,6 +13,7 @@ type W2Popup = {
width?: number; width?: number;
height?: number; height?: number;
modal?: boolean; modal?: boolean;
blockPage?: boolean;
body?: string; body?: string;
actions?: Record<string, () => void | Promise<void>>; actions?: Record<string, () => void | Promise<void>>;
}): { }): {

View File

@@ -16,7 +16,15 @@ export default defineConfig({
strictPort: true, strictPort: true,
https: httpsConfig, https: httpsConfig,
headers: { headers: {
"Cross-Origin-Resource-Policy": "same-site" // 关键:添加 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: { proxy: {
"/api": "http://127.0.0.1:3001", "/api": "http://127.0.0.1:3001",