Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
64
frontend_大健康/change_avatars_again.py
Normal file
64
frontend_大健康/change_avatars_again.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import random
|
||||
|
||||
# 读取头像列表
|
||||
with open('网页未导入数据/头像列表.json', 'r', encoding='utf-8') as f:
|
||||
avatar_list = json.load(f)
|
||||
|
||||
# 选择不同的头像(选择索引 30, 35, 40 的头像)
|
||||
selected_indices = [30, 35, 40]
|
||||
selected_avatars = []
|
||||
|
||||
for idx in selected_indices:
|
||||
if idx < len(avatar_list):
|
||||
url = avatar_list[idx]["file_url"].split("?")[0]
|
||||
selected_avatars.append(url)
|
||||
else:
|
||||
# 如果索引超出范围,从前面选择
|
||||
fallback_idx = idx % len(avatar_list)
|
||||
url = avatar_list[fallback_idx]["file_url"].split("?")[0]
|
||||
selected_avatars.append(url)
|
||||
|
||||
print(f"选择的新头像:")
|
||||
for i, url in enumerate(selected_avatars, 1):
|
||||
filename = url.split('/')[-1]
|
||||
print(f"第{i}名: {filename}")
|
||||
|
||||
# 读取mockData.js
|
||||
with open('src/data/mockData.js', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 更新前三名学生的头像
|
||||
updates = [
|
||||
{
|
||||
"name": "于语涵",
|
||||
"old_avatar": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/avatar/douyin/358c35e22ece94b548637c0e90c4ce0c.jpg",
|
||||
"new_avatar": selected_avatars[0]
|
||||
},
|
||||
{
|
||||
"name": "陈沐谦",
|
||||
"old_avatar": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/avatar/douyin/54bf2cbc6433120fd99d7d85b7c70f3a.jpg",
|
||||
"new_avatar": selected_avatars[1]
|
||||
},
|
||||
{
|
||||
"name": "魏思涵",
|
||||
"old_avatar": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/avatar/douyin/70a5030e91c730db9c2edbe8b6ca7bad.jpg",
|
||||
"new_avatar": selected_avatars[2]
|
||||
}
|
||||
]
|
||||
|
||||
# 替换头像URL
|
||||
for update in updates:
|
||||
old_count = content.count(update["old_avatar"])
|
||||
content = content.replace(update["old_avatar"], update["new_avatar"])
|
||||
new_count = content.count(update["new_avatar"])
|
||||
print(f"✓ 更新 {update['name']} 的头像 (替换了 {old_count} 处)")
|
||||
|
||||
# 写回文件
|
||||
with open('src/data/mockData.js', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("\n✅ 成功更换前三名学生的头像!")
|
||||
Reference in New Issue
Block a user