feat: SodiumPet 小钠桌宠 v0.1.0(Live2D 桌宠 / 经济任务 / 音乐 / 成就 / 编辑器 / MOD)
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
const fs = require('fs')
|
||||
const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/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')
|
||||
}
|
||||
|
||||
// ---------- 1) 内置配色预设
|
||||
{
|
||||
const p = base + 'shared/elements.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
c += `
|
||||
|
||||
export interface PeriodicPreset {
|
||||
id: string
|
||||
name: string
|
||||
scheme: PeriodicScheme
|
||||
colors: Record<string, string>
|
||||
}
|
||||
|
||||
const SOFT_CATEGORY: Record<string, string> = {
|
||||
alkali: '#ffc9b3',
|
||||
alkaline: '#ffe3a3',
|
||||
transition: '#d9f2e6',
|
||||
postmetal: '#cfe7ff',
|
||||
metalloid: '#e2f0c4',
|
||||
nonmetal: '#d3f0dd',
|
||||
halogen: '#ffe3bd',
|
||||
noble: '#ead9ff',
|
||||
lanthanide: '#ffd6e6',
|
||||
actinide: '#f9d2d2'
|
||||
}
|
||||
|
||||
export const PERIODIC_PRESETS: PeriodicPreset[] = [
|
||||
{
|
||||
id: 'spdf',
|
||||
name: '能级块 · 标准',
|
||||
scheme: 'block',
|
||||
colors: { s: '#ffd54a', p: '#6fc8ff', d: '#8ef0b0', f: '#cf9bff' }
|
||||
},
|
||||
{
|
||||
id: 'spdf-soft',
|
||||
name: '能级块 · 柔和',
|
||||
scheme: 'block',
|
||||
colors: { s: '#ffe9a8', p: '#bfe4ff', d: '#cdf3dd', f: '#e6cbff' }
|
||||
},
|
||||
{
|
||||
id: 'category',
|
||||
name: '元素分类 · 标准',
|
||||
scheme: 'category',
|
||||
colors: { ...CATEGORY_COLORS }
|
||||
},
|
||||
{
|
||||
id: 'category-soft',
|
||||
name: '元素分类 · 柔和',
|
||||
scheme: 'category',
|
||||
colors: SOFT_CATEGORY
|
||||
}
|
||||
]
|
||||
`
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
}
|
||||
|
||||
// ---------- 2) 详情页:预设按钮
|
||||
patch('renderer/src/detail/Detail.tsx', [
|
||||
[
|
||||
" periodicCellColor,\n type PeriodicStyle\n} from '../../../shared/elements'",
|
||||
" periodicCellColor,\n PERIODIC_PRESETS,\n type PeriodicPreset,\n type PeriodicStyle\n} from '../../../shared/elements'"
|
||||
],
|
||||
[
|
||||
" const [periodic, setPeriodic] = useState<PeriodicStyle>(DEFAULT_PERIODIC_STYLE)",
|
||||
" const [periodic, setPeriodic] = useState<PeriodicStyle>(DEFAULT_PERIODIC_STYLE)\n const [customPresets, setCustomPresets] = useState<PeriodicPreset[]>([])"
|
||||
],
|
||||
[
|
||||
` setPeriodic(
|
||||
((cat as { periodic?: PeriodicStyle }).periodic ?? DEFAULT_PERIODIC_STYLE) as PeriodicStyle
|
||||
)`,
|
||||
` const catPeriodic = (cat as { periodic?: PeriodicStyle & { presets?: PeriodicPreset[] } })
|
||||
.periodic
|
||||
setPeriodic((catPeriodic ?? DEFAULT_PERIODIC_STYLE) as PeriodicStyle)
|
||||
setCustomPresets(catPeriodic?.presets ?? [])`
|
||||
],
|
||||
// 顶部预设按钮(放在切换化学/普通之后)
|
||||
[
|
||||
` <div className="level-mode">`,
|
||||
` <div className="periodic-presets">
|
||||
{[...PERIODIC_PRESETS, ...customPresets].map((ps) => (
|
||||
<button
|
||||
key={ps.id}
|
||||
className={
|
||||
'set-tab' +
|
||||
(periodic.scheme === ps.scheme &&
|
||||
JSON.stringify(periodic.colors ?? {}) === JSON.stringify(ps.colors)
|
||||
? ' on'
|
||||
: '')
|
||||
}
|
||||
onClick={() =>
|
||||
setPeriodic({ ...periodic, scheme: ps.scheme, colors: { ...ps.colors } })
|
||||
}
|
||||
>
|
||||
{ps.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="level-mode">`
|
||||
]
|
||||
])
|
||||
|
||||
console.log('periodic presets patched')
|
||||
Reference in New Issue
Block a user