From e9a755fbe159eb1d94a595daacd0c85488d552d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=97=E7=8F=8F?= Date: Mon, 7 Jul 2025 20:08:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E8=BF=81=E5=B7=A6=E5=8F=B3=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E3=80=81=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A1=B5=E8=84=9A?= =?UTF-8?q?=E7=AD=89=E5=8A=9F=E8=83=BD,=E5=BA=94=E7=94=A8=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=9B=BE=E6=A0=87BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 +- app.py | 95 +- data/settings.json | 5 +- templates/attachments.html | 47 +- templates/base.html | 8 +- templates/edit_app.html | 223 ++-- templates/footer.html | 6 + templates/index.html | 2298 +++++++++++++++++++----------------- templates/manage.html | 41 + templates/settings.html | 25 + 10 files changed, 1531 insertions(+), 1242 deletions(-) create mode 100644 templates/footer.html diff --git a/README.md b/README.md index 519eadd..5e6cd07 100644 --- a/README.md +++ b/README.md @@ -14,29 +14,28 @@ ### 界面优化 1. 每行卡片数量支持自定义(4个、5个、6个、8个) 2. 应用的图标支持上传图片自定义 - 已完成 -3. 首页增加页脚 -4. 一级分类和二级分类固定宽度,超出宽度可左右滑动查看 +3. 自定义页脚 - 已完成 +4. 一级分类和二级分类固定宽度,超出宽度可左右滑动查看 - 已完成 5. 气泡的小箭头靠左对齐 - 已完成 6. logo图标设置区分明亮和暗黑模式 7. 私有应用在首页添加标识 8. 首页卡片右键菜单 9. 应用支持配置多个URL,左键打开默认URL,右键可选择URL进行复制地址或者打开或者编辑应用 +10. 新增应用界面便捷增加分类 +11. 新增应用界面便捷增加图标图片 ### 功能增强 -8. 应用管理页支持分页和按一级分类筛选 -9. 应用分页和附件分页功能 -10. 网站图标自动获取功能 -11. 书签收藏工具 +1. 应用管理页支持分页和按一级分类筛选 - 已完成 +2. 应用分页和附件分页功能 - 已完成 +3. 网站图标自动获取功能 +4. 书签收藏工具 ### BUG修复 -12. 应用编辑页面没有回显带入图片 +1. 应用编辑页面没有回显带入图片 - 已解决 ### 批量操作 -13. 应用批量选择功能: +1. 应用批量选择功能: - 批量删除 - 批量设置私有化/公有化 -14. 附件批量选择功能: - - 批量删除 - -15. 新增应用界面便捷增加分类 -16. 新增应用界面便捷增加图标图片 \ No newline at end of file +2. 附件批量选择功能: + - 批量删除 \ No newline at end of file diff --git a/app.py b/app.py index 3764c42..c46ebb6 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,7 @@ from functools import wraps from werkzeug.utils import secure_filename import requests from urllib.parse import urlparse +from math import ceil app = Flask(__name__) app.secret_key = 'your_secret_key_here' # 请更改为安全的密钥 @@ -44,6 +45,7 @@ SETTINGS_FILE = os.path.join(DATA_DIR, 'settings.json') GUEST_SETTINGS_FILE = os.path.join(DATA_DIR, 'guest_settings.json') + def migrate_settings(settings): """迁移旧版设置到新版格式""" if 'admin_password' in settings: @@ -59,6 +61,12 @@ def migrate_settings(settings): '123456', method='pbkdf2:sha256' ) + + # 确保有页脚设置 + if 'footer_html' not in settings: + settings[ + 'footer_html'] = '
Powered By AIDaohang
' + return settings @@ -78,7 +86,8 @@ def init_settings(): "logo_icon": "fa-th-list", "logo_image": "", "uploaded_backgrounds": [], - "uploaded_logos": [] + "uploaded_logos": [], + "footer_html": '
Powered By AIDaohang
' } with open(SETTINGS_FILE, 'w', encoding='utf-8') as f: json.dump(default_settings, f, ensure_ascii=False, indent=2) @@ -90,6 +99,14 @@ def init_settings(): if 'admin_password_hash' not in settings: # 需要迁移 settings = migrate_settings(settings) + # 添加新字段的默认值 + if 'footer_html' not in settings: + settings['footer_html'] = '
Powered By AIDaohang
' + with open(SETTINGS_FILE, 'w', encoding='utf-8') as f: + json.dump(settings, f, ensure_ascii=False, indent=2) + elif 'footer_html' not in settings: + # 已有密码哈希但没有页脚设置的情况 + settings['footer_html'] = '
Powered By AIDaohang
' with open(SETTINGS_FILE, 'w', encoding='utf-8') as f: json.dump(settings, f, ensure_ascii=False, indent=2) @@ -356,6 +373,7 @@ def system_settings(): settings['site_title'] = request.form.get('site_title', '应用导航中心') settings['show_logo'] = 'show_logo' in request.form settings['logo_type'] = request.form.get('logo_type', 'icon') + settings['footer_html'] = request.form.get('footer_html', '') # 处理logo设置 if settings['logo_type'] == 'icon': @@ -467,9 +485,38 @@ def system_settings(): @app.route('/attachments') @login_required def manage_attachments(): + type_filter = request.args.get('type', 'all') + search_query = request.args.get('search', '').lower() + page = int(request.args.get('page', 1)) + per_page = 10 # 每页显示10条数据 + settings = load_settings() attachments = load_attachments() - return render_template('attachments.html', settings=settings, attachments=attachments) + + # 应用筛选 + filtered_attachments = [] + for attachment in attachments: + # 类型筛选 + if type_filter != 'all' and attachment['type'] != type_filter: + continue + + # 搜索筛选 + if search_query and search_query not in attachment['filename'].lower(): + continue + + filtered_attachments.append(attachment) + + # 分页处理 + total_pages = ceil(len(filtered_attachments) / per_page) + paginated_attachments = filtered_attachments[(page - 1) * per_page: page * per_page] + + return render_template('attachments.html', + settings=settings, + attachments=paginated_attachments, + current_page=page, + total_pages=total_pages, + search_query=search_query, + type_filter=type_filter) @app.route('/upload_attachment', methods=['POST']) @@ -573,21 +620,45 @@ def handle_settings(): @login_required def index(): category_filter = request.args.get('category') + search_query = request.args.get('search', '').lower() + page = int(request.args.get('page', 1)) + per_page = 10 # 每页显示10条数据 + apps = load_apps() categories = load_categories() settings = load_settings() - if category_filter: - filtered_apps = [] - for app in apps: - # 检查是否匹配主分类或子分类 - if (app['category']['main'] == category_filter or - app['category']['sub'] == category_filter or - (category_filter in categories and app['category']['main'] == category_filter)): - filtered_apps.append(app) - apps = filtered_apps + # 应用筛选 + filtered_apps = [] + for app in apps: + # 分类筛选 + if category_filter and not (app['category']['main'] == category_filter or + app['category']['sub'] == category_filter or + (category_filter in categories and app['category']['main'] == category_filter)): + continue - return render_template('manage.html', apps=apps, settings=settings, categories=categories) + # 搜索筛选 + if search_query and not (search_query in app['title'].lower() or + search_query in app['url'].lower() or + search_query in app.get('description', '').lower() or + search_query in app['category']['main'].lower() or + search_query in app['category']['sub'].lower()): + continue + + filtered_apps.append(app) + + # 分页处理 + total_pages = ceil(len(filtered_apps) / per_page) + paginated_apps = filtered_apps[(page - 1) * per_page: page * per_page] + + return render_template('manage.html', + apps=paginated_apps, + settings=settings, + categories=categories, + current_page=page, + total_pages=total_pages, + search_query=search_query, + category_filter=category_filter) @app.route('/') def navigation(): diff --git a/data/settings.json b/data/settings.json index a68e9d8..c689b4a 100644 --- a/data/settings.json +++ b/data/settings.json @@ -8,7 +8,8 @@ "show_logo": true, "logo_type": "image", "logo_icon": "fa-solid fa-th-list", - "logo_image": "/upload/logo/5378dda810964da9a7515ec844628738.png", + "logo_image": "/upload/logo/b2c128cf2d4e47daa349c5e7f38c932c.png", "dark_bg_rotate": false, - "admin_password_hash": "scrypt:32768:8:1$mPFCfRRzOrcjE6z3$e72ef50a2d3f7292f64bcfc5e21f32c95ea8665414ea8d5f6b216735d68f151166c99fae21132c7949bd92ea32041f969cd4a471adb110a99328089541f7dccb" + "admin_password_hash": "scrypt:32768:8:1$mPFCfRRzOrcjE6z3$e72ef50a2d3f7292f64bcfc5e21f32c95ea8665414ea8d5f6b216735d68f151166c99fae21132c7949bd92ea32041f969cd4a471adb110a99328089541f7dccb", + "footer_html": "
\r\n
\r\n © 2023 AIDaohang. All rights reserved.\r\n |\r\n Powered by AIDaohang\r\n
\r\n
" } \ No newline at end of file diff --git a/templates/attachments.html b/templates/attachments.html index 208b23d..e6d8979 100644 --- a/templates/attachments.html +++ b/templates/attachments.html @@ -32,7 +32,25 @@
-
附件列表
+
+
附件列表
+
+ + + + {% if type_filter != 'all' or search_query %} + 重置 + {% endif %} +
+
@@ -83,12 +101,37 @@ {% else %} - + {% endfor %}
暂无附件没有找到匹配的附件
+ + + {% if total_pages > 1 %} + + {% endif %}
diff --git a/templates/base.html b/templates/base.html index 9ab643f..2f5e97f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -13,7 +13,7 @@ @@ -612,29 +668,29 @@ body.dark-theme .app-url {
-
- -
-
+
+ +
+
-
-
- -
-
- -
+
+
+
+
+ +
+
-
-
-
-

正在加载应用数据...

-
+
+
+
+

正在加载应用数据...

+
@@ -643,229 +699,247 @@ body.dark-theme .app-url {
- diff --git a/templates/manage.html b/templates/manage.html index dc5b16e..71cf799 100644 --- a/templates/manage.html +++ b/templates/manage.html @@ -10,6 +10,15 @@ 添加应用
+
+
+ + + +
+
@@ -31,6 +40,9 @@
+ {% if category_filter or search_query %} + 重置 + {% endif %}
@@ -86,10 +98,39 @@ + {% else %} + + 没有找到匹配的应用 + {% endfor %} + + + {% if total_pages > 1 %} + + {% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/settings.html b/templates/settings.html index 3081d7e..fdb969f 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -280,6 +280,27 @@ + +
+
+
页脚设置
+
+
+
+ + +
支持HTML代码,可用于添加版权信息、统计代码等
+
+ +
+
预览效果:
+ +
+
+
+
@@ -464,6 +485,10 @@