Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8aecaeb03 | |||
| bf63610510 | |||
| 7af3a7f21d |
@@ -55,7 +55,8 @@ def list_items():
|
|||||||
status=request.args.get('status'),
|
status=request.args.get('status'),
|
||||||
tag=request.args.get('tag'),
|
tag=request.args.get('tag'),
|
||||||
keyword=request.args.get('keyword'),
|
keyword=request.args.get('keyword'),
|
||||||
starred=starred
|
starred=starred,
|
||||||
|
folder_id=folder_id
|
||||||
)
|
)
|
||||||
|
|
||||||
return jsonify({'success': True, 'data': items, 'total': total})
|
return jsonify({'success': True, 'data': items, 'total': total})
|
||||||
@@ -929,12 +930,49 @@ INDEX_TEMPLATE = '''
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 文件夹列表样式 */
|
/* 文件夹列表样式 - 折叠式 */
|
||||||
.sidebar-section .section-header { font-weight: 500; }
|
.sidebar-section { margin-bottom: 2px; }
|
||||||
|
.sidebar-section .section-header {
|
||||||
|
font-weight: 500;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
.sidebar-section .section-header .header-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.sidebar-section .section-header .toggle-arrow {
|
||||||
|
font-size: 10px;
|
||||||
|
margin-right: 8px;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
.sidebar-section.expanded .section-header .toggle-arrow {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
.sidebar-section .section-header .new-folder-btn {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #adb5bd;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
background: rgba(255,255,255,0.1);
|
||||||
|
}
|
||||||
|
.sidebar-section .section-header .new-folder-btn:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: #28a745;
|
||||||
|
}
|
||||||
.folder-list {
|
.folder-list {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
max-height: 150px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
display: none; /* 默认隐藏 */
|
||||||
|
}
|
||||||
|
.sidebar-section.expanded .folder-list {
|
||||||
|
display: block; /* 展开时显示 */
|
||||||
}
|
}
|
||||||
.folder-list a {
|
.folder-list a {
|
||||||
padding: 6px 20px;
|
padding: 6px 20px;
|
||||||
@@ -1041,31 +1079,59 @@ INDEX_TEMPLATE = '''
|
|||||||
<a href="#" data-filter="starred"><i class="bi bi-star-fill" style="color:#ffc107;"></i> 重点关注</a>
|
<a href="#" data-filter="starred"><i class="bi bi-star-fill" style="color:#ffc107;"></i> 重点关注</a>
|
||||||
|
|
||||||
<!-- 文本类别 -->
|
<!-- 文本类别 -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section" id="section-text">
|
||||||
<a href="#" data-filter="text" class="section-header"><i class="bi bi-file-text"></i> 文本</a>
|
<a href="#" class="section-header" onclick="toggleSection('text'); return false;">
|
||||||
|
<span class="header-left">
|
||||||
|
<span class="toggle-arrow"><i class="bi bi-chevron-right"></i></span>
|
||||||
|
<i class="bi bi-file-text"></i> 文本
|
||||||
|
</span>
|
||||||
|
<span class="new-folder-btn" onclick="event.stopPropagation(); showNewFolderModal('text'); return false;">
|
||||||
|
<i class="bi bi-folder-plus"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<div class="folder-list" id="folderList-text"></div>
|
<div class="folder-list" id="folderList-text"></div>
|
||||||
<a href="#" class="folder-action" onclick="showNewFolderModal('text'); return false;"><i class="bi bi-folder-plus"></i> 新建文件夹</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 链接类别 -->
|
<!-- 链接类别 -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section" id="section-link">
|
||||||
<a href="#" data-filter="link" class="section-header"><i class="bi bi-link-45deg"></i> 链接</a>
|
<a href="#" class="section-header" onclick="toggleSection('link'); return false;">
|
||||||
|
<span class="header-left">
|
||||||
|
<span class="toggle-arrow"><i class="bi bi-chevron-right"></i></span>
|
||||||
|
<i class="bi bi-link-45deg"></i> 链接
|
||||||
|
</span>
|
||||||
|
<span class="new-folder-btn" onclick="event.stopPropagation(); showNewFolderModal('link'); return false;">
|
||||||
|
<i class="bi bi-folder-plus"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<div class="folder-list" id="folderList-link"></div>
|
<div class="folder-list" id="folderList-link"></div>
|
||||||
<a href="#" class="folder-action" onclick="showNewFolderModal('link'); return false;"><i class="bi bi-folder-plus"></i> 新建文件夹</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 专栏类别 -->
|
<!-- 专栏类别 -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section" id="section-column">
|
||||||
<a href="#" data-filter="column" class="section-header"><i class="bi bi-newspaper"></i> 专栏</a>
|
<a href="#" class="section-header" onclick="toggleSection('column'); return false;">
|
||||||
|
<span class="header-left">
|
||||||
|
<span class="toggle-arrow"><i class="bi bi-chevron-right"></i></span>
|
||||||
|
<i class="bi bi-newspaper"></i> 专栏
|
||||||
|
</span>
|
||||||
|
<span class="new-folder-btn" onclick="event.stopPropagation(); showNewFolderModal('column'); return false;">
|
||||||
|
<i class="bi bi-folder-plus"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<div class="folder-list" id="folderList-column"></div>
|
<div class="folder-list" id="folderList-column"></div>
|
||||||
<a href="#" class="folder-action" onclick="showNewFolderModal('column'); return false;"><i class="bi bi-folder-plus"></i> 新建文件夹</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 待办类别 -->
|
<!-- 待办类别 -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section" id="section-todo">
|
||||||
<a href="#" data-filter="todo" class="section-header"><i class="bi bi-check2-square"></i> 待办</a>
|
<a href="#" class="section-header" onclick="toggleSection('todo'); return false;">
|
||||||
|
<span class="header-left">
|
||||||
|
<span class="toggle-arrow"><i class="bi bi-chevron-right"></i></span>
|
||||||
|
<i class="bi bi-check2-square"></i> 待办
|
||||||
|
</span>
|
||||||
|
<span class="new-folder-btn" onclick="event.stopPropagation(); showNewFolderModal('todo'); return false;">
|
||||||
|
<i class="bi bi-folder-plus"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<div class="folder-list" id="folderList-todo"></div>
|
<div class="folder-list" id="folderList-todo"></div>
|
||||||
<a href="#" class="folder-action" onclick="showNewFolderModal('todo'); return false;"><i class="bi bi-folder-plus"></i> 新建文件夹</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="border-secondary">
|
<hr class="border-secondary">
|
||||||
@@ -3375,15 +3441,20 @@ async function loadFolders() {
|
|||||||
|
|
||||||
function renderFolderList(type) {
|
function renderFolderList(type) {
|
||||||
const container = document.getElementById(`folderList-${type}`);
|
const container = document.getElementById(`folderList-${type}`);
|
||||||
|
const section = document.getElementById(`section-${type}`);
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
const folders = allFolders[type] || [];
|
const folders = allFolders[type] || [];
|
||||||
|
|
||||||
if (folders.length === 0) {
|
if (folders.length === 0) {
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
|
if (section) section.classList.remove('expanded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 默认不展开,保持折叠状态
|
||||||
|
// if (section) section.classList.add('expanded'); // 已移除
|
||||||
|
|
||||||
container.innerHTML = folders.map(f => `
|
container.innerHTML = folders.map(f => `
|
||||||
<a href="#" data-folder="${f.id}" onclick="filterByFolder('${type}', ${f.id}); return false;">
|
<a href="#" data-folder="${f.id}" onclick="filterByFolder('${type}', ${f.id}); return false;">
|
||||||
<i class="bi bi-folder"></i> ${f.name} <small class="text-muted">(${f.item_count || 0})</small>
|
<i class="bi bi-folder"></i> ${f.name} <small class="text-muted">(${f.item_count || 0})</small>
|
||||||
@@ -3391,6 +3462,24 @@ function renderFolderList(type) {
|
|||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换文件夹区域展开/折叠
|
||||||
|
// 切换文件夹区域展开/折叠,并过滤显示该类别数据
|
||||||
|
function toggleSection(type) {
|
||||||
|
const section = document.getElementById(`section-${type}`);
|
||||||
|
if (!section) return;
|
||||||
|
|
||||||
|
// 切换展开状态
|
||||||
|
section.classList.toggle('expanded');
|
||||||
|
|
||||||
|
// 更新侧边栏选中状态
|
||||||
|
document.querySelectorAll('.sidebar a').forEach(a => a.classList.remove('active'));
|
||||||
|
section.querySelector('.section-header').classList.add('active');
|
||||||
|
|
||||||
|
// 设置过滤条件:只过滤类型,不限制文件夹
|
||||||
|
currentFilter = { type, status: '', starred: null, folder_id: null };
|
||||||
|
loadItems(1);
|
||||||
|
}
|
||||||
|
|
||||||
async function showNewFolderModal(type) {
|
async function showNewFolderModal(type) {
|
||||||
// 离线检查
|
// 离线检查
|
||||||
if (!checkOnlineBeforeAction('新建文件夹')) return;
|
if (!checkOnlineBeforeAction('新建文件夹')) return;
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class Database:
|
|||||||
return items
|
return items
|
||||||
|
|
||||||
def count_items(self, type: str = None, status: str = None, tag: str = None,
|
def count_items(self, type: str = None, status: str = None, tag: str = None,
|
||||||
keyword: str = None, starred: bool = None) -> int:
|
keyword: str = None, starred: bool = None, folder_id: int = None) -> int:
|
||||||
"""计算符合条件的条目总数"""
|
"""计算符合条件的条目总数"""
|
||||||
with self.get_conn() as conn:
|
with self.get_conn() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@@ -358,6 +358,15 @@ class Database:
|
|||||||
keyword_pattern = f"%{keyword}%"
|
keyword_pattern = f"%{keyword}%"
|
||||||
params.extend([keyword_pattern, keyword_pattern, keyword_pattern])
|
params.extend([keyword_pattern, keyword_pattern, keyword_pattern])
|
||||||
|
|
||||||
|
# 文件夹过滤
|
||||||
|
if folder_id is not None:
|
||||||
|
if folder_id == -1:
|
||||||
|
# 未分类:folder_id为NULL
|
||||||
|
conditions.append("i.folder_id IS NULL")
|
||||||
|
else:
|
||||||
|
conditions.append("i.folder_id = ?")
|
||||||
|
params.append(folder_id)
|
||||||
|
|
||||||
if conditions:
|
if conditions:
|
||||||
query += " WHERE " + " AND ".join(conditions)
|
query += " WHERE " + " AND ".join(conditions)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user