/** 头像 PNG 加 agent- 前缀,避免和图标同名(cloud.png 撞车导致 rspack 报冲突)。 */ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const repo = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); const dir = path.join(repo, 'app', 'src', 'assets', 'avatars-png'); for (const file of fs.readdirSync(dir)) { if (!file.endsWith('.png') || file.startsWith('agent-')) continue; fs.renameSync(path.join(dir, file), path.join(dir, `agent-${file}`)); } const iconFile = path.join(repo, 'app', 'src', 'Icon.tsx'); let src = fs.readFileSync(iconFile, 'utf8'); src = src.replace(/\.\/assets\/avatars-png\/([a-z0-9-]+)\.png/g, './assets/avatars-png/agent-$1.png'); fs.writeFileSync(iconFile, src, 'utf8'); console.log('头像文件:', fs.readdirSync(dir).join(', ')); console.log('Icon.tsx 里的头像引用:'); for (const line of src.split('\n')) { if (line.includes('avatars-png')) console.log(' ', line.trim()); }