poi-plugin-inventory-cleaner 1.12.1 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +29 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -133,19 +133,36 @@ function Stat({ label, value, tone }) {
|
|
|
133
133
|
)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
function
|
|
137
|
-
const img = event.currentTarget
|
|
138
|
-
if (img.dataset.fallback) return
|
|
139
|
-
img.dataset.fallback = '1'
|
|
140
|
-
img.src = iconUrl(-1)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function iconUrl(iconType) {
|
|
136
|
+
function iconBase() {
|
|
144
137
|
if (typeof window === 'undefined') return ''
|
|
145
138
|
const root = window.ROOT || window.__ROOT || ''
|
|
146
139
|
if (!root) return ''
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
return 'file:///' + String(root).replace(/\\/g, '/').replace(/^\/+/, '')
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function iconUrl(iconType, kind) {
|
|
144
|
+
const base = iconBase()
|
|
145
|
+
if (!base) return ''
|
|
146
|
+
const id = Number(iconType) || 0
|
|
147
|
+
return kind === 'png'
|
|
148
|
+
? base + '/assets/img/slotitem/' + id + '.png'
|
|
149
|
+
: base + '/assets/svg/slotitem/' + id + '.svg'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// poi 的 PNG 图标只到 47,48~60 只有 SVG;按 svg → png → 通用图标 的顺序回落
|
|
153
|
+
function fallbackIcon(event) {
|
|
154
|
+
const img = event.currentTarget
|
|
155
|
+
const stage = img.dataset.iconStage || 'svg'
|
|
156
|
+
const id = Number(img.dataset.iconId) || 0
|
|
157
|
+
if (stage === 'svg') {
|
|
158
|
+
img.dataset.iconStage = 'png'
|
|
159
|
+
img.src = iconUrl(id, 'png')
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
if (stage === 'png') {
|
|
163
|
+
img.dataset.iconStage = 'none'
|
|
164
|
+
img.src = iconUrl(-1, 'svg')
|
|
165
|
+
}
|
|
149
166
|
}
|
|
150
167
|
|
|
151
168
|
function CategoryPicker({ value, groups, onChange }) {
|
|
@@ -214,6 +231,7 @@ function CategoryPicker({ value, groups, onChange }) {
|
|
|
214
231
|
src: iconUrl(entry.icon),
|
|
215
232
|
alt: '',
|
|
216
233
|
draggable: 'false',
|
|
234
|
+
'data-icon-id': String(entry.icon || 0),
|
|
217
235
|
onError: fallbackIcon,
|
|
218
236
|
}),
|
|
219
237
|
h('span', { className: 'stock-picker-name' }, entry.key || t('stock.batchOther')),
|
|
@@ -240,6 +258,7 @@ function StockRow({ row, onKeepChange }) {
|
|
|
240
258
|
src: iconUrl(row.icon),
|
|
241
259
|
alt: '',
|
|
242
260
|
draggable: 'false',
|
|
261
|
+
'data-icon-id': String(row.icon || 0),
|
|
243
262
|
onError: fallbackIcon,
|
|
244
263
|
}),
|
|
245
264
|
h('span', { className: 'stock-name' }, row.cn || row.jp || `#${row.id}`),
|