Files
SodiumPet/tools/patch-p33-a.cjs
T

123 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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) 修 Panel 缺 import(互动面板崩溃的根因)
patch('renderer/src/panel/Panel.tsx', [
[
` ITEMS,
JOBS,
STAT_META,`,
` ITEMS,
JOBS,
STAT_META,
jobMaxMult,`
]
])
// 2) Detail 窗口日间配色:选择器改成 day,补 html/body 与按钮
{
const p = base + 'renderer/src/detail/detail.css'
let c = fs.readFileSync(p, 'utf8')
c = c.replaceAll("[data-theme='light']", "[data-theme='day']")
c += `
[data-theme='day'] html,
[data-theme='day'] body,
[data-theme='day'] #root {
background: #eef2f8;
}
[data-theme='day'] .detail-head,
[data-theme='day'] .detail-title {
color: #1b2434;
}
[data-theme='day'] .icon-btn {
color: #55627a;
}
[data-theme='day'] .icon-btn:hover {
color: #1b2434;
}
[data-theme='day'] .summary-value {
color: #1e88c7;
}
[data-theme='day'] .birthday-date {
color: #b8860b;
}
[data-theme='day'] .stat-num.on {
color: #1e88c7;
}
[data-theme='day'] .empty {
color: #6b7890;
}
`
fs.writeFileSync(p, c, 'utf8')
}
// 3) Detail 统计总结:改为每个任务各自的倍率
patch('renderer/src/detail/Detail.tsx', [
[
"import { ITEMS, JOBS, expProgress, rewardMultiplier, levelOf } from '../../../shared/petState'",
"import { ITEMS, JOBS, expProgress, jobMaxMult, levelOf } from '../../../shared/petState'"
],
[
` const mult = rewardMultiplier(level)`,
``
],
[
` <div className="summary-cell">
<span className="summary-label">任务倍率</span>
<span className="summary-value">×{mult.toFixed(2)}</span>
</div>`,
``
],
// 每任务倍率表(追加在 summary-grid 之后)
[
` </>
)}
{tab === 'birthday' && (`,
` <div className="section-title" style={{ marginTop: 12 }}>
各任务当前倍率
</div>
<div className="stat-table">
{JOBS.map((j) => {
const locked = level < j.level
const m = jobMaxMult(j.level, level)
return (
<div className="stat-row" key={j.id}>
<span>
{jobName(j.id)}
{locked ? '(需 Lv.' + j.level + ')' : ''}
</span>
<span className={locked ? 'stat-num' : 'stat-num on'}>×{locked ? 0 : m}</span>
</div>
)
})}
</div>
</>
)}
{tab === 'birthday' && (`
]
])
console.log('interact crash + detail theme + per-job mult patched')