From e92349e11191458dfa80f33952c7a7e794036305 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Wed, 22 Apr 2026 16:59:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(v4.2.1):=20=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96+?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E5=88=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hover文件夹时按钮悬浮在右侧,高度一致 - 新增数据按钮(绿色+)直接添加数据到该文件夹 --- xian_favor/api.py | 87 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/xian_favor/api.py b/xian_favor/api.py index ede87fc..96b6ead 100644 --- a/xian_favor/api.py +++ b/xian_favor/api.py @@ -1087,18 +1087,38 @@ INDEX_TEMPLATE = ''' .folder-list a i { margin-right: 5px; } .folder-list .folder-item { display: flex; + align-items: center; padding: 6px 10px; + position: relative; } .folder-list .folder-item a { - padding: 0 10px; + padding: 6px 10px; flex-grow: 1; + display: flex; + align-items: center; } .folder-list .folder-actions { + position: absolute; + right: 10px; display: none; + gap: 4px; + background: #343a40; + padding: 4px 8px; + border-radius: 4px; } .folder-list .folder-item:hover .folder-actions { display: flex; - gap: 2px; + } + .folder-list .folder-actions .btn { + padding: 2px 6px; + font-size: 12px; + line-height: 1; + } + .folder-list .folder-item:hover { + background: #495057; + } + .folder-list .folder-item:hover a { + color: #fff; } .folder-action { font-size: 12px; @@ -2664,6 +2684,9 @@ function showAddModal(type) { // 设置类型 document.getElementById('addType').value = type; + // 重置文件夹ID(从顶部按钮添加时不指定文件夹) + currentAddFolderId = null; + // 只有不是编辑草稿时才重置 // currentDraftId 在 editDraft 中已设置,不要覆盖 @@ -2720,7 +2743,8 @@ async function addItem() { due_date: type === 'todo' ? document.getElementById('addDueDate').value : null, note: document.getElementById('addNote').value, tags: document.getElementById('addTags').value.split(',').map(t => t.trim()).filter(t => t), - is_starred: document.getElementById('addStarred').checked + is_starred: document.getElementById('addStarred').checked, + folder_id: currentAddFolderId // 如果从文件夹添加,带上文件夹ID }; const res = await fetch(`${API_BASE}/items`, { @@ -2741,6 +2765,7 @@ async function addItem() { stopAutoSave(); hideDraftIndicator(); + currentAddFolderId = null; // 重置文件夹ID refreshData(); } } @@ -4194,10 +4219,13 @@ function renderFolderList(type) { ${f.name} (${f.item_count || 0})
- + -
@@ -4327,6 +4355,55 @@ async function deleteFolderConfirm(folderId, folderName) { } } +// 显示新增数据到文件夹的模态框 +function showAddToFolderModal(type, folderId) { + // 离线检查 + if (!checkOnlineBeforeAction('添加数据')) return; + + // 设置类型 + document.getElementById('addType').value = type; + document.getElementById('editFolderId').value = ''; // 重置编辑ID + + // 设置弹窗标题和图标 + const typeInfo = { + text: { icon: '📝', title: '添加文本' }, + link: { icon: '🔗', title: '添加链接' }, + column: { icon: '📰', title: '添加专栏' }, + todo: { icon: '✅', title: '添加待办' } + }; + + document.getElementById('addModalIcon').textContent = typeInfo[type].icon; + document.getElementById('addModalTitle').textContent = typeInfo[type].title; + + // 显示/隐藏对应字段 + document.getElementById('contentGroup').style.display = type === 'text' ? 'block' : 'none'; + document.getElementById('urlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none'; + document.getElementById('sourceGroup').style.display = type === 'column' ? 'block' : 'none'; + document.getElementById('todoFields').style.display = type === 'todo' ? 'block' : 'none'; + + // 清空表单 + document.getElementById('addForm').reset(); + hideDraftIndicator(); + + // 设置默认文件夹(隐藏字段,需要在提交时带上) + currentAddFolderId = folderId; + + // 打开弹窗 + new bootstrap.Modal(document.getElementById('addModal')).show(); + + // 启动自动保存 + startAutoSave(); + + // 弹框关闭时停止自动保存并重置文件夹ID + document.getElementById('addModal').addEventListener('hidden.bs.modal', () => { + stopAutoSave(); + currentAddFolderId = null; + }, { once: true }); +} + +// 当前新增时的文件夹ID +let currentAddFolderId = null; + function filterByFolder(type, folderId) { // 更新侧边栏选中状态 document.querySelectorAll('.sidebar a').forEach(a => a.classList.remove('active'));