sync from local backup

This commit is contained in:
chunyu
2026-08-05 23:59:15 +08:00
commit d48ec1747c
358 changed files with 34384 additions and 0 deletions
View File
@@ -0,0 +1,60 @@
from django.core.management.base import BaseCommand
from apidirectory.models import ApiCategory, ApiItem
class Command(BaseCommand):
help = '填充API接口大全的初始数据'
def handle(self, *args, **options):
# 清空现有数据
ApiItem.objects.all().delete()
ApiCategory.objects.all().delete()
# 创建分类
categories_data = [
{'name': '基础工具', 'icon': 'ToolOutlined', 'sort_order': 1},
{'name': '数据查询', 'icon': 'SearchOutlined', 'sort_order': 2},
{'name': '内容生成', 'icon': 'FileTextOutlined', 'sort_order': 3},
{'name': '生活服务', 'icon': 'HomeOutlined', 'sort_order': 4},
{'name': '开发工具', 'icon': 'CodeOutlined', 'sort_order': 5},
]
categories = {}
for cat_data in categories_data:
cat = ApiCategory.objects.create(**cat_data)
categories[cat_data['name']] = cat
self.stdout.write(f'创建分类: {cat.name}')
# 创建API项目
items_data = [
# 基础工具
{'name': 'IP地址查询', 'description': '根据IP地址获取地理位置信息', 'url_path': '/api/getIpData/', 'method': 'GET', 'category': '基础工具', 'icon': 'GlobalOutlined', 'color': '#667eea'},
{'name': '二维码生成', 'description': '将文本或URL转换为二维码图片', 'url_path': '/api/qrcode-generator/', 'method': 'POST', 'category': '基础工具', 'icon': 'QrcodeOutlined', 'color': '#10b981'},
{'name': '短链接生成', 'description': '将长URL转换为短链接', 'url_path': '/api/shorturl/shorten/', 'method': 'POST', 'category': '基础工具', 'icon': 'LinkOutlined', 'color': '#f59e0b'},
{'name': '密码生成器', 'description': '生成随机安全密码', 'url_path': '/api/password-generator/', 'method': 'GET', 'category': '基础工具', 'icon': 'LockOutlined', 'is_coming_soon': True},
# 数据查询
{'name': '天气查询', 'description': '查询全球各地实时天气信息', 'url_path': '/api/weather', 'method': 'GET', 'category': '数据查询', 'icon': 'CloudOutlined', 'color': '#3b82f6'},
{'name': '空气质量', 'description': '查询城市空气质量指数AQI', 'url_path': '/api/air-quality/', 'method': 'GET', 'category': '数据查询', 'icon': 'DashboardOutlined', 'color': '#10b981'},
# 内容生成
{'name': '百度翻译', 'description': '支持多种语言的互译服务', 'url_path': '/api/baiduFanyi/', 'method': 'POST', 'category': '内容生成', 'icon': 'TranslationOutlined', 'color': '#667eea', 'is_new': True},
{'name': 'OCR文字识别', 'description': '从图片中识别文字内容', 'url_path': '/api/baiduFanyi/pictureRecognize/', 'method': 'POST', 'category': '内容生成', 'icon': 'ScanOutlined', 'color': '#8b5cf6', 'is_coming_soon': True},
{'name': '语音识别', 'description': '将语音转换为文字', 'url_path': '/api/baiduFanyi/speechRecognition/', 'method': 'POST', 'category': '内容生成', 'icon': 'AudioOutlined', 'color': '#ec4899', 'is_coming_soon': True},
# 生活服务
{'name': '滑块验证码', 'description': '滑块验证码生成与验证', 'url_path': '/api/captcha/', 'method': 'GET', 'category': '生活服务', 'icon': 'SafetyOutlined', 'color': '#10b981'},
{'name': '图片验证码', 'description': '图片验证码生成与识别', 'url_path': '/api/image-captcha/', 'method': 'GET', 'category': '生活服务', 'icon': 'SafetyOutlined', 'color': '#3b82f6'},
{'name': 'TODO待办', 'description': '管理个人待办事项', 'url_path': '/api/todo/', 'method': 'GET', 'category': '生活服务', 'icon': 'CheckSquareOutlined', 'is_coming_soon': True},
]
for item_data in items_data:
cat_name = item_data.pop('category')
item_data['category'] = categories[cat_name]
item = ApiItem.objects.create(**item_data)
self.stdout.write(f'创建API: {item.name} ({item.method} {item.url_path})')
self.stdout.write(self.style.SUCCESS(
f'\n成功创建 {ApiCategory.objects.count()} 个分类, '
f'{ApiItem.objects.count()} 个API接口'
))
@@ -0,0 +1,119 @@
from django.core.management.base import BaseCommand
from apidirectory.models import ApiCategory, ApiItem
class Command(BaseCommand):
help = 'Seed API directory with initial data'
def handle(self, *args, **options):
self.stdout.write('Seeding API directory...')
categories_data = [
{'name': '数据查询', 'icon': 'SearchOutlined', 'sort_order': 1},
{'name': '位置服务', 'icon': 'EnvironmentOutlined', 'sort_order': 2},
{'name': '金融货币', 'icon': 'DollarOutlined', 'sort_order': 3},
{'name': '工具服务', 'icon': 'ToolOutlined', 'sort_order': 4},
{'name': '翻译服务', 'icon': 'TranslationOutlined', 'sort_order': 5},
]
categories = {}
for cat_data in categories_data:
cat, created = ApiCategory.objects.get_or_create(
name=cat_data['name'],
defaults=cat_data
)
categories[cat_data['name']] = cat
if created:
self.stdout.write(f' Created category: {cat.name}')
items_data = [
{
'name': '天气查询',
'description': '根据城市名称查询实时天气信息,支持全球城市和多种温度单位',
'url_path': '/api/weather',
'method': 'GET',
'category': '数据查询',
'is_new': True,
'color': '#10b981',
'image_url': 'https://images.unsplash.com/photo-1504608524841-42fe6f032b4b?w=800&h=600&fit=crop',
},
{
'name': '空气质量指数',
'description': '查询指定城市的空气质量指数AQI、PM2.5、PM10等环境数据',
'url_path': '/api/air-quality/',
'method': 'GET',
'category': '数据查询',
'is_new': True,
'color': '#3b82f6',
'image_url': 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800&h=600&fit=crop',
},
{
'name': 'IP地址定位',
'description': '根据IP地址获取地理位置信息,支持自动识别客户端IP',
'url_path': '/api/getIpData/',
'method': 'GET',
'category': '位置服务',
'color': '#8b5cf6',
'image_url': 'https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=800&h=600&fit=crop',
},
{
'name': '二维码生成',
'description': '根据URL或文本生成二维码图片',
'url_path': '/api/qrcode-generator/',
'method': 'POST',
'category': '工具服务',
'color': '#ec4899',
'image_url': 'https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?w=800&h=600&fit=crop',
},
{
'name': '百度翻译',
'description': '支持200+语言互译,自动检测源语言',
'url_path': '/api/baiduFanyi/',
'method': 'POST',
'category': '翻译服务',
'color': '#06b6d4',
'is_enabled': True,
'image_url': 'https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?w=800&h=600&fit=crop',
},
{
'name': '文本比较',
'description': '比较两段文本的差异,支持多种比较模式',
'url_path': '/api/tool/text-diff/',
'method': 'POST',
'category': '工具服务',
'color': '#14b8a6',
'image_url': 'https://images.unsplash.com/photo-1518770660439-4636190af475?w=800&h=600&fit=crop',
},
{
'name': '图片压缩',
'description': '在线压缩图片,支持批量处理和质量调节',
'url_path': '/api/tool/image-compressor',
'method': 'POST',
'category': '工具服务',
'color': '#84cc16',
'image_url': 'https://images.unsplash.com/photo-1542038784456-1ea8e935640e?w=800&h=600&fit=crop',
},
{
'name': '短链接生成',
'description': '将长链接转换为短链接,支持自定义后缀',
'url_path': '/api/shorturl/shorten/',
'method': 'POST',
'category': '工具服务',
'color': '#f97316',
'image_url': 'https://images.unsplash.com/photo-1557682172-298e090bd0f1?w=800&h=600&fit=crop',
},
]
for item_data in items_data:
cat_name = item_data.pop('category')
item_data['category'] = categories[cat_name]
item, created = ApiItem.objects.update_or_create(
url_path=item_data['url_path'],
defaults=item_data
)
if created:
self.stdout.write(f' Created item: {item.name} ({item.url_path})')
else:
self.stdout.write(f' Updated item: {item.name} ({item.url_path})')
self.stdout.write(self.style.SUCCESS('API directory seeded successfully!'))