fix: 修复拖拽问题,松开鼠标结束拖动,互不影响

This commit is contained in:
Zhukj
2026-04-14 18:00:00 +08:00
commit ba45fd0592
4 changed files with 839 additions and 0 deletions

238
style.css Normal file
View File

@@ -0,0 +1,238 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
background: #f5f5f5;
overflow: hidden;
-webkit-user-select: none;
user-select: none;
}
.app {
display: flex;
flex-direction: column;
height: 100vh;
}
/* 顶部工具栏 */
.toolbar {
display: flex;
justify-content: center;
gap: 16px;
padding: 12px 16px;
background: #fff;
border-bottom: 1px solid #e0e0e0;
flex-shrink: 0;
}
.btn {
padding: 10px 24px;
font-size: 15px;
border: 1px solid #ddd;
border-radius: 6px;
background: #fff;
color: #333;
cursor: pointer;
transition: all 0.2s;
}
.btn:active {
background: #f0f0f0;
}
.btn-primary {
background: #4a90e2;
color: #fff;
border-color: #4a90e2;
}
.btn-primary:active {
background: #3a7bc8;
}
/* 图片展示区 */
.canvas-area {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
overflow: auto;
position: relative;
}
.empty-tip {
color: #999;
font-size: 14px;
}
.image-container {
display: none;
position: relative;
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.image-container.show {
display: block;
}
#bgImage {
display: block;
max-width: 100%;
max-height: calc(100vh - 200px);
object-fit: contain;
-webkit-user-drag: none;
}
/* 文字输入框 */
.text-input {
position: absolute;
min-width: 80px;
min-height: 32px;
padding: 4px 8px;
font-size: 18px;
color: #333;
background: rgba(255,255,255,0.9);
border: 2px solid transparent;
border-radius: 4px;
outline: none;
cursor: grab;
white-space: nowrap;
line-height: 1.4;
-webkit-user-select: none;
user-select: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
/* 选中状态(单击) */
.text-input.selected {
border-color: #4a90e2;
box-shadow: 0 0 0 2px rgba(74,144,226,0.3);
cursor: grab;
}
/* 编辑状态(双击) */
.text-input.editing {
border-color: #4a90e2;
background: rgba(255,255,255,0.95);
cursor: text;
-webkit-user-select: text;
user-select: text;
}
/* 拖拽状态 */
.text-input.dragging {
opacity: 0.8;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
cursor: grabbing;
}
/* 隐藏空提示 */
.empty-tip.hidden {
display: none;
}
/* 手机端输入控制区 */
.mobile-input-controls {
display: none;
padding: 12px 16px;
background: #fff;
border-top: 1px solid #e0e0e0;
gap: 12px;
flex-shrink: 0;
}
.mobile-input-controls.show {
display: flex;
}
.input-control-group {
flex: 1;
display: flex;
flex-direction: column;
gap: 4px;
}
.input-control-group label {
font-size: 12px;
color: #666;
}
.input-control-group input {
padding: 10px 12px;
font-size: 15px;
border: 1px solid #ddd;
border-radius: 6px;
outline: none;
-webkit-user-select: text;
user-select: text;
}
.input-control-group input:focus {
border-color: #4a90e2;
}
/* 长按提示 */
.long-press-tip {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
padding: 8px 16px;
background: rgba(0,0,0,0.7);
color: #fff;
font-size: 12px;
border-radius: 16px;
opacity: 0;
transition: opacity 0.3s;
pointer-events: none;
z-index: 1000;
}
.long-press-tip.show {
opacity: 1;
}
/* 右键菜单 */
.context-menu {
position: fixed;
background: #fff;
border: 1px solid #ddd;
border-radius: 6px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
padding: 4px 0;
z-index: 1000;
min-width: 120px;
}
.context-menu-item {
padding: 10px 16px;
font-size: 14px;
color: #333;
cursor: pointer;
transition: background 0.2s;
}
.context-menu-item:hover {
background: #f5f5f5;
}
.context-menu-item:active {
background: #e8e8e8;
}
/* 移动端适配 */
@media (max-width: 768px) {
.mobile-input-controls {
display: flex;
}
#bgImage {
max-height: calc(100vh - 280px);
}
}