feat: SodiumPet 小钠桌宠 v0.1.0(Live2D 桌宠 / 经济任务 / 音乐 / 成就 / 编辑器 / MOD)
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
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')
|
||||
}
|
||||
|
||||
patch('editor/Editor.tsx', [
|
||||
[
|
||||
`import {
|
||||
CATEGORY_COLORS,
|
||||
ELEMENT_CATEGORY_LABEL,
|
||||
DEFAULT_PERIODIC_STYLE,
|
||||
elementName,
|
||||
MAX_LEVEL,
|
||||
type PeriodicStyle
|
||||
} from '../../../shared/elements'`,
|
||||
`import {
|
||||
CATEGORY_COLORS,
|
||||
ELEMENT_CATEGORY_LABEL,
|
||||
DEFAULT_PERIODIC_STYLE,
|
||||
ELEMENT_GRID_POS,
|
||||
ELEMENTS,
|
||||
elementName,
|
||||
MAX_LEVEL,
|
||||
periodicCellColor,
|
||||
PERIODIC_PRESETS,
|
||||
type PeriodicStyle
|
||||
} from '../../../shared/elements'`
|
||||
],
|
||||
// 选中值计算
|
||||
[
|
||||
` <select
|
||||
className="text-input"
|
||||
value={customDirty ? '__custom' : periodic.scheme + (periodic.colors ? ':' + JSON.stringify(periodic.colors) : '')}`,
|
||||
` <select
|
||||
className="text-input"
|
||||
value={
|
||||
customDirty
|
||||
? '__custom'
|
||||
: PERIODIC_PRESETS.find(
|
||||
(ps) =>
|
||||
ps.scheme === periodic.scheme &&
|
||||
JSON.stringify(ps.colors) === JSON.stringify(periodic.colors ?? {})
|
||||
)?.id ?? '__custom'
|
||||
}`
|
||||
],
|
||||
[
|
||||
` {customDirty && <option value="__custom">自定义(未保存)</option>}`,
|
||||
` <option value="__custom">自定义{ customDirty ? '(未保存)' : ''}</option>`
|
||||
]
|
||||
])
|
||||
|
||||
// 详情页:当前为自定义配色时给个提示
|
||||
patch('detail/Detail.tsx', [
|
||||
[
|
||||
` <div className="periodic-presets">`,
|
||||
` <div className="periodic-presets">
|
||||
{!PERIODIC_PRESETS.some(
|
||||
(ps) =>
|
||||
ps.scheme === periodic.scheme &&
|
||||
JSON.stringify(ps.colors) === JSON.stringify(periodic.colors ?? {})
|
||||
) &&
|
||||
customPresets.every(
|
||||
(ps) =>
|
||||
ps.scheme !== periodic.scheme ||
|
||||
JSON.stringify(ps.colors) !== JSON.stringify(periodic.colors ?? {})
|
||||
) && <span className="preset-custom-tag">当前:自定义</span>}`
|
||||
]
|
||||
])
|
||||
|
||||
// 编辑器周期表网格样式
|
||||
{
|
||||
const p = base + 'editor/editor.css'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
c += `
|
||||
|
||||
.periodic-editor {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(18, 1fr);
|
||||
grid-auto-rows: 22px;
|
||||
gap: 2px;
|
||||
padding: 6px;
|
||||
border: 1px solid #1d2637;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.ped-cell {
|
||||
position: relative;
|
||||
border-radius: 3px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
color: #0d1017;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.ped-cell.on {
|
||||
outline: 2px solid #ffffff;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.ped-color {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ped-z {
|
||||
font-size: 6.5px;
|
||||
opacity: 0.75;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ped-sym {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ped-pick {
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
top: 1px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #0d1017;
|
||||
opacity: 0.55;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ped-pick:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.preset-custom-tag {
|
||||
font-size: 12px;
|
||||
color: #8b98ad;
|
||||
padding: 4px 8px;
|
||||
border: 1px dashed #2b3648;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
[data-theme='day'] .periodic-editor {
|
||||
border-color: #cfd8e6;
|
||||
}
|
||||
|
||||
[data-theme='day'] .preset-custom-tag {
|
||||
border-color: #cfd8e6;
|
||||
color: #55627a;
|
||||
}
|
||||
`
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
}
|
||||
|
||||
console.log('editor grid imports + custom tag patched')
|
||||
Reference in New Issue
Block a user