poi-plugin-inventory-cleaner 1.12.1 → 1.13.1

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/i18n/en-US.json CHANGED
@@ -31,6 +31,7 @@
31
31
  "stock.keepPlus": "Keep one more",
32
32
  "stock.batchToggle": "Batch keep",
33
33
  "stock.categoryAll": "All categories",
34
+ "stock.backToTop": "Back to top",
34
35
  "stock.categoryTitle": "Filter by in-game equipment type",
35
36
  "stock.sortTitle": "Sort by",
36
37
  "stock.sortVerdict": "Guide verdict",
package/i18n/zh-CN.json CHANGED
@@ -31,6 +31,7 @@
31
31
  "stock.keepPlus": "多留一件",
32
32
  "stock.batchToggle": "批量保留",
33
33
  "stock.categoryAll": "全部类别",
34
+ "stock.backToTop": "回到顶部",
34
35
  "stock.categoryTitle": "按游戏装备类型筛选",
35
36
  "stock.sortTitle": "排序方式",
36
37
  "stock.sortVerdict": "按攻略判定",
package/index.js CHANGED
@@ -133,19 +133,36 @@ function Stat({ label, value, tone }) {
133
133
  )
134
134
  }
135
135
 
136
- function fallbackIcon(event) {
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
- const base = String(root).replace(/\\/g, '/').replace(/^\/+/, '')
148
- return 'file:///' + base + '/assets/img/slotitem/' + (Number(iconType) || 0) + '.png'
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}`),
@@ -384,6 +403,17 @@ function App() {
384
403
 
385
404
  const [batchOpen, setBatchOpen] = React.useState(false)
386
405
  const [batchValues, setBatchValues] = React.useState({})
406
+ const [showTop, setShowTop] = React.useState(false)
407
+ const rootRef = React.useRef(null)
408
+
409
+ const handleScroll = React.useCallback((event) => {
410
+ setShowTop(event.currentTarget.scrollTop > 400)
411
+ }, [])
412
+
413
+ const scrollToTop = React.useCallback(() => {
414
+ const element = rootRef.current
415
+ if (element) element.scrollTo({ top: 0, behavior: 'smooth' })
416
+ }, [])
387
417
 
388
418
  const firstKeepSave = React.useRef(true)
389
419
  React.useEffect(() => {
@@ -458,7 +488,7 @@ function App() {
458
488
 
459
489
  return h(
460
490
  'div',
461
- { className: 'stock-root' },
491
+ { className: 'stock-root', ref: rootRef, onScroll: handleScroll },
462
492
  h('style', null, CSS),
463
493
  h(
464
494
  'header',
@@ -639,7 +669,18 @@ function App() {
639
669
  ),
640
670
  h('p', { className: 'stock-warn' }, t('stock.warn')),
641
671
  h('p', { className: 'stock-source' }, t('stock.source')),
642
-
672
+ showTop
673
+ ? h(
674
+ 'button',
675
+ {
676
+ type: 'button',
677
+ className: 'stock-top',
678
+ title: t('stock.backToTop'),
679
+ onClick: scrollToTop,
680
+ },
681
+ '↑',
682
+ )
683
+ : null,
643
684
  )
644
685
  }
645
686
 
package/lib/style.js CHANGED
@@ -373,25 +373,21 @@ const CSS = `
373
373
  .stock-note {
374
374
  margin: 6px 0 0;
375
375
  font-size: 11px;
376
- line-height: 1.55;
377
- opacity: 0.65;
378
- overflow: hidden;
379
- text-overflow: ellipsis;
380
- display: -webkit-box;
381
- -webkit-line-clamp: 3;
382
- -webkit-box-orient: vertical;
376
+ line-height: 1.6;
377
+ opacity: 0.7;
378
+ white-space: normal;
379
+ overflow-wrap: anywhere;
380
+ word-break: break-word;
383
381
  }
384
382
 
385
383
  .stock-consume {
386
384
  margin: 4px 0 0;
387
385
  font-size: 10px;
388
- line-height: 1.5;
386
+ line-height: 1.55;
389
387
  opacity: 0.45;
390
- overflow: hidden;
391
- text-overflow: ellipsis;
392
- display: -webkit-box;
393
- -webkit-line-clamp: 1;
394
- -webkit-box-orient: vertical;
388
+ white-space: normal;
389
+ overflow-wrap: anywhere;
390
+ word-break: break-word;
395
391
  }
396
392
 
397
393
  .stock-batchbar {
@@ -645,6 +641,53 @@ const CSS = `
645
641
  opacity: 0.42;
646
642
  }
647
643
 
644
+ .stock-root::-webkit-scrollbar {
645
+ width: 12px;
646
+ height: 12px;
647
+ }
648
+
649
+ .stock-root::-webkit-scrollbar-track {
650
+ background: rgba(255, 255, 255, 0.06);
651
+ border-radius: 6px;
652
+ }
653
+
654
+ .stock-root::-webkit-scrollbar-thumb {
655
+ background: rgba(170, 180, 195, 0.6);
656
+ border: 2px solid transparent;
657
+ border-radius: 6px;
658
+ background-clip: padding-box;
659
+ }
660
+
661
+ .stock-root::-webkit-scrollbar-thumb:hover {
662
+ background: rgba(205, 215, 230, 0.8);
663
+ border: 2px solid transparent;
664
+ background-clip: padding-box;
665
+ }
666
+
667
+ .stock-top {
668
+ position: fixed;
669
+ right: 22px;
670
+ bottom: 22px;
671
+ z-index: 70;
672
+ width: 42px;
673
+ height: 42px;
674
+ padding: 0;
675
+ border: 1px solid rgba(150, 160, 175, 0.55);
676
+ border-radius: 50%;
677
+ color: #e8edf4;
678
+ background: rgba(38, 44, 54, 0.94);
679
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
680
+ font-family: inherit;
681
+ font-size: 18px;
682
+ line-height: 1;
683
+ cursor: pointer;
684
+ }
685
+
686
+ .stock-top:hover {
687
+ border-color: #818cf8;
688
+ color: #818cf8;
689
+ }
690
+
648
691
  `
649
692
 
650
693
  module.exports = { CSS }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poi-plugin-inventory-cleaner",
3
- "version": "1.12.1",
3
+ "version": "1.13.1",
4
4
  "description": "库存清理大师:对照改修攻略与保留上限,找出囤积过量、可以清理的装备,并标出不能拆的改修材料。",
5
5
  "main": "index.js",
6
6
  "files": [