Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8aecaeb03 | |||
| bf63610510 |
@@ -55,7 +55,8 @@ def list_items():
|
||||
status=request.args.get('status'),
|
||||
tag=request.args.get('tag'),
|
||||
keyword=request.args.get('keyword'),
|
||||
starred=starred
|
||||
starred=starred,
|
||||
folder_id=folder_id
|
||||
)
|
||||
|
||||
return jsonify({'success': True, 'data': items, 'total': total})
|
||||
@@ -3462,11 +3463,21 @@ function renderFolderList(type) {
|
||||
}
|
||||
|
||||
// 切换文件夹区域展开/折叠
|
||||
// 切换文件夹区域展开/折叠,并过滤显示该类别数据
|
||||
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) {
|
||||
|
||||
@@ -326,7 +326,7 @@ class Database:
|
||||
return items
|
||||
|
||||
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:
|
||||
cursor = conn.cursor()
|
||||
@@ -358,6 +358,15 @@ class Database:
|
||||
keyword_pattern = f"%{keyword}%"
|
||||
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:
|
||||
query += " WHERE " + " AND ".join(conditions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user