feat: SodiumPet 小钠桌宠 v0.1.0(Live2D 桌宠 / 经济任务 / 音乐 / 成就 / 编辑器 / MOD)

This commit is contained in:
Tian_XiaRi
2026-12-01 16:41:07 +08:00
commit d25e726ef7
261 changed files with 33676 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
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')
}
// 0) 配置:工具栏图标映射
patch('shared/petState.ts', [
[
` /** 歌词浮窗:底色 / 文字色 / 描边色 / 字号 */
lyricBg: string`,
` /** 底栏图标:tab id -> 'sticker:1.0.png' 或 'img:icons/xxx.png' */
tabIcons: Record<string, string>
/** 歌词浮窗:底色 / 文字色 / 描边色 / 字号 */
lyricBg: string`
],
[
` lyricBg: 'rgba(16,20,30,0.55)',`,
` tabIcons: {},
lyricBg: 'rgba(16,20,30,0.55)',`
]
])
// 1) 协议:pet://stickers/<file>(内置表情包)
patch('main/index.ts', [
[
` } else if (url.host === 'music') {`,
` } else if (url.host === 'stickers') {
const dir = path.join(APP_DIR, 'assets', 'stickers')
abs = path.join(dir, rel)
root = dir
} else if (url.host === 'music') {`
]
])
// 2) 渲染端图标地址解析
{
const p = base + 'renderer/src/ui/iconUrl.ts'
fs.writeFileSync(
p,
`/** 把配置里的图标值转成可访问 URL */
export function iconUrl(value?: string): string {
if (!value) return ''
if (value.startsWith('sticker:')) return 'pet://stickers/' + encodeURIComponent(value.slice(8))
if (value.startsWith('img:')) return 'pet://data/' + value.slice(4).split('/').map(encodeURIComponent).join('/')
return ''
}
`,
'utf8'
)
}
// 3) Panel:TABS 渲染图标
patch('renderer/src/panel/Panel.tsx', [
[
"import { Icon } from '../ui/Icon'",
"import { Icon } from '../ui/Icon'\nimport { iconUrl } from '../ui/iconUrl'"
],
[
` {t.id === 'shop' && flavor === 'normal' ? '商店' : t.label}`,
` {cfg?.tabIcons?.[t.id] && (
<img className="tab-icon" src={iconUrl(cfg.tabIcons[t.id])} alt="" />
)}
{t.id === 'shop' && flavor === 'normal' ? '商店' : t.label}`
]
])
// 4) Menu:底栏分类也支持图标
patch('renderer/src/menu/Menu.tsx', [
[
"import { api } from '../api'",
"import { api } from '../api'\nimport { iconUrl } from '../ui/iconUrl'"
],
[
` {c.id === 'shop' && flavor === 'normal' ? '商店' : c.label}`,
` {cfg?.tabIcons?.[c.id] && (
<img className="tab-icon" src={iconUrl(cfg.tabIcons[c.id])} alt="" />
)}
{c.id === 'shop' && flavor === 'normal' ? '商店' : c.label}`
]
])
console.log('tab icons patched')