const fs = require('fs') const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/renderer/src/' function patch(file, pairs) { const p = base + file let c = fs.readFileSync(p, 'utf8') for (const [from, to] of pairs) { if (!c.includes(from)) { console.log('MISS in', file, '::', from.slice(0, 70).replace(/\n/g, '\\n')) continue } c = c.replace(from, to) } fs.writeFileSync(p, c, 'utf8') } // ---- Detail:使用配色方案 patch('detail/Detail.tsx', [ [ "import { ELEMENTS, elementName, levelLabelWrapped, MAX_LEVEL } from '../../../shared/elements'", "import {\n CATEGORY_COLORS,\n CATEGORY_LABEL,\n DEFAULT_PERIODIC_STYLE,\n ELEMENTS,\n elementName,\n levelLabelWrapped,\n MAX_LEVEL,\n periodicCellColor,\n type PeriodicStyle\n} from '../../../shared/elements'" ], [ " const [lvMode, setLvMode] = useState<'auto' | 'chemistry' | 'normal'>('auto')", " const [lvMode, setLvMode] = useState<'auto' | 'chemistry' | 'normal'>('auto')\n const [periodic, setPeriodic] = useState(DEFAULT_PERIODIC_STYLE)" ], [ ` void a?.getCatalog().then((cat) => { try { setLevels(((cat as { levels?: CatalogLevels }).levels ?? {}) as CatalogLevels) } catch { setLevels({}) } })`, ` void a?.getCatalog().then((cat) => { try { setLevels(((cat as { levels?: CatalogLevels }).levels ?? {}) as CatalogLevels) setPeriodic( ((cat as { periodic?: PeriodicStyle }).periodic ?? DEFAULT_PERIODIC_STYLE) as PeriodicStyle ) } catch { setLevels({}) } })` ], [ `
`, `
` ], [ ` style={{ gridRow: row, gridColumn: col, background: el.color }}`, ` style={{ gridRow: row, gridColumn: col, background: periodicCellColor(el, periodic) }}` ], // 图例 [ `
`, `
{periodic.scheme === 'category' ? (Object.keys(CATEGORY_LABEL) as Array).map((k) => ( {CATEGORY_LABEL[k]} )) : (['s', 'p', 'd', 'f'] as const).map((b) => ( )[b] }} /> {b} 区 ))}
` ] ]) // ---- Editor:周期表配色编辑(等级页底部) patch('editor/Editor.tsx', [ [ "import { elementName, MAX_LEVEL } from '../../../shared/elements'", "import {\n CATEGORY_COLORS,\n CATEGORY_LABEL,\n DEFAULT_PERIODIC_STYLE,\n elementName,\n MAX_LEVEL,\n type PeriodicStyle\n} from '../../../shared/elements'" ], [ " const [lvDraft, setLvDraft] = useState<{ desc: string; icon: string }>({ desc: '', icon: '' })", " const [lvDraft, setLvDraft] = useState<{ desc: string; icon: string }>({ desc: '', icon: '' })\n const [periodic, setPeriodic] = useState(DEFAULT_PERIODIC_STYLE)" ], [ " setLevelsMeta(((c as { levels?: CatalogLevels }).levels ?? {}) as CatalogLevels)", " setLevelsMeta(((c as { levels?: CatalogLevels }).levels ?? {}) as CatalogLevels)\n setPeriodic(\n ((c as { periodic?: PeriodicStyle }).periodic ?? DEFAULT_PERIODIC_STYLE) as PeriodicStyle\n )" ], // 周期表配置块(放在等级表单之后,仍属于等级页) [ `

等级描述会显示在「详细 → 等级预览」里;化学等级还能用元素名做提示。

`, `

等级描述会显示在「详细 → 等级预览」里;化学等级还能用元素名做提示。

周期表配色
配色方案
{(periodic.scheme === 'category' ? (Object.keys(CATEGORY_LABEL) as Array).map((k) => ({ key: k as string, label: CATEGORY_LABEL[k], fallback: CATEGORY_COLORS[k] })) : (['s', 'p', 'd', 'f'] as const).map((b) => ({ key: b as string, label: b + ' 区', fallback: ({ s: '#ffd54a', p: '#6fc8ff', d: '#8ef0b0', f: '#cf9bff' } as Record< string, string >)[b] })) ).map((row) => ( ))}
底图背景 setPeriodic({ ...periodic, bg: e.target.value })} />
` ] ]) console.log('periodic wiring patched')