-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
554 lines (490 loc) · 18 KB
/
index.html
File metadata and controls
554 lines (490 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TechManWorkflow-JointJS</title>
<link rel="stylesheet" href="js/lib/jointjs-3.7.7.min.css">
<style>
html, body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
/* 主画布容器样式 */
#paper-container {
position: absolute;
top: 0;
left: 140px; /* Account for the left sidebar width */
right: 0;
bottom: 0;
overflow: hidden;
background-color: #f8f9fa;
}
/* 平移模式指示器样式 */
.panning-mode-indicator {
position: fixed;
top: 20px;
right: 20px;
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 8px 16px;
border-radius: 4px;
font-family: Arial, sans-serif;
font-size: 14px;
z-index: 10000;
display: none;
pointer-events: none;
}
/* 鼠标指针样式 */
.panning-cursor {
cursor: grab !important;
}
.panning-cursor:active {
cursor: grabbing !important;
}
/* 小地图样式 */
#minimap-container {
position: fixed;
bottom: 20px;
right: 20px;
width: 220px;
height: 180px;
background-color: rgba(255, 255, 255, 0.9);
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
overflow: hidden;
transition: opacity 0.3s ease;
}
#minimap-container:hover {
opacity: 1 !important;
}
/* 小地图视口指示器 */
.minimap-viewport {
position: absolute;
border: 2px solid rgba(25, 118, 210, 0.7);
background-color: rgba(25, 118, 210, 0.1);
z-index: 1001;
cursor: move;
pointer-events: all;
transition: border-color 0.2s ease;
}
.minimap-viewport:hover {
border-color: rgba(25, 118, 210, 0.9);
background-color: rgba(25, 118, 210, 0.15);
}
/* 小地图标题 */
.minimap-title {
position: absolute;
top: 0;
left: 0;
right: 0;
background-color: rgba(240, 240, 240, 0.8);
color: #666;
font-size: 11px;
padding: 2px 6px;
text-align: center;
border-bottom: 1px solid #ddd;
z-index: 1002;
pointer-events: none;
user-select: none;
}
/* 缩放控制工具栏样式 */
#zoom-toolbar {
position: fixed;
bottom: 20px;
right: 250px; /* 位于小地图左侧 */
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid #ccc;
border-radius: 20px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 6px 12px;
display: flex;
align-items: center;
z-index: 1000;
transition: all 0.3s ease;
}
#zoom-toolbar button {
background: none;
border: none;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 18px;
font-weight: bold;
color: #555;
transition: all 0.2s ease;
outline: none;
margin: 0 2px;
}
#zoom-toolbar button:hover {
background-color: rgba(0, 0, 0, 0.1);
transform: scale(1.1);
}
#zoom-toolbar button:active {
background-color: rgba(0, 0, 0, 0.2);
transform: scale(0.95);
}
#zoom-percentage {
margin: 0 8px;
font-size: 14px;
font-weight: bold;
color: #555;
width: 50px;
text-align: center;
user-select: none;
cursor: pointer;
padding: 4px 6px;
border-radius: 12px;
transition: all 0.2s ease;
}
#zoom-percentage:hover {
background-color: rgba(0, 0, 0, 0.1);
}
#zoom-percentage:active {
background-color: rgba(0, 0, 0, 0.2);
transform: scale(0.95);
}
#toggle-minimap {
margin-left: 8px;
border-left: 1px solid #ddd;
padding-left: 8px;
}
/* SVG图标样式 */
.toolbar-icon {
width: 18px;
height: 18px;
fill: #555;
transition: fill 0.2s ease;
}
button:hover .toolbar-icon {
fill: #333;
}
/* 小屏幕适配 */
@media (max-width: 768px) {
#zoom-toolbar {
right: 210px;
padding: 4px 8px;
}
#zoom-toolbar button {
width: 26px;
height: 26px;
}
#zoom-percentage {
font-size: 12px;
width: 40px;
}
}
/* 加载指示器 */
.loading-indicator {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.9);
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 10001;
text-align: center;
font-size: 16px;
color: #333;
}
.loading-spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-right: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* 容器拖拽高亮效果 */
.container-drag-highlight {
stroke: #87ceeb !important;
stroke-width: 2 !important;
filter: drop-shadow(0 0 6px rgba(135, 206, 235, 0.3)) !important;
transition: all 0.2s ease !important;
}
/* 确保容器标题文本不受高亮效果影响 */
.container-drag-highlight text {
fill: inherit !important;
stroke: none !important;
filter: none !important;
}
/* 拖拽状态下的光标 */
.dragging-cursor {
cursor: grabbing !important;
}
/* 容器节点悬停效果增强 */
.container-hover-effect {
transition: all 0.2s ease;
}
.container-hover-effect:hover {
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}
/* 撤销/重做按钮工具栏样式 */
#undo-redo-toolbar {
position: fixed;
top: 20px;
right: 20px;
background-color: rgba(255, 255, 255, 0.9);
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 8px;
display: flex;
align-items: center;
gap: 4px;
z-index: 1000;
transition: all 0.3s ease;
}
#undo-redo-toolbar:hover {
background-color: rgba(255, 255, 255, 0.95);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}
#undo-redo-toolbar button {
background: none;
border: none;
width: 36px;
height: 36px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 16px;
color: #555;
transition: all 0.2s ease;
outline: none;
position: relative;
}
#undo-redo-toolbar button:hover {
background-color: rgba(0, 0, 0, 0.1);
transform: scale(1.05);
}
#undo-redo-toolbar button:active {
background-color: rgba(0, 0, 0, 0.2);
transform: scale(0.95);
}
#undo-redo-toolbar button:disabled {
color: #ccc;
cursor: not-allowed;
transform: none;
}
#undo-redo-toolbar button:disabled:hover {
background-color: transparent;
transform: none;
}
/* 撤销/重做按钮图标样式 */
.undo-redo-icon {
width: 20px;
height: 20px;
fill: currentColor;
transition: fill 0.2s ease;
}
/* 工具提示样式 */
.tooltip {
position: absolute;
bottom: -35px;
left: 50%;
transform: translateX(-50%);
background-color: rgba(0, 0, 0, 0.8);
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
z-index: 10001;
}
#undo-redo-toolbar button:hover .tooltip {
opacity: 1;
}
/* 小屏幕适配 */
@media (max-width: 768px) {
#undo-redo-toolbar {
top: 10px;
right: 10px;
padding: 6px;
}
#undo-redo-toolbar button {
width: 32px;
height: 32px;
}
.undo-redo-icon {
width: 18px;
height: 18px;
}
}
</style>
</head>
<body>
<!-- 主画布容器 -->
<div id="paper-container"></div>
<!-- 平移模式指示器 -->
<div class="panning-mode-indicator">画布平移模式</div>
<!-- 撤销/重做工具栏 -->
<div id="undo-redo-toolbar">
<button id="undo-btn" type="button" disabled>
<svg class="undo-redo-icon" viewBox="0 0 24 24">
<path d="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z" />
</svg>
<div class="tooltip">撤销 (Ctrl+Z)</div>
</button>
<button id="redo-btn" type="button" disabled>
<svg class="undo-redo-icon" viewBox="0 0 24 24">
<path d="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.53,15.22L3.9,16C4.95,12.81 7.96,10.5 11.5,10.5C13.46,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z" />
</svg>
<div class="tooltip">重做 (Ctrl+Y)</div>
</button>
</div>
<!-- 小地图容器 -->
<div id="minimap-container"></div>
<!-- 缩放控制工具栏 -->
<div id="zoom-toolbar">
<button id="zoom-out" type="button" title="缩小 (Ctrl+-)">
<svg class="toolbar-icon" viewBox="0 0 24 24">
<path d="M19,13H5V11H19V13Z" />
</svg>
</button>
<div id="zoom-percentage" title="点击重置缩放 (Ctrl+0)">100%</div>
<button id="zoom-in" type="button" title="放大 (Ctrl++)">
<svg class="toolbar-icon" viewBox="0 0 24 24">
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
</svg>
</button>
<button id="toggle-minimap" type="button" title="切换小地图显示 (Ctrl+M)">
<svg class="toolbar-icon" viewBox="0 0 24 24">
<path d="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M10,18H6V12H10V18M18,18H12V12H18V18M18,10H6V6H18V10Z" />
</svg>
</button>
</div>
<!-- 测试按钮 (开发时使用) -->
<div id="test-controls" style="position: fixed; top: 10px; right: 10px; z-index: 10000; background: rgba(0,0,0,0.8); padding: 10px; border-radius: 5px; display: none;">
<button onclick="WorkflowAPI.checkUndoRedoCopyPasteStatus()" style="margin: 2px; padding: 5px 10px; background: #2196F3; color: white; border: none; border-radius: 3px; cursor: pointer;">检查状态</button>
<button onclick="testUndoRedo()" style="margin: 2px; padding: 5px 10px; background: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer;">测试撤销/重做</button>
<button onclick="testCopyPaste()" style="margin: 2px; padding: 5px 10px; background: #FF9800; color: white; border: none; border-radius: 3px; cursor: pointer;">测试复制/粘贴</button>
<button onclick="document.getElementById('test-controls').style.display='none'" style="margin: 2px; padding: 5px 10px; background: #f44336; color: white; border: none; border-radius: 3px; cursor: pointer;">隐藏</button>
</div>
<!-- 加载指示器 -->
<div class="loading-indicator" id="loading-indicator">
<div class="loading-spinner"></div>
正在初始化工作流设计器...
</div>
<!-- JointJS依赖库 (本地化) -->
<script src="js/lib/jquery-3.7.1.min.js"></script>
<script src="js/lib/underscore-1.13.6.min.js"></script>
<script src="js/lib/backbone-1.4.1.min.js"></script>
<script src="js/lib/jointjs-3.7.7.min.js"></script>
<!-- 应用模块 -->
<script src="js/core/constants.js"></script>
<script src="js/utils/helpers.js"></script>
<!-- 命令系统 -->
<script src="js/features/command-history.js"></script>
<script src="js/features/commands/node-commands.js"></script>
<script src="js/features/commands/property-commands.js"></script>
<script src="js/features/clipboard-manager.js"></script>
<!-- 核心功能 -->
<script src="js/core/graph.js"></script>
<script src="js/features/node-manager.js"></script>
<script src="js/components/sidebar.js"></script>
<script src="js/components/minimap.js"></script>
<script src="js/components/zoom-toolbar.js"></script>
<script src="js/components/undo-redo-toolbar.js"></script>
<script src="js/components/property-panel.js"></script>
<!-- 主应用入口 -->
<script src="js/main.js"></script>
<script>
// 应用加载完成后隐藏加载指示器
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
const loadingIndicator = document.getElementById('loading-indicator');
if (loadingIndicator) {
loadingIndicator.style.opacity = '0';
loadingIndicator.style.transition = 'opacity 0.5s ease';
setTimeout(() => {
loadingIndicator.style.display = 'none';
}, 500);
}
}, 1000);
});
// 按 Ctrl+Shift+T 显示测试控件
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.shiftKey && e.key === 'T') {
const testControls = document.getElementById('test-controls');
testControls.style.display = testControls.style.display === 'none' ? 'block' : 'none';
}
});
// 测试撤销/重做功能
function testUndoRedo() {
console.log('🧪 开始测试撤销/重做功能...');
// 创建一个测试节点
if (workflowApp) {
const nodeManager = new NodeManager(workflowApp);
const node = nodeManager.createNode('process', 200, 200);
if (node) {
console.log('✅ 节点创建成功:', node.id);
setTimeout(() => {
console.log('🔄 测试撤销...');
WorkflowAPI.undoOperation();
setTimeout(() => {
console.log('🔄 测试重做...');
WorkflowAPI.redoOperation();
}, 1000);
}, 1000);
} else {
console.log('❌ 节点创建失败');
}
}
}
// 测试复制/粘贴功能
function testCopyPaste() {
console.log('🧪 开始测试复制/粘贴功能...');
if (workflowApp) {
const elements = workflowApp.graph.getElements();
if (elements.length > 0) {
// 选中第一个节点
const firstNode = elements[0];
workflowApp.state.selectedElement = firstNode;
console.log('✅ 已选中节点:', firstNode.id);
setTimeout(() => {
console.log('📋 测试复制...');
WorkflowAPI.copySelectedNodes();
setTimeout(() => {
console.log('📋 测试粘贴...');
WorkflowAPI.pasteNodes();
}, 1000);
}, 1000);
} else {
console.log('❌ 画布上没有节点,请先创建一个节点');
// 创建一个节点用于测试
const nodeManager = new NodeManager(workflowApp);
const node = nodeManager.createNode('process', 150, 150);
if (node) {
console.log('✅ 已创建测试节点:', node.id);
workflowApp.state.selectedElement = node;
setTimeout(() => testCopyPaste(), 1000);
}
}
}
}
</script>
</body>
</html>