本次提交对图纸工作台进行了全面的功能重构和交互体验升级,主要涵盖了数据结构优化、核心逻辑增强、以及全新的可视化交互功能。
### 主要更新内容:
#### 1. **核心应用逻辑 (app.js)**
- **数据结构优化**:
- 重构了初始化逻辑,现在每个图片被视为一个独立的 \drawing\ 对象,包含自身的坐标边界和关联图片,使数据模型更清晰。
- **状态管理**:
- 引入 \currentDrawingId\ 状态,用于精确追踪和控制当前显示的图纸。
- **核心功能增强**:
- **自动图纸切换**: 实现了 \getDrawingForItem\ 映射逻辑,当用户在结构树中选择不同层级的件号时,系统能自动切换到其关联的图纸。
- **件号重命名 (handleItemRename)**: 彻底重写了重命名逻辑,现在支持递归更新所有子孙件号的ID和层级关系,保证了复杂结构下数据的一致性。
- **件号更新 (handleItemUpdate)**: 增强了件号创建和更新的鲁棒性,在添加深层级子件号时,会自动创建不存在的父级装配件,简化了操作流程。
- **图片拖拽**: 新增 \updateImagePosition\ 处理器,允许用户在画布上直接拖动图片并更新其世界坐标。
#### 2. **数据编辑器 (components/DataEditor.js)**
- **UI/UX 改进**:
- 大幅扩展了可编辑字段,增加了中文名、英文名、规格、材料、比例和备注等详细属性。
- 界面现在能够智能区分零件和装配件,并对装配件的重量输入框进行只读处理,因为其重量由子件自动汇总计算。
- 为只读字段添加了明确的提示信息,优化了用户体验。
#### 3. **图纸查看器 (components/DrawingViewer.js)**
- **全新交互功能**:
- **画布平移与缩放**: 实现了完整的画布拖拽平移和鼠标滚轮缩放功能,操作更流畅。
- **表格与图片拖拽**: 用户现在可以直接在画布上拖动明细表 (\GraphicalTable\) 和图纸中的图片,实现自由布局。
- **点击创建件号**: 在画布空白处单击,会弹出输入框,允许用户在指定位置快速创建新的件号,并记录其在图纸上的标记位置 (\markerPosition\)。
- **UI 浮层与控件**:
- 在画布上增加了多个交互浮层,包括左上角的图纸-件号绑定工具、右上角的缩放按钮、以及两侧用于切换图纸的箭头按钮。
- 新增了动态输入框 (\inputBox\),用于响应画布点击事件,提升了操作的直观性。
- **渲染与状态**:
- \GraphicalTable\ 和 \<image>\ 元素现在具备了拖拽所需的所有属性和事件处理。
- 内部状态管理重构,以支持新的视图变换 (\iewTransform\) 和交互状态。
#### 4. **主页面 (index.html)**
- **项目依赖**:
- 将 React 的 CDN 依赖切换为本地 \endor\ 目录下的文件,提高了应用的稳定性和加载速度。
- 移除了 Babel 依赖,因为项目已统一使用 \React.createElement\ API,无需 JSX 编译。
- **样式系统**:
- 全面拥抱 Tailwind CSS 的 \@layer\ 规则,对样式进行了分层(theme, base, components, utilities),使 CSS 结构更清晰、更易于维护。
- 定义了全局 CSS 变量,统一了颜色、尺寸等设计规范。
97 lines
3.5 KiB
HTML
97 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>图纸工作台 - 切分识别与编辑系统</title>
|
|
<meta name="description" content="专业的图纸切分识别与编辑工作台,支持层级结构管理和数据编辑">
|
|
<meta name="keywords" content="图纸工作台,图纸切分,零件识别,数据编辑,料号管理">
|
|
<meta property="og:title" content="图纸工作台 - 切分识别与编辑系统">
|
|
<meta property="og:description" content="专业的图纸切分识别与编辑工作台,支持层级结构管理和数据编辑">
|
|
<meta name="twitter:title" content="图纸工作台 - 切分识别与编辑系统">
|
|
<meta name="twitter:description" content="专业的图纸切分识别与编辑工作台,支持层级结构管理和数据编辑">
|
|
|
|
<!-- Switched to local vendor files for reliability -->
|
|
<script src="vendor/react.production.min.js"></script>
|
|
<script src="vendor/react-dom.production.min.js"></script>
|
|
<!-- Removed Babel: not needed since scripts are plain JS (no JSX) -->
|
|
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link href="vendor/lucide.css" rel="stylesheet">
|
|
|
|
<style type="text/tailwindcss">
|
|
@layer theme {
|
|
:root {
|
|
--primary-color: #2563eb;
|
|
--secondary-color: #f1f5f9;
|
|
--accent-color: #10b981;
|
|
--text-primary: #1e293b;
|
|
--text-secondary: #64748b;
|
|
--border-color: #e2e8f0;
|
|
--sidebar-width: 280px;
|
|
--header-height: 60px;
|
|
}
|
|
}
|
|
|
|
@layer base {
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
background-color: #f8fafc;
|
|
color: var(--text-primary);
|
|
}
|
|
}
|
|
|
|
@layer components {
|
|
.workspace-panel {
|
|
@apply bg-white border border-[var(--border-color)] rounded-lg shadow-sm;
|
|
}
|
|
|
|
.tree-item {
|
|
@apply flex items-center px-3 py-2 hover:bg-gray-50 cursor-pointer rounded-md transition-colors;
|
|
}
|
|
|
|
.tree-item.selected {
|
|
@apply bg-blue-50 border-l-4 border-l-[var(--primary-color)];
|
|
}
|
|
|
|
.btn-primary {
|
|
@apply bg-[var(--primary-color)] text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors;
|
|
}
|
|
|
|
.btn-secondary {
|
|
@apply bg-gray-100 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-200 transition-colors;
|
|
}
|
|
|
|
.form-input {
|
|
@apply w-full px-3 py-2 border border-[var(--border-color)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--primary-color)] focus:border-transparent;
|
|
}
|
|
}
|
|
|
|
@layer utilities {
|
|
.drag-handle {
|
|
cursor: grab;
|
|
}
|
|
|
|
.drag-handle:active {
|
|
cursor: grabbing;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
|
|
<script type="text/javascript" src="components/Header.js"></script>
|
|
<script type="text/javascript" src="components/StructureTree.js"></script>
|
|
<script type="text/javascript" src="components/DrawingViewer.js"></script>
|
|
<script type="text/javascript" src="components/DataEditor.js"></script>
|
|
<script type="text/javascript" src="utils/dragUtils.js"></script>
|
|
<script type="text/javascript" src="app.js"></script>
|
|
</body>
|
|
</html> |