From daecbf4603fadc2cb9dffb33c1f8fb4472919af1 Mon Sep 17 00:00:00 2001
From: changjunqiang <344656718@qq.com>
Date: Tue, 16 Jun 2026 09:25:40 +0800
Subject: [PATCH] add drawer effect
---
src/views/ChapterView.vue | 128 ++++++++++++++++++++++++++++----------
1 file changed, 96 insertions(+), 32 deletions(-)
diff --git a/src/views/ChapterView.vue b/src/views/ChapterView.vue
index 789e127..68af836 100644
--- a/src/views/ChapterView.vue
+++ b/src/views/ChapterView.vue
@@ -70,23 +70,27 @@
-
-
-
-
-
-
👆
-
请从上方选择一个代码文件查看其源码
-
-
+
+
+
+
+
+
@@ -121,6 +125,10 @@ function selectFile(file) {
currentFile.value = file
}
+function closeDrawer() {
+ currentFile.value = null
+}
+
function getFolderDescription(folderName) {
const descriptions = {
mergesort: '归并排序是分治法的经典应用:将数组一分为二,分别排序后合并。时间复杂度 O(n log n)。',
@@ -353,31 +361,87 @@ function getFolderDescription(folderName) {
margin-left: 20px;
}
-.code-section {
- margin: 32px 0;
+/* ========== Drawer ========== */
+.drawer-overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 1000;
+ background: rgba(0, 0, 0, 0.45);
+ display: flex;
+ justify-content: flex-end;
}
-.code-section-label {
- margin-bottom: 16px;
+.drawer-panel {
+ width: min(720px, 90vw);
+ height: 100%;
+ background: var(--bg);
+ display: flex;
+ flex-direction: column;
+ box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}
-.empty-section {
- padding: 60px 0;
- text-align: center;
+.drawer-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16px 20px;
+ border-bottom: 1px solid var(--border-color);
+ flex-shrink: 0;
}
-.empty-state {
- color: var(--text-tertiary);
+.drawer-title {
+ font-size: 17px;
+ font-weight: 700;
+ color: var(--text-primary);
}
-.empty-icon {
- font-size: 40px;
- display: block;
- margin-bottom: 12px;
+.drawer-close-btn {
+ background: none;
+ border: none;
+ font-size: 20px;
+ cursor: pointer;
+ color: var(--text-secondary);
+ padding: 4px 10px;
+ border-radius: 6px;
+ transition: all 0.15s;
}
-.empty-state p {
- font-size: 15px;
+.drawer-close-btn:hover {
+ background: var(--hover-bg);
+ color: var(--text-primary);
+}
+
+.drawer-body {
+ flex: 1;
+ overflow-y: auto;
+ padding: 0;
+}
+
+.drawer-body .code-viewer {
+ border-radius: 0;
+ border: none;
+ min-height: 100%;
+}
+
+/* 抽屉过渡动画 */
+.drawer-enter-active,
+.drawer-leave-active {
+ transition: opacity 0.25s ease;
+}
+
+.drawer-enter-active .drawer-panel,
+.drawer-leave-active .drawer-panel {
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
+}
+
+.drawer-enter-from,
+.drawer-leave-to {
+ opacity: 0;
+}
+
+.drawer-enter-from .drawer-panel,
+.drawer-leave-to .drawer-panel {
+ transform: translateX(100%);
}
.not-found {