diff --git a/src/components/LivePreviewEditor.vue b/src/components/LivePreviewEditor.vue index 4645f89..e37c87a 100644 --- a/src/components/LivePreviewEditor.vue +++ b/src/components/LivePreviewEditor.vue @@ -4,8 +4,12 @@
-
-
+
+
暂无大纲
+ + +
{ + isResizing.value = true; + startX = e.clientX; + startWidth = tocWidth.value; + + document.addEventListener('mousemove', handleResize); + document.addEventListener('mouseup', stopResize); + document.body.style.cursor = 'col-resize'; + document.body.style.userSelect = 'none'; +}; + +const handleResize = (e) => { + if (!isResizing.value) return; + const diff = e.clientX - startX; + const newWidth = Math.max(150, Math.min(600, startWidth + diff)); + tocWidth.value = newWidth; +}; + +const stopResize = () => { + isResizing.value = false; + document.removeEventListener('mousemove', handleResize); + document.removeEventListener('mouseup', stopResize); + document.body.style.cursor = ''; + document.body.style.userSelect = ''; +}; const debounce = (fn, delay) => { let timer = null; @@ -480,16 +521,20 @@ onUnmounted(() => { } .toc-sidebar { - width: 220px; + /* width: 220px; 由 JS 控制 */ flex-shrink: 0; border-right: 1px solid var(--border-color); overflow-y: auto; overflow-x: hidden; background-color: var(--card-background); - transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); + transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s; opacity: 1; } +.toc-sidebar.resizing { + transition: none; +} + .toc-sidebar.collapsed { width: 0; opacity: 0; @@ -497,10 +542,25 @@ onUnmounted(() => { } .toc-content { - width: 220px; /* 固定宽度,防止内容挤压 */ + /* width: 220px; 由 JS 控制 */ padding: 12px 0; } +.toc-resizer { + width: 4px; + cursor: col-resize; + background-color: transparent; + transition: background-color 0.2s; + flex-shrink: 0; + margin-left: -1px; /* 重叠边框 */ + z-index: 10; + position: relative; +} + +.toc-resizer:hover, .toc-sidebar.resizing + .toc-resizer { + background-color: var(--primary-color); +} + .toc-empty { padding: 20px; text-align: center;