diff --git a/app.py b/app.py index 566541b..bcb4438 100644 --- a/app.py +++ b/app.py @@ -206,7 +206,9 @@ def delete_article(): return jsonify({'error': 'Missing article ID'}), 400 # 调用删除函数 - success = delete_entry(int(article_id)),decrease_count() + print('删除',article_id) + success = delete_entry(int(article_id)) and decrease_count() + print('zzz',success) if success: return jsonify({'message': 'Article deleted successfully'}), 200 diff --git a/config.json b/config.json index 3a4c29b..58ec866 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "count": "44", + "count": 2, "translation_services": { "doubao": { "auth_key": "XX", diff --git a/static/1.js b/static/1.js index 85b8745..b50e59b 100644 --- a/static/1.js +++ b/static/1.js @@ -4,18 +4,44 @@ // 显示主页 function showHome() { + document.getElementById('recentread').innerHTML = 'Recent Reading'; + document.getElementById('articleContainer').style.display = ''; document.getElementById('viewAllSection').style.display = 'flex'; document.querySelector('.sidebar-menu a[onclick="showHome()"]').classList.add('active'); document.querySelector('.sidebar-menu a[onclick="showAllRecent()"]').classList.remove('active'); - loadArticles(true,true); // true表示只显示前3条 + document.querySelector('.sidebar-menu a[onclick="showSetup()"]').classList.remove('active'); // 添加这行 + loadArticles(true,true); + document.getElementById('t-container').style.display = ''; } - // 显示所有最近阅读 function showAllRecent() { + document.getElementById('recentread').innerHTML = 'Recent Reading'; + + document.getElementById('articleContainer').style.display = ''; document.getElementById('viewAllSection').style.display = 'none'; document.querySelector('.sidebar-menu a[onclick="showHome()"]').classList.remove('active'); document.querySelector('.sidebar-menu a[onclick="showAllRecent()"]').classList.add('active'); - loadArticles(false,true); // false表示显示所有数据 + document.querySelector('.sidebar-menu a[onclick="showSetup()"]').classList.remove('active'); // 添加这行 + loadArticles(false,true); + document.getElementById('t-container').style.display = ''; + } + // 添加新的函数处理 Setup steps + function showSetup() { + // 隐藏其他部分(如果需要的话) + + + document.getElementById('recentread').innerHTML = 'config.json'; + document.getElementById('articleContainer').style.display = 'none'; + document.getElementById('viewAllSection').style.display = 'none'; + + + // 移除其他菜单项的 active 类 + document.querySelector('.sidebar-menu a[onclick="showHome()"]').classList.remove('active'); + document.querySelector('.sidebar-menu a[onclick="showAllRecent()"]').classList.remove('active'); + + // 给 Setup steps 添加 active 类 + document.querySelector('.sidebar-menu a[onclick="showSetup()"]').classList.add('active'); + document.getElementById('t-container').style.display = 'block'; } // 显示上传模态框 @@ -26,6 +52,8 @@ } + + // 显示设置模态框 function showSettings() { document.getElementById('settingsModal').style.display = 'block'; diff --git a/static/2.js b/static/2.js index 6b86b24..28cba11 100644 --- a/static/2.js +++ b/static/2.js @@ -124,6 +124,22 @@ function initSettings() { }); } +function getecount() { + fetch('/api/get-default-services') + .then(response => response.json()) + .then(data => { + if (data.success && data.data) { + const settings = data.data; + + document.getElementById('count_article').textContent = ` Articles in Total: ${settings.count} `; + } + }) + .catch(error => { + console.error('获取设置失败:', error); + alert('获取设置失败,请稍后重试'); + }); +} + // 页面加载时初始化设置 document.addEventListener('DOMContentLoaded', initSettings); diff --git a/static/3.js b/static/3.js index 382f99e..13b9c36 100644 --- a/static/3.js +++ b/static/3.js @@ -423,6 +423,7 @@ function deleteArticle(articleId) { const value = document.getElementById('record_show_staute').getAttribute('data-value') === 'true'; loadArticles(value,false) + getecount() } else { throw new Error('删除失败'); }