code cleanup

This commit is contained in:
olcxja 2026-09-26 10:13:50 +02:00
commit e8cd664965
8 changed files with 362 additions and 406 deletions

View file

@ -826,14 +826,12 @@ function wireEvents() {
if (p) qs('#gc-workdir').value = p
})
qs('#gc-tool-run').addEventListener('click', runCustomTool)
async function applyIconResult(res) {
toast(res.ok ? t('config.icon.set') : t('config.icon.noIcon'), res.ok ? 'success' : 'error')
if (res.ok) refreshConfigIcon()
}
qs('#gc-icon-auto').addEventListener('click', async () => {
const res = await window.plwl.gamesAutoIcon(state.currentGame.id)
if (res.ok) {
toast(t('config.icon.set'), 'success')
refreshConfigIcon()
} else {
toast(t('config.icon.noIcon'), 'error')
}
applyIconResult(await window.plwl.gamesAutoIcon(state.currentGame.id))
})
qs('#gc-icon-browse').addEventListener('click', async () => {
const p = await window.plwl.dialogPickFile({
@ -842,17 +840,7 @@ function wireEvents() {
filters: [{ name: t('config.icon.pick'), extensions: ['png', 'jpg', 'jpeg', 'svg', 'ico', 'webp', 'gif', 'bmp', 'exe'] }]
})
if (!p) return
let res
if (p.toLowerCase().endsWith('.exe')) {
res = await window.plwl.gamesSetIconFile(state.currentGame.id, p)
if (res.ok) toast(t('config.icon.set'), 'success')
else toast(t('config.icon.noIcon'), 'error')
} else {
res = await window.plwl.gamesSetIconFile(state.currentGame.id, p)
if (res.ok) toast(t('config.icon.set'), 'success')
else toast(t('config.icon.noIcon'), 'error')
}
refreshConfigIcon()
applyIconResult(await window.plwl.gamesSetIconFile(state.currentGame.id, p))
})
qs('#gc-icon-reset').addEventListener('click', async () => {
await window.plwl.gamesResetIcon(state.currentGame.id)