175 lines
5.2 KiB
Python
175 lines
5.2 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
"""
|
|||
|
|
检查礼物图片文件
|
|||
|
|
"""
|
|||
|
|
from pathlib import Path
|
|||
|
|
|
|||
|
|
# 图片源目录
|
|||
|
|
SOURCE_DIR = Path('开发/2026年2月4日/Gift')
|
|||
|
|
|
|||
|
|
# SQL 中定义的礼物列表
|
|||
|
|
SQL_GIFTS = {
|
|||
|
|
# 经济类礼物(10-50金币)
|
|||
|
|
"玫瑰花": "rose.png",
|
|||
|
|
"棒棒糖": "lollipop.png",
|
|||
|
|
"咖啡": "coffee.png",
|
|||
|
|
"冰淇淋": "icecream.png",
|
|||
|
|
"小蛋糕": "cake.png",
|
|||
|
|
"巧克力": "chocolate.png",
|
|||
|
|
"奶茶": "milktea.png",
|
|||
|
|
"小星星": "star.png",
|
|||
|
|
"爱心气球": "heart_balloon.png",
|
|||
|
|
"小礼物盒": "gift_box.png",
|
|||
|
|
"彩虹": "rainbow.png",
|
|||
|
|
|
|||
|
|
# 中档礼物(50-200金币)
|
|||
|
|
"香槟": "champagne.png",
|
|||
|
|
"钻石": "diamond.png",
|
|||
|
|
"王冠": "crown.png",
|
|||
|
|
"爱心": "big_heart.png",
|
|||
|
|
"月亮": "moon.png",
|
|||
|
|
"烟花": "fireworks.png",
|
|||
|
|
"水晶球": "crystal_ball.png",
|
|||
|
|
"玫瑰花束": "rose_bouquet.png",
|
|||
|
|
"星星项链": "star_necklace.png",
|
|||
|
|
|
|||
|
|
# 高级礼物(200-500金币)
|
|||
|
|
"跑车": "sports_car.png",
|
|||
|
|
"飞机": "airplane.png",
|
|||
|
|
"游艇": "yacht.png",
|
|||
|
|
"城堡": "castle.png",
|
|||
|
|
|
|||
|
|
# 特殊礼物(500+金币)
|
|||
|
|
"宇宙飞船": "spaceship.png",
|
|||
|
|
"时光机": "time_machine.png",
|
|||
|
|
"魔法棒": "magic_wand.png",
|
|||
|
|
"永恒之心": "eternal_heart.png",
|
|||
|
|
|
|||
|
|
# 节日限定礼物
|
|||
|
|
"圣诞树": "christmas_tree.png",
|
|||
|
|
"情人节巧克力": "valentine_chocolate.png",
|
|||
|
|
"生日蛋糕": "birthday_cake.png",
|
|||
|
|
"万圣节南瓜": "halloween_pumpkin.png",
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 实际图片文件名映射
|
|||
|
|
ACTUAL_FILES = {
|
|||
|
|
"玫瑰花.png": "rose.png",
|
|||
|
|
"棒棒糖.png": "lollipop.png",
|
|||
|
|
"咖啡.png": "coffee.png",
|
|||
|
|
"冰淇淋.png": "icecream.png",
|
|||
|
|
"小蛋糕.png": "cake.png",
|
|||
|
|
"巧克力.png": "chocolate.png",
|
|||
|
|
"奶茶.png": "milktea.png",
|
|||
|
|
"爱心气球.png": "heart_balloon.png",
|
|||
|
|
"小礼物盒.png": "gift_box.png",
|
|||
|
|
"彩虹.png": "rainbow.png",
|
|||
|
|
"香槟.png": "champagne.png",
|
|||
|
|
"钻石.png": "diamond.png",
|
|||
|
|
"王冠.png": "crown.png",
|
|||
|
|
"爱心.png": "big_heart.png",
|
|||
|
|
"月亮.png": "moon.png",
|
|||
|
|
"烟花.png": "fireworks.png",
|
|||
|
|
"水晶球.png": "crystal_ball.png",
|
|||
|
|
"玫瑰花束.png": "rose_bouquet.png",
|
|||
|
|
"星星项链.png": "star_necklace.png",
|
|||
|
|
"跑车.png": "sports_car.png",
|
|||
|
|
"飞机.png": "airplane.png",
|
|||
|
|
"游艇.png": "yacht.png",
|
|||
|
|
"城堡.png": "castle.png",
|
|||
|
|
"宇宙飞船.png": "spaceship.png",
|
|||
|
|
"魔法棒.png": "magic_wand.png",
|
|||
|
|
"圣诞树.png": "christmas_tree.png",
|
|||
|
|
"情人节巧克力.png": "valentine_chocolate.png",
|
|||
|
|
"生日蛋糕.png": "birthday_cake.png",
|
|||
|
|
"万圣节南瓜.png": "halloween_pumpkin.png",
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
def check_gifts():
|
|||
|
|
"""检查礼物图片"""
|
|||
|
|
print("=" * 70)
|
|||
|
|
print(" 礼物图片文件检查")
|
|||
|
|
print("=" * 70)
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
if not SOURCE_DIR.exists():
|
|||
|
|
print(f"❌ 错误:源目录不存在: {SOURCE_DIR}")
|
|||
|
|
return
|
|||
|
|
|
|||
|
|
# 获取所有 PNG 文件
|
|||
|
|
all_files = list(SOURCE_DIR.glob("*.png"))
|
|||
|
|
print(f"📁 源目录: {SOURCE_DIR}")
|
|||
|
|
print(f"📊 找到 {len(all_files)} 个 PNG 文件")
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
# 检查每个礼物
|
|||
|
|
print("=" * 70)
|
|||
|
|
print(" 检查礼物图片")
|
|||
|
|
print("=" * 70)
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
existing_gifts = []
|
|||
|
|
missing_gifts = []
|
|||
|
|
|
|||
|
|
for gift_name, target_filename in SQL_GIFTS.items():
|
|||
|
|
# 查找对应的实际文件
|
|||
|
|
found = False
|
|||
|
|
for actual_file, target_file in ACTUAL_FILES.items():
|
|||
|
|
if target_file == target_filename:
|
|||
|
|
file_path = SOURCE_DIR / actual_file
|
|||
|
|
if file_path.exists():
|
|||
|
|
size = file_path.stat().st_size / 1024
|
|||
|
|
print(f"✓ {gift_name}")
|
|||
|
|
print(f" 文件: {actual_file} → {target_filename}")
|
|||
|
|
print(f" 大小: {size:.1f} KB")
|
|||
|
|
print()
|
|||
|
|
existing_gifts.append((gift_name, actual_file, target_filename))
|
|||
|
|
found = True
|
|||
|
|
break
|
|||
|
|
|
|||
|
|
if not found:
|
|||
|
|
print(f"✗ {gift_name}")
|
|||
|
|
print(f" 目标: {target_filename}")
|
|||
|
|
print(f" 状态: 缺失")
|
|||
|
|
print()
|
|||
|
|
missing_gifts.append((gift_name, target_filename))
|
|||
|
|
|
|||
|
|
# 统计结果
|
|||
|
|
print("=" * 70)
|
|||
|
|
print(" 统计结果")
|
|||
|
|
print("=" * 70)
|
|||
|
|
print()
|
|||
|
|
print(f"SQL 中定义: {len(SQL_GIFTS)} 个礼物")
|
|||
|
|
print(f"存在图片: {len(existing_gifts)} 个")
|
|||
|
|
print(f"缺失图片: {len(missing_gifts)} 个")
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
if missing_gifts:
|
|||
|
|
print("=" * 70)
|
|||
|
|
print(" 缺失的礼物")
|
|||
|
|
print("=" * 70)
|
|||
|
|
print()
|
|||
|
|
for gift_name, target_filename in missing_gifts:
|
|||
|
|
print(f"- {gift_name} ({target_filename})")
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
if existing_gifts:
|
|||
|
|
print("=" * 70)
|
|||
|
|
print(" 建议")
|
|||
|
|
print("=" * 70)
|
|||
|
|
print()
|
|||
|
|
print(f"✓ 有 {len(existing_gifts)} 个礼物有图片")
|
|||
|
|
print(f"✗ 有 {len(missing_gifts)} 个礼物缺少图片")
|
|||
|
|
print()
|
|||
|
|
print("建议:")
|
|||
|
|
print("1. 创建只包含现有图片的 SQL 文件")
|
|||
|
|
print("2. 上传图片到 OSS")
|
|||
|
|
print("3. 导入数据库")
|
|||
|
|
print()
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
check_gifts()
|