37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
const fs = require('fs')
|
|
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/renderer/src/detail/Detail.tsx'
|
|
let c = fs.readFileSync(p, 'utf8')
|
|
|
|
const startMark = ' <div className="periodic-legend">'
|
|
const start = c.indexOf(startMark)
|
|
if (start < 0) {
|
|
console.log('legend not found')
|
|
process.exit(1)
|
|
}
|
|
const end = c.indexOf(' </div>', start)
|
|
if (end < 0) {
|
|
console.log('legend end not found')
|
|
process.exit(1)
|
|
}
|
|
const oldBlock = c.slice(start, end + ' </div>'.length)
|
|
|
|
const newBlock = [
|
|
' <div className="periodic-legend">',
|
|
' {periodicZoneList(periodic).map((z) => (',
|
|
' <span key={z.id} className="legend-item">',
|
|
' <i style={{ background: z.color }} />',
|
|
' {z.label}',
|
|
' </span>',
|
|
' ))}',
|
|
' </div>'
|
|
].join('\n')
|
|
|
|
c = c.replace(oldBlock, newBlock)
|
|
if (!c.includes('periodicZoneList(periodic)')) {
|
|
console.log('replace failed')
|
|
process.exit(1)
|
|
}
|
|
c = c.replace(' periodicCellColor,', ' periodicCellColor,\n periodicZoneList,')
|
|
fs.writeFileSync(p, c, 'utf8')
|
|
console.log('detail legend patched')
|