feat(C-02):工具热榜周榜+最近使用

新增ToolUsageRecord使用日志(tool+created_at索引);/tool/top/总榜按累计排序、周榜按近7天聚合(无日志回退总榜,兼容period旧参);/tool/recent/登录去重倒序;seed新增AI图片放大/代码运行两个工具。
This commit is contained in:
chunyu
2026-09-15 15:20:27 +08:00
parent 37cad3947d
commit 24874aae23
7 changed files with 300 additions and 2 deletions
+6
View File
@@ -19,6 +19,10 @@ class Command(BaseCommand):
name='实用',
defaults={'icon': 'ThunderboltOutlined', 'sort_order': 3}
)[0],
'AI 工具': ToolCategory.objects.get_or_create(
name='AI 工具',
defaults={'icon': 'ThunderboltOutlined', 'sort_order': 0}
)[0],
}
tools_data = [
@@ -38,6 +42,8 @@ class Command(BaseCommand):
{'name': '取色器', 'description': '颜色拾取、HEX/RGB/HSL转换、历史记录', 'icon': 'PictureOutlined', 'url_path': '/color-picker', 'category': categories['设计'], 'color': '#eab308', 'usage_count': 4280},
{'name': '字符编码转换', 'description': 'GBK/UTF-8/Big5/Shift_JIS 等字符集互转,支持文件上传下载', 'icon': 'CodeOutlined', 'url_path': '/utility/charset-converter', 'category': categories['开发'], 'color': '#1677ff', 'usage_count': 3650},
{'name': '图片编辑', 'description': '在线图片编辑,支持裁剪、滤镜、调节、文字、画笔', 'icon': 'EditOutlined', 'url_path': '/utility/image-editor', 'category': categories['设计'], 'color': '#f59e0b', 'usage_count': 3456},
{'name': 'AI 图片放大', 'description': 'AI 图片放大 2x/4x(2 积分/次,失败退回)', 'icon': 'ExpandOutlined', 'url_path': '/utility/image-upscaler', 'category': categories['AI 工具'], 'color': '#8b5cf6', 'usage_count': 0, 'is_new': True},
{'name': '代码在线运行', 'description': 'JS/Python 沙箱在线运行(学练一体)', 'icon': 'CodeOutlined', 'url_path': '/utility/code-runner', 'category': categories['开发'], 'color': '#6366f1', 'usage_count': 0, 'is_new': True},
]
created_count = 0