aram-mayhem-dsh 0.3.0 → 0.3.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.
Files changed (52) hide show
  1. package/INSTALL.zh-CN.txt +61 -54
  2. package/LICENSE +27 -27
  3. package/README.md +234 -194
  4. package/THIRD_PARTY_NOTICES.md +50 -50
  5. package/client.js +973 -829
  6. package/config/settings.json +57 -57
  7. package/cordis.patch.yml +5 -6
  8. package/data/README.md +9 -9
  9. package/docs/DETAIL.md +3 -3
  10. package/docs/DETAIL.zh.md +3 -3
  11. package/docs/preview.svg +63 -63
  12. package/icon.svg +23 -23
  13. package/index.js +544 -439
  14. package/install.ps1 +63 -63
  15. package/locale/en.json +7 -7
  16. package/locale/zh.json +7 -7
  17. package/package.json +72 -72
  18. package/requirements-core.txt +6 -6
  19. package/requirements-dsh.txt +8 -8
  20. package/scripts/desktop_overlay.py +1305 -1305
  21. package/scripts/dsh_service.py +999 -999
  22. package/src/__init__.py +3 -3
  23. package/src/app.py +462 -462
  24. package/src/core/__init__.py +1 -1
  25. package/src/core/event_bus.py +56 -56
  26. package/src/core/events.py +28 -28
  27. package/src/core/hotkeys.py +166 -166
  28. package/src/core/logging_setup.py +44 -44
  29. package/src/core/paths.py +44 -44
  30. package/src/core/settings.py +271 -271
  31. package/src/data/__init__.py +1 -1
  32. package/src/data/fetcher.py +239 -239
  33. package/src/data/matcher.py +534 -534
  34. package/src/data/models.py +287 -287
  35. package/src/data/schema.py +128 -128
  36. package/src/data/scoring.py +127 -127
  37. package/src/data/store.py +543 -543
  38. package/src/lcu/__init__.py +1 -1
  39. package/src/lcu/connector.py +316 -316
  40. package/src/lcu/listener.py +507 -507
  41. package/src/main.py +76 -76
  42. package/src/ui/__init__.py +1 -1
  43. package/src/ui/augment_panel.py +276 -276
  44. package/src/ui/build_panel.py +319 -319
  45. package/src/ui/champ_panel.py +236 -236
  46. package/src/ui/overlay_window.py +631 -631
  47. package/src/ui/theme.py +298 -298
  48. package/src/ui/widgets.py +408 -408
  49. package/src/vision/__init__.py +1 -1
  50. package/src/vision/capture.py +249 -249
  51. package/src/vision/ocr_engine.py +122 -122
  52. package/src/vision/scanner.py +272 -272
package/client.js CHANGED
@@ -1,829 +1,973 @@
1
- window.__ModuleLoader__.load({
2
- id: 'aram-mayhem-dsh',
3
- factory(require) {
4
- const React = require('react')
5
- const h = React.createElement
6
- const { useEffect, useRef, useState } = React
7
-
8
- // Web and Electron (app://app) use the DSH same-origin relay; a plain
9
- // file:// page falls back to the loopback service, which allows null origin.
10
- const API = location.protocol === 'file:' ? 'http://127.0.0.1:8123' : '/aram-api'
11
- const AUTO_KEY = 'dsh.aram-mayhem.auto-scan.v1'
12
- const TABS = [
13
- { id: 'champ', label: '选人' },
14
- { id: 'augment', label: '推荐海克斯' },
15
- { id: 'build', label: '出装' },
16
- ]
17
- const TIER = {
18
- T0: { color: '#B8862F', bg: 'rgba(184,134,47,.12)' },
19
- T1: { color: '#238A78', bg: 'rgba(35,138,120,.12)' },
20
- T2: { color: '#4E78A8', bg: 'rgba(78,120,168,.12)' },
21
- T3: { color: '#7B8798', bg: 'rgba(123,135,152,.12)' },
22
- }
23
- // League augment rarity accents: silver / gold / prismatic.
24
- const RARITY = {
25
- prismatic: {
26
- color: '#8B5CF6',
27
- // Iridescent border, the same cyan → violet → gold reading as the
28
- // prismatic augment card frame in game.
29
- background: 'linear-gradient(135deg, rgba(92,225,230,.18), rgba(179,136,255,.22), rgba(255,209,102,.18)) padding-box, '
30
- + 'linear-gradient(135deg, #5CE1E6, #B388FF, #FFD166) border-box',
31
- border: '1px solid transparent',
32
- },
33
- gold: {
34
- color: '#A77B2C',
35
- bg: 'rgba(200,170,110,.16)',
36
- border: '1px solid #C8AA6E99',
37
- },
38
- silver: {
39
- color: '#6F7F94',
40
- bg: 'rgba(174,186,203,.16)',
41
- border: '1px solid #AEBACB99',
42
- },
43
- }
44
-
45
- const S = {
46
- page: {
47
- height: '100%', minHeight: 0, boxSizing: 'border-box', display: 'flex',
48
- flexDirection: 'column', padding: '18px 26px 14px', gap: 10,
49
- fontSize: 13, lineHeight: 1.55, overflow: 'hidden',
50
- },
51
- row: { display: 'flex', alignItems: 'center', gap: 8 },
52
- wrap: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' },
53
- title: { fontSize: 22, fontWeight: 650, margin: 0, letterSpacing: '-0.01em' },
54
- sub: { opacity: 0.64, fontSize: 12.5 },
55
- header: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'flex-start', flexWrap: 'wrap', flexShrink: 0 },
56
- card: {
57
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
58
- background: 'var(--dsw-alias-card-fill, rgba(128,128,128,.055))',
59
- borderRadius: 14,
60
- },
61
- hero: {
62
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
63
- background: 'var(--dsw-alias-card-fill, rgba(128,128,128,.055))',
64
- borderRadius: 16, padding: 16,
65
- },
66
- chip: {
67
- display: 'inline-flex', alignItems: 'center', gap: 5, padding: '2px 8px',
68
- borderRadius: 999, border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.26))',
69
- fontSize: 11.5, lineHeight: 1.6, whiteSpace: 'nowrap',
70
- },
71
- btn: {
72
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.35))',
73
- background: 'transparent', color: 'inherit', borderRadius: 9,
74
- padding: '6px 12px', cursor: 'pointer', fontSize: 12.5,
75
- },
76
- primary: {
77
- border: '1px solid var(--dsw-alias-border-l3, rgba(128,128,128,.3))',
78
- background: 'var(--dsw-alias-button-primary-dimmed, rgba(128,128,128,.16))',
79
- color: 'var(--dsw-alias-label-primary, inherit)',
80
- borderRadius: 9, padding: '7px 14px', cursor: 'pointer', fontSize: 12.5,
81
- },
82
- input: {
83
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.3))',
84
- background: 'transparent', color: 'inherit', borderRadius: 9,
85
- padding: '7px 10px', fontSize: 12.5, width: 170, outline: 'none',
86
- },
87
- tab: on => ({
88
- border: 'none', borderBottom: `2px solid ${on ? 'var(--dsw-alias-brand-primary, #0F8A9D)' : 'transparent'}`,
89
- background: 'transparent', color: on ? 'var(--dsw-alias-brand-primary, #0F8A9D)' : 'inherit',
90
- opacity: on ? 1 : 0.65, padding: '7px 12px', cursor: 'pointer', fontSize: 13,
91
- fontWeight: on ? 650 : 500,
92
- }),
93
- section: { display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', gap: 10, margin: '4px 0 8px' },
94
- sectionTitle: { fontSize: 13, fontWeight: 650 },
95
- muted: { opacity: 0.62, fontSize: 12 },
96
- benchGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 8 },
97
- rowCard: {
98
- display: 'flex', alignItems: 'center', gap: 9, padding: '8px 10px',
99
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', borderRadius: 11,
100
- background: 'transparent', color: 'inherit', textAlign: 'left', cursor: 'pointer', width: '100%',
101
- },
102
- metric: { display: 'flex', flexDirection: 'column', gap: 0, minWidth: 58 },
103
- metricV: { fontSize: 15, fontWeight: 700, fontVariantNumeric: 'tabular-nums' },
104
- metricL: { fontSize: 10.5, opacity: 0.58, whiteSpace: 'nowrap' },
105
- bar: { height: 5, borderRadius: 999, background: 'var(--dsw-alias-border-l2, rgba(128,128,128,.2))', overflow: 'hidden' },
106
- body: { flex: 1, minHeight: 0, overflow: 'auto', paddingRight: 4, display: 'flex', flexDirection: 'column', gap: 10 },
107
- item: {
108
- display: 'inline-flex', alignItems: 'center', gap: 6, padding: '4px 8px',
109
- borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
110
- fontSize: 11.5, whiteSpace: 'nowrap',
111
- },
112
- skill: color => ({
113
- width: 28, height: 28, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
114
- borderRadius: 7, border: `1px solid ${color}66`, color, background: `${color}18`,
115
- fontSize: 12.5, fontWeight: 700,
116
- }),
117
- banner: {
118
- border: '1px solid rgba(200,120,50,.35)', background: 'rgba(200,120,50,.08)',
119
- borderRadius: 10, padding: '8px 10px', fontSize: 12.5, flexShrink: 0,
120
- },
121
- error: {
122
- border: '1px solid rgba(200,70,70,.35)', background: 'rgba(200,70,70,.08)',
123
- borderRadius: 10, padding: '9px 11px', fontSize: 12.5, flexShrink: 0,
124
- },
125
- }
126
-
127
- const pct = (value, digits = 1) => typeof value === 'number' ? `${(value * 100).toFixed(digits)}%` : '--'
128
-
129
- async function get(path, timeout = 8000) {
130
- const response = await fetch(`${API}${path}`, { signal: AbortSignal.timeout(timeout) })
131
- const data = await response.json().catch(() => ({}))
132
- if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
133
- return data
134
- }
135
-
136
- async function post(path, body, timeout = 180000) {
137
- const response = await fetch(`${API}${path}`, {
138
- method: 'POST',
139
- headers: { 'Content-Type': 'application/json; charset=utf-8' },
140
- body: JSON.stringify(body || {}),
141
- signal: AbortSignal.timeout(timeout),
142
- })
143
- const data = await response.json().catch(() => ({}))
144
- if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
145
- return data
146
- }
147
-
148
- function Chip({ children, tone = 'normal', title }) {
149
- const color = tone === 'gold' ? '#B8862F' : tone === 'green' ? '#2F9E62'
150
- : tone === 'red' ? '#C05050' : undefined
151
- return h('span', {
152
- style: {
153
- ...S.chip,
154
- ...(color ? { color, borderColor: `${color}55`, background: `${color}10` } : {}),
155
- },
156
- title,
157
- }, children)
158
- }
159
-
160
- function Tier({ tier }) {
161
- const t = TIER[tier] || TIER.T2
162
- return h('span', {
163
- style: {
164
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
165
- minWidth: 26, height: 18, padding: '0 5px', borderRadius: 5,
166
- color: t.color, background: t.bg, border: `1px solid ${t.color}44`,
167
- fontSize: 10, fontWeight: 700,
168
- },
169
- }, tier || 'T2')
170
- }
171
-
172
- function Rarity({ rarity, label }) {
173
- const r = RARITY[rarity] || RARITY.gold
174
- return h('span', {
175
- style: {
176
- padding: '1px 5px', borderRadius: 4, fontSize: 10,
177
- color: r.color, background: r.bg || r.background,
178
- border: r.border || `1px solid ${r.color}44`,
179
- },
180
- }, label || rarity || '?')
181
- }
182
-
183
- const AVATAR_COLORS = ['#3A6B8E', '#6F5AA8', '#A86E3A', '#3E8078', '#9A5E72']
184
-
185
- function Avatar({ name, size = 38, tier }) {
186
- const initial = (name || '?').slice(0, 1)
187
- const color = AVATAR_COLORS[Math.abs((name || '').split('').reduce((a, ch) => a + ch.charCodeAt(0), 0)) % AVATAR_COLORS.length]
188
- const border = (TIER[tier] || TIER.T2).color
189
- return h('span', {
190
- style: {
191
- width: size, height: size, borderRadius: '50%', flex: '0 0 auto',
192
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
193
- color: '#fff', fontSize: Math.round(size * .4), fontWeight: 700,
194
- background: `linear-gradient(135deg, ${color}, ${color}99)`,
195
- border: `1px solid ${border}88`,
196
- },
197
- }, initial)
198
- }
199
-
200
- function Bar({ value, best }) {
201
- const width = Math.max(0, Math.min(100, Number(value) || 0))
202
- return h('div', { style: S.bar },
203
- h('div', {
204
- style: {
205
- width: `${width}%`, height: '100%', borderRadius: 999,
206
- background: best
207
- ? 'linear-gradient(90deg, #B8862F, #E0B962)'
208
- : 'linear-gradient(90deg, #2E8B8B, #4FC3B8)',
209
- },
210
- }))
211
- }
212
-
213
- function Metric({ value, label, color }) {
214
- return h('div', { style: S.metric },
215
- h('span', { style: { ...S.metricV, color: color || 'inherit' } }, value),
216
- h('span', { style: S.metricL }, label))
217
- }
218
-
219
- function ItemChip({ item }) {
220
- return h('span', { style: S.item, title: `${item.name} · ${item.total || 0} 金币` },
221
- h('span', {
222
- style: {
223
- width: 18, height: 18, borderRadius: 4, display: 'inline-flex',
224
- alignItems: 'center', justifyContent: 'center', fontSize: 9,
225
- background: 'var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18))',
226
- color: 'inherit', fontWeight: 700,
227
- },
228
- }, (item.name || '?').slice(0, 1)),
229
- h('span', null, item.name))
230
- }
231
-
232
- function HeroCard({ summary, preview, onReset }) {
233
- const c = summary.champion
234
- return h('div', { style: S.hero },
235
- h('div', { style: { ...S.row, alignItems: 'flex-start', gap: 13 } },
236
- h(Avatar, { name: c.name, size: 58, tier: c.tier }),
237
- h('div', { style: { flex: 1, minWidth: 0 } },
238
- h('div', { style: { ...S.row, gap: 7, flexWrap: 'wrap' } },
239
- h('span', { style: { fontSize: 20, fontWeight: 700 } }, c.name),
240
- h(Tier, { tier: c.tier }),
241
- preview ? h('button', { style: { ...S.btn, padding: '2px 8px', fontSize: 11 }, onClick: onReset }, '返回我的英雄') : null),
242
- h('div', { style: S.muted }, `${c.title || ''} · ${summary.style_label || '均衡强化'}`),
243
- h('div', { style: { ...S.row, gap: 14, marginTop: 10, flexWrap: 'wrap' } },
244
- h(Metric, { value: c.rank, label: '全服排名' }),
245
- h(Metric, { value: c.pick_rate_label, label: '选取率' }),
246
- h(Metric, { value: Number(c.games || 0).toLocaleString('en-US'), label: '样本' }))),
247
- h('div', { style: { textAlign: 'right', minWidth: 72 } },
248
- h('div', { style: { fontSize: 26, fontWeight: 750, letterSpacing: '-0.02em', fontVariantNumeric: 'tabular-nums' } }, c.win_rate_label),
249
- h('div', { style: S.muted }, '海斗胜率'))),
250
- h('div', { style: { marginTop: 12 } }, h(Bar, { value: c.win_rate * 100, best: c.tier === 'T0' || c.tier === 'T1' })),
251
- summary.top_augments?.length
252
- ? h('div', { style: { ...S.row, gap: 6, marginTop: 10, flexWrap: 'wrap' } },
253
- h('span', { style: S.muted }, '优先:'),
254
- summary.top_augments.slice(0, 3).map(item => h(Chip, {
255
- key: item.augment.id, tone: item.is_best ? 'gold' : 'normal',
256
- title: `推荐分 ${item.score}`,
257
- }, item.augment.name)))
258
- : null)
259
- }
260
-
261
- function BenchRow({ item, my, active, onClick }) {
262
- const c = item.champion
263
- const delta = my ? c.win_rate - my.champion.win_rate : null
264
- return h('button', {
265
- style: {
266
- ...S.rowCard,
267
- ...(active ? {
268
- borderColor: 'var(--dsw-alias-brand-primary, #0F8A9D)',
269
- boxShadow: 'inset 0 0 0 1px var(--dsw-alias-brand-primary, #0F8A9D)',
270
- } : {}),
271
- },
272
- onClick,
273
- title: '点击查看该英雄的出装与海克斯',
274
- },
275
- h(Avatar, { name: c.name, size: 32, tier: c.tier }),
276
- h('div', { style: { minWidth: 0, flex: 1 } },
277
- h('div', { style: { ...S.row, gap: 5 } },
278
- h('span', { style: { fontWeight: 600 } }, c.name),
279
- h(Tier, { tier: c.tier })),
280
- h('div', { style: { ...S.muted, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } },
281
- item.top_augments?.[0] ? `首选 ${item.top_augments[0].augment.name}` : '暂无英雄样本')),
282
- h('div', { style: { textAlign: 'right', flex: '0 0 auto' } },
283
- h('div', { style: { fontWeight: 700, fontVariantNumeric: 'tabular-nums' } }, c.win_rate_label),
284
- h('div', {
285
- style: { ...S.muted, color: delta == null ? undefined : delta >= 0 ? '#2F9E62' : '#C05050' },
286
- }, delta == null ? '海斗胜率' : `${delta >= 0 ? '+' : ''}${(delta * 100).toFixed(1)} vs 我的`)))
287
- }
288
-
289
- function Candidate({ item }) {
290
- const best = item.is_best
291
- return h('div', {
292
- style: {
293
- ...S.card, padding: 11,
294
- ...(best ? { borderColor: 'rgba(184,134,47,.65)', background: 'rgba(184,134,47,.055)' } : {}),
295
- },
296
- },
297
- h('div', { style: { ...S.row, gap: 7 } },
298
- h('span', {
299
- style: {
300
- width: 24, height: 24, borderRadius: 12, flex: '0 0 auto',
301
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
302
- fontSize: 10, fontWeight: 700,
303
- color: best ? '#8a5d14' : 'inherit',
304
- background: best ? 'rgba(184,134,47,.14)' : 'rgba(128,128,128,.08)',
305
- border: `1px solid ${best ? 'rgba(184,134,47,.4)' : 'rgba(128,128,128,.22)'}`,
306
- },
307
- }, item.rank),
308
- h('span', {
309
- style: {
310
- fontWeight: 700, fontSize: 13.5, flex: '1 1 auto', minWidth: 0,
311
- overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
312
- },
313
- }, item.augment.name),
314
- h(Rarity, { rarity: item.augment.rarity, label: item.augment.rarity_label }),
315
- h(Tier, { tier: item.tier }),
316
- h('span', { style: { fontSize: 19, fontWeight: 750, color: best ? '#B8862F' : 'inherit', fontVariantNumeric: 'tabular-nums' } }, Math.round(item.score)),
317
- h('span', { style: { ...S.muted, fontSize: 10 } }, '/100')),
318
- h('div', { style: { ...S.row, gap: 12, flexWrap: 'wrap', margin: '5px 0 6px' } },
319
- h('span', { style: { fontWeight: 650 } }, `胜率 ${item.win_rate_label}`),
320
- h('span', { style: { ...S.muted, color: item.delta >= 0 ? '#2F9E62' : '#C05050' } },
321
- `差值 ${item.delta_label}pp`),
322
- h('span', { style: S.muted }, `选取 ${item.pick_rate_label}`),
323
- h('span', { style: S.muted }, `样本 ${Number(item.games || 0).toLocaleString('en-US')}`),
324
- !item.champion_stats ? h('span', { style: S.muted }, '全服数据') : null),
325
- h(Bar, { value: item.score, best }),
326
- item.tags?.length
327
- ? h('div', { style: { ...S.wrap, gap: 4, marginTop: 6 } },
328
- item.tags.map(tag => h(Chip, { key: tag, tone: tag === '首选' ? 'gold' : tag.includes('偏低') ? 'red' : 'normal' }, tag)))
329
- : null)
330
- }
331
-
332
- function BuildView({ summary }) {
333
- if (!summary?.build) return h('div', { style: { ...S.card, padding: 16 } }, h('div', { style: S.muted }, '该英雄暂无出装数据。'))
334
- const b = summary.build
335
- const itemNames = items => (items || []).map(item => h(ItemChip, { key: item.id, item }))
336
- return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } },
337
- h('div', null,
338
- h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '出门装'), h('span', { style: S.muted }, '按定位推荐')),
339
- h('div', { style: S.wrap }, itemNames(b.starting_items))),
340
- h('div', null,
341
- h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '核心三件套'), h('span', { style: S.muted }, '统计样本')),
342
- (b.core_builds || []).map((core, index) => h('div', {
343
- key: index, style: { ...S.card, padding: '9px 10px', marginBottom: 7 },
344
- },
345
- h('div', { style: { ...S.row, gap: 6, marginBottom: 5 } },
346
- h('span', { style: { color: index === 0 ? '#B8862F' : undefined, fontWeight: 650, fontSize: 11.5 } },
347
- index === 0 ? '首选' : `方案 ${index + 1}`),
348
- h('span', { style: { flex: 1 } }),
349
- h('span', { style: { fontWeight: 650 } }, `${core.win_rate_label} 胜率`),
350
- h('span', { style: S.muted }, `${Number(core.games || 0).toLocaleString('en-US')} 局`),
351
- core.pick_rate_label ? h('span', { style: S.muted }, `选取 ${core.pick_rate_label}`) : null),
352
- h('div', { style: { ...S.wrap, gap: 3 } },
353
- (core.items || []).flatMap((item, itemIndex) => [
354
- itemIndex ? h('span', { key: `a${itemIndex}`, style: S.muted }, '→') : null,
355
- h(ItemChip, { key: item.id, item }),
356
- ]))))),
357
- h('div', null,
358
- h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '鞋子与召唤师技能'), h('span', { style: S.muted }, '按定位 / 样本最高组合')),
359
- h('div', { style: { ...S.wrap, gap: 6 } },
360
- itemNames(b.boots),
361
- (b.spells || []).map(spell => h('span', { key: spell, style: S.chip }, spell)))),
362
- h('div', null,
363
- h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '命运之武器'), h('span', { style: S.muted }, '首件传说参考')),
364
- h('div', { style: { ...S.card, padding: 10 } },
365
- b.destiny
366
- ? h('div', null,
367
- h('div', { style: { ...S.wrap, gap: 6 } }, itemNames(b.destiny.items)),
368
- h('div', { style: { ...S.muted, marginTop: 6 } },
369
- `${b.destiny.win_rate_label} 胜率 · ${Number(b.destiny.games || 0).toLocaleString('en-US')} 局${b.destiny.note ? ` · ${b.destiny.note}` : ''}`))
370
- : h('div', { style: S.muted }, '该英雄暂无达标的命运之武器装备样本。'))),
371
- h('div', null,
372
- h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '技能加点'), h('span', { style: S.muted }, '通用模板,非统计数据')),
373
- h('div', { style: { ...S.row, gap: 5, flexWrap: 'wrap' } },
374
- (b.skill_priority || []).map((skill, index) => h(React.Fragment, { key: skill + index },
375
- index ? h('span', { key: `arrow${index}`, style: S.muted }, '›') : null,
376
- h('span', { style: S.skill(['#4E78A8', '#238A78', '#8B5CF6'][index] || '#7B8798') }, skill))),
377
- h('span', { style: { ...S.skill('#B8862F'), marginLeft: 6 } }, 'R'),
378
- h('span', { style: { ...S.muted, marginLeft: 5 } }, '6 / 11 / 16 级')),
379
- b.skill_note ? h('div', { style: { ...S.muted, marginTop: 6 } }, b.skill_note) : null),
380
- h('div', { style: { ...S.muted, borderTop: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', paddingTop: 10 } },
381
- b.notes || ''))
382
- }
383
-
384
- function Page() {
385
- const [snap, setSnap] = useState(null)
386
- const [loadError, setLoadError] = useState('')
387
- const [tab, setTab] = useState('champ')
388
- const [preview, setPreview] = useState(null)
389
- const [search, setSearch] = useState('')
390
- const [results, setResults] = useState([])
391
- const [searchBusy, setSearchBusy] = useState(false)
392
- const [searchError, setSearchError] = useState('')
393
- const [searchEmpty, setSearchEmpty] = useState(false)
394
- const [detected, setDetected] = useState([])
395
- const [evals, setEvals] = useState([])
396
- const [scanError, setScanError] = useState('')
397
- const [scanning, setScanning] = useState(false)
398
- const [autoScan, setAutoScan] = useState(() => {
399
- try { return localStorage.getItem(AUTO_KEY) === '1' } catch { return false }
400
- })
401
- const [scanAt, setScanAt] = useState(0)
402
- const [serviceWait, setServiceWait] = useState(false)
403
- const [overlayOn, setOverlayOn] = useState(null)
404
- const [overlayBusy, setOverlayBusy] = useState(false)
405
- const [overlayError, setOverlayError] = useState('')
406
- const scanRef = useRef(null)
407
- const scanningRef = useRef(false)
408
- const lastScanRef = useRef(0)
409
- const myIdRef = useRef(0)
410
-
411
- useEffect(() => {
412
- const timer = setTimeout(() => setServiceWait(true), 8000)
413
- return () => clearTimeout(timer)
414
- }, [])
415
-
416
- useEffect(() => {
417
- let alive = true
418
- const pull = async () => {
419
- try {
420
- const data = await get('/overlay/status', 4000)
421
- if (!alive) return
422
- setOverlayOn(!!data.running)
423
- setOverlayError(data.pyside === false ? '缺少 PySide6,无法启动桌面图标' : '')
424
- } catch {
425
- if (alive) setOverlayOn(false)
426
- }
427
- }
428
- pull()
429
- const timer = setInterval(pull, 8000)
430
- return () => { alive = false; clearInterval(timer) }
431
- }, [])
432
-
433
- useEffect(() => {
434
- let alive = true
435
- const pull = async () => {
436
- try {
437
- const data = await get('/snapshot', 6000)
438
- if (!alive) return
439
- setSnap(data)
440
- setLoadError('')
441
- if (data.last_scan && data.last_scan.at > lastScanRef.current) {
442
- lastScanRef.current = data.last_scan.at
443
- setDetected(data.last_scan.matches || [])
444
- setEvals(data.last_scan.evaluations || [])
445
- setScanAt(data.last_scan.at)
446
- }
447
- } catch (error) {
448
- if (alive) setLoadError(`${error?.message || error}(请求 ${API}/health)`)
449
- }
450
- }
451
- pull()
452
- const timer = setInterval(pull, 2000)
453
- return () => { alive = false; clearInterval(timer) }
454
- }, [])
455
-
456
- const myId = snap?.champ_select?.my_champion_id || 0
457
- useEffect(() => {
458
- if (myId !== myIdRef.current) {
459
- myIdRef.current = myId
460
- setPreview(null)
461
- setEvals([])
462
- setDetected([])
463
- setScanError('')
464
- if (myId) setTab('champ')
465
- }
466
- }, [myId])
467
-
468
- useEffect(() => {
469
- try { localStorage.setItem(AUTO_KEY, autoScan ? '1' : '0') } catch { /* ignore */ }
470
- }, [autoScan])
471
-
472
- const active = preview || snap?.my_champion || null
473
- const scanChampionId = snap?.my_champion?.champion?.id || myId || active?.champion?.id || null
474
- const lcu = snap?.lcu || {}
475
- const canScan = !!lcu.in_game || lcu.phase === 'InProgress' || lcu.phase === 'Reconnect'
476
-
477
- const runScan = async (championOverride) => {
478
- if (scanningRef.current) return
479
- scanningRef.current = true
480
- setScanning(true)
481
- setScanError('')
482
- try {
483
- const body = { champion: championOverride || scanChampionId || undefined }
484
- const data = await post('/scan', body)
485
- if (!data.ok) {
486
- setScanError(data.error || '识别失败')
487
- setDetected([])
488
- setEvals([])
489
- return
490
- }
491
- setDetected(data.matches || [])
492
- setEvals(data.evaluations || [])
493
- setScanAt(data.at || Date.now() / 1000)
494
- lastScanRef.current = data.at || Date.now() / 1000
495
- } catch (error) {
496
- setScanError(String(error?.message || error))
497
- } finally {
498
- scanningRef.current = false
499
- setScanning(false)
500
- }
501
- }
502
- scanRef.current = runScan
503
-
504
- useEffect(() => {
505
- if (!autoScan || !canScan || tab !== 'augment') return
506
- const timer = setInterval(() => {
507
- if (!scanningRef.current) scanRef.current?.(scanChampionId)
508
- }, 6000)
509
- return () => clearInterval(timer)
510
- }, [autoScan, canScan, scanChampionId, tab])
511
-
512
- const doSearch = async () => {
513
- const q = search.trim()
514
- if (!q) return
515
- setSearchBusy(true)
516
- setSearchError('')
517
- setSearchEmpty(false)
518
- try {
519
- const data = await get(`/champions?q=${encodeURIComponent(q)}&limit=10`)
520
- setResults(data.champions || [])
521
- setSearchEmpty(!data.champions?.length)
522
- } catch (error) {
523
- setSearchError(String(error?.message || error))
524
- } finally {
525
- setSearchBusy(false)
526
- }
527
- }
528
-
529
- const chooseResult = async champion => {
530
- setSearchBusy(true)
531
- setSearchError('')
532
- setSearchEmpty(false)
533
- try {
534
- const data = await get(`/champion?champion=${champion.id}&top=5`)
535
- setPreview(data.summary)
536
- setTab('champ')
537
- setResults([])
538
- setSearch('')
539
- } catch (error) {
540
- setSearchError(String(error?.message || error))
541
- } finally {
542
- setSearchBusy(false)
543
- }
544
- }
545
-
546
- const resetPreview = () => {
547
- setPreview(null)
548
- setTab('champ')
549
- }
550
-
551
- const previewBench = async item => {
552
- setPreview(item)
553
- setTab('champ')
554
- try {
555
- const data = await get(`/champion?champion=${item.champion.id}&top=5`)
556
- setPreview(data.summary)
557
- } catch {
558
- // Keep the snapshot's top-three summary if the follow-up fails.
559
- }
560
- }
561
-
562
- const toggleOverlay = async () => {
563
- if (overlayBusy || overlayOn === null) return
564
- const turningOff = !!overlayOn
565
- setOverlayBusy(true)
566
- setOverlayError('')
567
- try {
568
- const data = turningOff
569
- ? await post('/overlay/stop', { persist: true }, 15000)
570
- : await post('/overlay/start', { persist: true }, 25000)
571
- if (turningOff) {
572
- if (data.running) throw new Error(data.note || '图标仍在运行')
573
- setOverlayOn(false)
574
- } else {
575
- if (!data.running) throw new Error(data.note || '图标启动失败')
576
- setOverlayOn(true)
577
- }
578
- } catch (error) {
579
- setOverlayError(String(error?.message || error))
580
- try {
581
- const status = await get('/overlay/status', 4000)
582
- setOverlayOn(!!status.running)
583
- } catch { /* keep previous state */ }
584
- } finally {
585
- setOverlayBusy(false)
586
- }
587
- }
588
-
589
- const meta = snap?.meta || {}
590
- const bench = snap?.bench || []
591
- const me = snap?.my_champion || null
592
- const augmentName = active?.champion?.name || '等待英雄'
593
- const recommendations = active?.top_augments || []
594
- const scanChampionName = me?.champion?.name || augmentName
595
- const phase = lcu.phase || 'Disconnected'
596
- const phaseLabel = {
597
- ChampSelect: '选人阶段', InProgress: '对局中', Reconnect: '重连中',
598
- Lobby: '大厅', None: '空闲', Disconnected: '未连接', EndOfGame: '对局结束',
599
- }[phase] || phase
600
-
601
- if (!snap && loadError) {
602
- if (!serviceWait) {
603
- return h('div', { style: { ...S.page, justifyContent: 'center', alignItems: 'center', opacity: .7 }, role: 'status' },
604
- '正在启动本地服务,首次启动可能需要几秒…')
605
- }
606
- return h('div', { style: S.page },
607
- h('div', { style: S.header }, h('div', null, h('h1', { style: S.title }, '海斗助手'), h('div', { style: S.sub }, 'ARAM: Mayhem · 本地数据与 LCU'))),
608
- h('div', { style: S.error, role: 'alert' },
609
- h('div', { style: { fontWeight: 650, marginBottom: 4 } }, '本地服务暂不可用'),
610
- h('div', null, loadError),
611
- h('div', { style: { ...S.muted, marginTop: 6 } }, '页面会每 2 秒自动重试;插件加载时 Host 也会尝试启动服务。'),
612
- h('button', { style: { ...S.btn, marginTop: 8 }, onClick: () => location.reload() }, '立即重试')),
613
- h('div', { style: { ...S.card, padding: 16, marginTop: 8 } },
614
- h('div', { style: { fontWeight: 650, marginBottom: 6 } }, '仍无法启动时'),
615
- h('div', { style: S.muted }, '在插件目录运行:python scripts/dsh_service.py --port 8123 --root .'),
616
- h('div', { style: { ...S.muted, marginTop: 4 } }, '或检查 Python 依赖:python -m pip install -r requirements-dsh.txt')))
617
- }
618
- if (!snap) {
619
- return h('div', { style: { ...S.page, justifyContent: 'center', alignItems: 'center', opacity: .65 }, role: 'status' }, '正在连接海斗助手服务…')
620
- }
621
-
622
- return h('div', { style: S.page },
623
- h('div', { style: S.header },
624
- h('div', null,
625
- h('h1', { style: S.title }, '海斗助手'),
626
- h('div', { style: S.sub }, `ARAM: Mayhem · ${meta.patch || '--'} · ${meta.source || '本地数据'}`)),
627
- h('div', { style: { ...S.row, gap: 7, flexWrap: 'wrap', justifyContent: 'flex-end' } },
628
- h(Chip, { tone: 'gold' }, `数据 ${meta.patch || '--'}`),
629
- h(Chip, { tone: lcu.connected ? 'green' : 'normal', title: lcu.error || undefined },
630
- `LCU ${lcu.connected ? '已连接' : '未连接'}`),
631
- h(Chip, null, phaseLabel),
632
- h('button', {
633
- type: 'button',
634
- role: 'switch',
635
- 'aria-checked': !!overlayOn,
636
- 'aria-label': '显示屏幕置顶桌面图标',
637
- title: '显示或隐藏屏幕置顶的海斗助手图标',
638
- disabled: overlayBusy || overlayOn === null,
639
- onClick: toggleOverlay,
640
- style: {
641
- ...S.chip,
642
- fontFamily: 'inherit', fontSize: 11.5,
643
- cursor: overlayBusy || overlayOn === null ? 'wait' : 'pointer',
644
- background: overlayOn ? 'rgba(47,158,98,.12)' : 'transparent',
645
- borderColor: overlayOn ? '#2F9E62' : 'var(--dsw-alias-border-l2, rgba(128,128,128,.3))',
646
- opacity: overlayOn === null ? .6 : 1,
647
- },
648
- },
649
- h('span', {
650
- style: {
651
- width: 7, height: 7, borderRadius: '50%',
652
- background: overlayOn ? '#2F9E62' : '#8A8A8A',
653
- },
654
- }),
655
- `桌面图标 ${overlayBusy || overlayOn === null ? '…' : overlayOn ? '开' : '关'}`),
656
- h('input', {
657
- style: S.input, value: search, placeholder: '搜索英雄,如 亚索',
658
- 'aria-label': '搜索英雄',
659
- onChange: event => {
660
- setSearch(event.target.value)
661
- setSearchError('')
662
- setSearchEmpty(false)
663
- },
664
- onKeyDown: event => { if (event.key === 'Enter') doSearch() },
665
- }),
666
- h('button', { style: S.btn, onClick: doSearch, disabled: searchBusy }, searchBusy ? '…' : '查询'))),
667
-
668
- loadError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, `服务暂时不可用:${loadError}`) : null,
669
- overlayError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, `桌面图标:${overlayError}`) : null,
670
- !lcu.connected && lcu.error
671
- ? h('div', { style: { ...S.muted, flexShrink: 0 } }, `LCU:${lcu.error}。仍可搜索英雄;进入对局后可手动扫描。`)
672
- : null,
673
- lcu.connected && !lcu.is_mayhem && lcu.queue_id
674
- ? h('div', { style: S.banner }, `当前队列:${lcu.queue_name || lcu.queue_id}。海斗统计仅供参考。`)
675
- : null,
676
- searchError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, searchError) : null,
677
- searchEmpty
678
- ? h('div', { style: { ...S.muted, flexShrink: 0 } }, '没有找到匹配的英雄。')
679
- : null,
680
- results.length
681
- ? h('div', { style: { ...S.card, padding: 10, flexShrink: 0 } },
682
- h('div', { style: { ...S.muted, marginBottom: 6 } }, '搜索结果'),
683
- h('div', { style: S.wrap },
684
- results.map(item => h('button', {
685
- key: item.id, style: S.btn, onClick: () => chooseResult(item),
686
- }, `${item.name} ${item.tier} ${item.win_rate_label}`))))
687
- : null,
688
-
689
- h('div', {
690
- style: { ...S.row, gap: 3, borderBottom: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', flexShrink: 0 },
691
- role: 'tablist', 'aria-label': '海斗助手页签',
692
- },
693
- TABS.map(item => h('button', {
694
- key: item.id, style: S.tab(tab === item.id), onClick: () => setTab(item.id),
695
- role: 'tab', 'aria-selected': tab === item.id, type: 'button',
696
- }, item.label, item.id === 'augment' && evals.length ? ' ●' : ''))),
697
-
698
- h('div', { style: S.body },
699
- tab === 'champ'
700
- ? h(React.Fragment, null,
701
- active
702
- ? h(HeroCard, { summary: active, preview: !!preview, onReset: resetPreview })
703
- : h('div', { style: { ...S.card, padding: 20, textAlign: 'center' } },
704
- h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '等待选人'),
705
- h('div', { style: S.muted }, '连接客户端后自动读取你的英雄;也可以在上方搜索英雄查看数据。')),
706
- bench.length
707
- ? h('div', null,
708
- h('div', { style: S.section },
709
- h('span', { style: S.sectionTitle }, '备战席'),
710
- h('span', { style: S.muted }, `${bench.length} 位可选 · 点击预览`)),
711
- h('div', { style: S.benchGrid },
712
- bench.map(item => h(BenchRow, {
713
- key: item.champion.id, item, my: me, active: preview?.champion?.id === item.champion.id,
714
- onClick: () => previewBench(item),
715
- }))))
716
- : null,
717
- h('div', { style: S.muted },
718
- `数据快照:${meta.matches ? Number(meta.matches).toLocaleString('en-US') + ' 场' : '--'} · 更新 ${meta.updated_label || '--'}。`
719
- + ' 统计为部分对局样本,胜率与选取是相关关系。'))
720
- : tab === 'augment'
721
- ? h(React.Fragment, null,
722
- h('div', { style: { ...S.card, padding: '9px 11px' } },
723
- h('div', { style: { ...S.row, gap: 9, flexWrap: 'wrap' } },
724
- h(Avatar, { name: augmentName, size: 32, tier: active?.champion?.tier }),
725
- h('div', { style: { flex: 1, minWidth: 130 } },
726
- h('div', { style: { fontWeight: 650 } }, augmentName),
727
- h('div', { style: S.muted }, active
728
- ? `${active.champion.title || ''} · 胜率 ${active.champion.win_rate_label} · ${active.champion.tier}`
729
- : '先选择英雄,或等待 LCU 选人')),
730
- h('label', {
731
- style: { ...S.row, gap: 5, fontSize: 11.5, opacity: .75, cursor: 'pointer' },
732
- title: '仅在本页签打开时,每 6 秒扫描一次游戏客户区',
733
- },
734
- h('input', {
735
- type: 'checkbox', checked: autoScan,
736
- onChange: event => setAutoScan(event.target.checked),
737
- }), '自动扫描 6s'),
738
- h('button', {
739
- style: { ...S.primary, opacity: scanning ? .55 : 1 },
740
- disabled: scanning,
741
- onClick: () => runScan(scanChampionId),
742
- }, scanning ? '识别中…' : '立即扫描'))),
743
- scanError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, scanError) : null,
744
- !canScan
745
- ? h('div', { style: { ...S.card, padding: 16, ...S.muted } },
746
- '进入对局后,海克斯三选一出现时可扫描当前卡片;即使 LCU 未连接,也可以手动扫描。'
747
- + '建议使用无边框/窗口化;首次 OCR 会加载本地模型,只读取游戏客户区。')
748
- : null,
749
- evals.length
750
- ? h(React.Fragment, null,
751
- h('div', { style: S.section },
752
- h('span', { style: S.sectionTitle }, `本局识别 · ${scanChampionName}`),
753
- h('span', { style: S.muted }, `${evals.length} 张 · 按推荐度排序${scanAt ? ' · ' + new Date(scanAt * 1000).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' }) : ''}`)),
754
- evals.map(item => h(Candidate, { key: 'scan-' + item.augment.id, item })),
755
- h('div', { style: S.muted },
756
- '本局识别按当前客户端英雄评分;推荐分 = 英雄专属胜率(向全服收缩)+ 全服强度。'))
757
- : detected.length
758
- ? h('div', { style: { ...S.card, padding: 12 } },
759
- h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '识别到卡片'),
760
- h('div', { style: S.wrap }, detected.map(item => h(Chip, { key: item.id }, `${item.name} ${Math.round((item.confidence || 0) * 100)}%`))))
761
- : null,
762
- h('div', { style: S.section },
763
- h('span', { style: S.sectionTitle }, `版本推荐 · ${augmentName}`),
764
- h('span', { style: S.muted }, recommendations.length
765
- ? `${recommendations.length} 个 · 英雄专属 + 全服样本`
766
- : '暂无英雄推荐')),
767
- recommendations.length
768
- ? recommendations.map(item => h(Candidate, { key: 'rec-' + item.augment.id, item }))
769
- : h('div', { style: { ...S.card, padding: 18, textAlign: 'center' } },
770
- h('div', { style: { fontWeight: 650, marginBottom: 5 } }, active ? '暂无该英雄的推荐' : '还没有选择英雄'),
771
- h('div', { style: S.muted }, active
772
- ? '该英雄在本版本没有足够的海克斯样本。'
773
- : '等待 LCU 选人,或在上方搜索英雄后查看推荐。')),
774
- h('div', { style: S.muted },
775
- '推荐分 = 英雄专属胜率(向全服收缩)+ 全服强度;低样本会被压低。'
776
- + ' 差值单位为百分点。'))
777
- : h(React.Fragment, null,
778
- active
779
- ? h('div', { style: { ...S.row, gap: 7, marginBottom: 2 } },
780
- h(Avatar, { name: active.champion.name, size: 30, tier: active.champion.tier }),
781
- h('span', { style: { fontWeight: 700 } }, active.champion.name),
782
- h(Tier, { tier: active.champion.tier }),
783
- preview ? h('button', { style: { ...S.btn, padding: '2px 8px', fontSize: 11 }, onClick: resetPreview }, '返回我的英雄') : null)
784
- : h('div', { style: { ...S.card, padding: 18, textAlign: 'center' } },
785
- h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '还没有选择英雄'),
786
- h('div', { style: S.muted }, '等待 LCU 选人,或在上方搜索英雄后查看出装。')),
787
- active ? h(BuildView, { summary: active }) : null)),
788
-
789
- h('div', {
790
- style: {
791
- ...S.row, justifyContent: 'space-between', gap: 8, flexWrap: 'wrap',
792
- borderTop: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))',
793
- paddingTop: 8, flexShrink: 0, fontSize: 11, opacity: .62,
794
- },
795
- },
796
- h('span', null, `数据 ${meta.patch || '--'} · ${meta.source || '--'} · ${meta.license || '--'}`),
797
- h('span', null, `服务 127.0.0.1:8123${lcu.summoner ? ' · ' + lcu.summoner : ''}`)))
798
- }
799
-
800
- function Icon({ size = 20, active = false }) {
801
- return h('svg', {
802
- width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
803
- stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round',
804
- style: { display: 'block', color: active ? 'var(--dsw-alias-brand-primary)' : 'currentColor' },
805
- 'aria-hidden': true, focusable: false,
806
- },
807
- h('path', { d: 'M12 2.6l7.2 4.1v8.1L12 19l-7.2-4.2V6.7L12 2.6z' }),
808
- h('path', { d: 'M12 7.2l3.4 2v4.1L12 15.5l-3.4-2.2V9.2L12 7.2z', opacity: 0.55 }),
809
- h('path', { d: 'M8.4 19.1L12 21.5l3.6-2.4' }))
810
- }
811
-
812
- return {
813
- inject: ['slots'],
814
- apply(ctx) {
815
- ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
816
- name: 'sidebar.panellist',
817
- id: 'aram-mayhem',
818
- order: 25,
819
- label: () => '海斗助手',
820
- }, Icon))
821
-
822
- ctx.slots.inject('main', () => ctx.slots.register({
823
- name: 'main',
824
- key: 'aram-mayhem',
825
- }, Page))
826
- },
827
- }
828
- },
829
- })
1
+ window.__ModuleLoader__.load({
2
+ id: 'aram-mayhem-dsh',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const { useEffect, useRef, useState } = React
7
+
8
+ // Web and Electron (app://app) use the DSH same-origin relay; a plain
9
+ // file:// page falls back to the loopback service, which allows null origin.
10
+ const API = location.protocol === 'file:' ? 'http://127.0.0.1:8123' : '/aram-api'
11
+ const CONTROL = '/aram-control'
12
+ const AUTO_KEY = 'dsh.aram-mayhem.auto-scan.v1'
13
+ const TABS = [
14
+ { id: 'champ', label: '选人' },
15
+ { id: 'augment', label: '推荐海克斯' },
16
+ { id: 'build', label: '出装' },
17
+ ]
18
+ const TIER = {
19
+ T0: { color: '#B8862F', bg: 'rgba(184,134,47,.12)' },
20
+ T1: { color: '#238A78', bg: 'rgba(35,138,120,.12)' },
21
+ T2: { color: '#4E78A8', bg: 'rgba(78,120,168,.12)' },
22
+ T3: { color: '#7B8798', bg: 'rgba(123,135,152,.12)' },
23
+ }
24
+ // League augment rarity accents: silver / gold / prismatic.
25
+ const RARITY = {
26
+ prismatic: {
27
+ color: '#8B5CF6',
28
+ // Iridescent border, the same cyan → violet → gold reading as the
29
+ // prismatic augment card frame in game.
30
+ background: 'linear-gradient(135deg, rgba(92,225,230,.18), rgba(179,136,255,.22), rgba(255,209,102,.18)) padding-box, '
31
+ + 'linear-gradient(135deg, #5CE1E6, #B388FF, #FFD166) border-box',
32
+ border: '1px solid transparent',
33
+ },
34
+ gold: {
35
+ color: '#A77B2C',
36
+ bg: 'rgba(200,170,110,.16)',
37
+ border: '1px solid #C8AA6E99',
38
+ },
39
+ silver: {
40
+ color: '#6F7F94',
41
+ bg: 'rgba(174,186,203,.16)',
42
+ border: '1px solid #AEBACB99',
43
+ },
44
+ }
45
+
46
+ const S = {
47
+ page: {
48
+ height: '100%', minHeight: 0, boxSizing: 'border-box', display: 'flex',
49
+ flexDirection: 'column', padding: '18px 26px 14px', gap: 10,
50
+ fontSize: 13, lineHeight: 1.55, overflow: 'hidden',
51
+ },
52
+ row: { display: 'flex', alignItems: 'center', gap: 8 },
53
+ wrap: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' },
54
+ title: { fontSize: 22, fontWeight: 650, margin: 0, letterSpacing: '-0.01em' },
55
+ sub: { opacity: 0.64, fontSize: 12.5 },
56
+ header: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'flex-start', flexWrap: 'wrap', flexShrink: 0 },
57
+ card: {
58
+ border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
59
+ background: 'var(--dsw-alias-card-fill, rgba(128,128,128,.055))',
60
+ borderRadius: 14,
61
+ },
62
+ hero: {
63
+ border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
64
+ background: 'var(--dsw-alias-card-fill, rgba(128,128,128,.055))',
65
+ borderRadius: 16, padding: 16,
66
+ },
67
+ chip: {
68
+ display: 'inline-flex', alignItems: 'center', gap: 5, padding: '2px 8px',
69
+ borderRadius: 999, border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.26))',
70
+ fontSize: 11.5, lineHeight: 1.6, whiteSpace: 'nowrap',
71
+ },
72
+ btn: {
73
+ border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.35))',
74
+ background: 'transparent', color: 'inherit', borderRadius: 9,
75
+ padding: '6px 12px', cursor: 'pointer', fontSize: 12.5,
76
+ },
77
+ primary: {
78
+ border: '1px solid var(--dsw-alias-border-l3, rgba(128,128,128,.3))',
79
+ background: 'var(--dsw-alias-button-primary-dimmed, rgba(128,128,128,.16))',
80
+ color: 'var(--dsw-alias-label-primary, inherit)',
81
+ borderRadius: 9, padding: '7px 14px', cursor: 'pointer', fontSize: 12.5,
82
+ },
83
+ input: {
84
+ border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.3))',
85
+ background: 'transparent', color: 'inherit', borderRadius: 9,
86
+ padding: '7px 10px', fontSize: 12.5, width: 170, outline: 'none',
87
+ },
88
+ tab: on => ({
89
+ border: 'none', borderBottom: `2px solid ${on ? 'var(--dsw-alias-brand-primary, #0F8A9D)' : 'transparent'}`,
90
+ background: 'transparent', color: on ? 'var(--dsw-alias-brand-primary, #0F8A9D)' : 'inherit',
91
+ opacity: on ? 1 : 0.65, padding: '7px 12px', cursor: 'pointer', fontSize: 13,
92
+ fontWeight: on ? 650 : 500,
93
+ }),
94
+ section: { display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', gap: 10, margin: '4px 0 8px' },
95
+ sectionTitle: { fontSize: 13, fontWeight: 650 },
96
+ muted: { opacity: 0.62, fontSize: 12 },
97
+ benchGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 8 },
98
+ rowCard: {
99
+ display: 'flex', alignItems: 'center', gap: 9, padding: '8px 10px',
100
+ border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', borderRadius: 11,
101
+ background: 'transparent', color: 'inherit', textAlign: 'left', cursor: 'pointer', width: '100%',
102
+ },
103
+ metric: { display: 'flex', flexDirection: 'column', gap: 0, minWidth: 58 },
104
+ metricV: { fontSize: 15, fontWeight: 700, fontVariantNumeric: 'tabular-nums' },
105
+ metricL: { fontSize: 10.5, opacity: 0.58, whiteSpace: 'nowrap' },
106
+ bar: { height: 5, borderRadius: 999, background: 'var(--dsw-alias-border-l2, rgba(128,128,128,.2))', overflow: 'hidden' },
107
+ body: { flex: 1, minHeight: 0, overflow: 'auto', paddingRight: 4, display: 'flex', flexDirection: 'column', gap: 10 },
108
+ item: {
109
+ display: 'inline-flex', alignItems: 'center', gap: 6, padding: '4px 8px',
110
+ borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.22))',
111
+ fontSize: 11.5, whiteSpace: 'nowrap',
112
+ },
113
+ skill: color => ({
114
+ width: 28, height: 28, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
115
+ borderRadius: 7, border: `1px solid ${color}66`, color, background: `${color}18`,
116
+ fontSize: 12.5, fontWeight: 700,
117
+ }),
118
+ banner: {
119
+ border: '1px solid rgba(200,120,50,.35)', background: 'rgba(200,120,50,.08)',
120
+ borderRadius: 10, padding: '8px 10px', fontSize: 12.5, flexShrink: 0,
121
+ },
122
+ error: {
123
+ border: '1px solid rgba(200,70,70,.35)', background: 'rgba(200,70,70,.08)',
124
+ borderRadius: 10, padding: '9px 11px', fontSize: 12.5, flexShrink: 0,
125
+ },
126
+ }
127
+
128
+ const pct = (value, digits = 1) => typeof value === 'number' ? `${(value * 100).toFixed(digits)}%` : '--'
129
+
130
+ async function get(path, timeout = 8000) {
131
+ const response = await fetch(`${API}${path}`, { signal: AbortSignal.timeout(timeout) })
132
+ const data = await response.json().catch(() => ({}))
133
+ if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
134
+ return data
135
+ }
136
+
137
+ async function post(path, body, timeout = 180000) {
138
+ const response = await fetch(`${API}${path}`, {
139
+ method: 'POST',
140
+ headers: { 'Content-Type': 'application/json; charset=utf-8' },
141
+ body: JSON.stringify(body || {}),
142
+ signal: AbortSignal.timeout(timeout),
143
+ })
144
+ const data = await response.json().catch(() => ({}))
145
+ if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
146
+ return data
147
+ }
148
+
149
+ async function controlGet(path = '/status', timeout = 5000) {
150
+ const response = await fetch(`${CONTROL}${path}`, { signal: AbortSignal.timeout(timeout) })
151
+ const data = await response.json().catch(() => ({}))
152
+ if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
153
+ return data
154
+ }
155
+
156
+ async function controlPost(path, timeout = 75000) {
157
+ const response = await fetch(`${CONTROL}${path}`, {
158
+ method: 'POST',
159
+ headers: { 'Content-Type': 'application/json; charset=utf-8' },
160
+ body: '{}',
161
+ signal: AbortSignal.timeout(timeout),
162
+ })
163
+ const data = await response.json().catch(() => ({}))
164
+ if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
165
+ return data
166
+ }
167
+
168
+ function Chip({ children, tone = 'normal', title }) {
169
+ const color = tone === 'gold' ? '#B8862F' : tone === 'green' ? '#2F9E62'
170
+ : tone === 'red' ? '#C05050' : undefined
171
+ return h('span', {
172
+ style: {
173
+ ...S.chip,
174
+ ...(color ? { color, borderColor: `${color}55`, background: `${color}10` } : {}),
175
+ },
176
+ title,
177
+ }, children)
178
+ }
179
+
180
+ function Tier({ tier }) {
181
+ const t = TIER[tier] || TIER.T2
182
+ return h('span', {
183
+ style: {
184
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
185
+ minWidth: 26, height: 18, padding: '0 5px', borderRadius: 5,
186
+ color: t.color, background: t.bg, border: `1px solid ${t.color}44`,
187
+ fontSize: 10, fontWeight: 700,
188
+ },
189
+ }, tier || 'T2')
190
+ }
191
+
192
+ function Rarity({ rarity, label }) {
193
+ const r = RARITY[rarity] || RARITY.gold
194
+ return h('span', {
195
+ style: {
196
+ padding: '1px 5px', borderRadius: 4, fontSize: 10,
197
+ color: r.color, background: r.bg || r.background,
198
+ border: r.border || `1px solid ${r.color}44`,
199
+ },
200
+ }, label || rarity || '?')
201
+ }
202
+
203
+ const AVATAR_COLORS = ['#3A6B8E', '#6F5AA8', '#A86E3A', '#3E8078', '#9A5E72']
204
+
205
+ function Avatar({ name, size = 38, tier }) {
206
+ const initial = (name || '?').slice(0, 1)
207
+ const color = AVATAR_COLORS[Math.abs((name || '').split('').reduce((a, ch) => a + ch.charCodeAt(0), 0)) % AVATAR_COLORS.length]
208
+ const border = (TIER[tier] || TIER.T2).color
209
+ return h('span', {
210
+ style: {
211
+ width: size, height: size, borderRadius: '50%', flex: '0 0 auto',
212
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
213
+ color: '#fff', fontSize: Math.round(size * .4), fontWeight: 700,
214
+ background: `linear-gradient(135deg, ${color}, ${color}99)`,
215
+ border: `1px solid ${border}88`,
216
+ },
217
+ }, initial)
218
+ }
219
+
220
+ function Bar({ value, best }) {
221
+ const width = Math.max(0, Math.min(100, Number(value) || 0))
222
+ return h('div', { style: S.bar },
223
+ h('div', {
224
+ style: {
225
+ width: `${width}%`, height: '100%', borderRadius: 999,
226
+ background: best
227
+ ? 'linear-gradient(90deg, #B8862F, #E0B962)'
228
+ : 'linear-gradient(90deg, #2E8B8B, #4FC3B8)',
229
+ },
230
+ }))
231
+ }
232
+
233
+ function Metric({ value, label, color }) {
234
+ return h('div', { style: S.metric },
235
+ h('span', { style: { ...S.metricV, color: color || 'inherit' } }, value),
236
+ h('span', { style: S.metricL }, label))
237
+ }
238
+
239
+ function ItemChip({ item }) {
240
+ return h('span', { style: S.item, title: `${item.name} · ${item.total || 0} 金币` },
241
+ h('span', {
242
+ style: {
243
+ width: 18, height: 18, borderRadius: 4, display: 'inline-flex',
244
+ alignItems: 'center', justifyContent: 'center', fontSize: 9,
245
+ background: 'var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18))',
246
+ color: 'inherit', fontWeight: 700,
247
+ },
248
+ }, (item.name || '?').slice(0, 1)),
249
+ h('span', null, item.name))
250
+ }
251
+
252
+ function HeroCard({ summary, preview, onReset }) {
253
+ const c = summary.champion
254
+ return h('div', { style: S.hero },
255
+ h('div', { style: { ...S.row, alignItems: 'flex-start', gap: 13 } },
256
+ h(Avatar, { name: c.name, size: 58, tier: c.tier }),
257
+ h('div', { style: { flex: 1, minWidth: 0 } },
258
+ h('div', { style: { ...S.row, gap: 7, flexWrap: 'wrap' } },
259
+ h('span', { style: { fontSize: 20, fontWeight: 700 } }, c.name),
260
+ h(Tier, { tier: c.tier }),
261
+ preview ? h('button', { style: { ...S.btn, padding: '2px 8px', fontSize: 11 }, onClick: onReset }, '返回我的英雄') : null),
262
+ h('div', { style: S.muted }, `${c.title || ''} · ${summary.style_label || '均衡强化'}`),
263
+ h('div', { style: { ...S.row, gap: 14, marginTop: 10, flexWrap: 'wrap' } },
264
+ h(Metric, { value: c.rank, label: '全服排名' }),
265
+ h(Metric, { value: c.pick_rate_label, label: '选取率' }),
266
+ h(Metric, { value: Number(c.games || 0).toLocaleString('en-US'), label: '样本' }))),
267
+ h('div', { style: { textAlign: 'right', minWidth: 72 } },
268
+ h('div', { style: { fontSize: 26, fontWeight: 750, letterSpacing: '-0.02em', fontVariantNumeric: 'tabular-nums' } }, c.win_rate_label),
269
+ h('div', { style: S.muted }, '海斗胜率'))),
270
+ h('div', { style: { marginTop: 12 } }, h(Bar, { value: c.win_rate * 100, best: c.tier === 'T0' || c.tier === 'T1' })),
271
+ summary.top_augments?.length
272
+ ? h('div', { style: { ...S.row, gap: 6, marginTop: 10, flexWrap: 'wrap' } },
273
+ h('span', { style: S.muted }, '优先:'),
274
+ summary.top_augments.slice(0, 3).map(item => h(Chip, {
275
+ key: item.augment.id, tone: item.is_best ? 'gold' : 'normal',
276
+ title: `推荐分 ${item.score}`,
277
+ }, item.augment.name)))
278
+ : null)
279
+ }
280
+
281
+ function BenchRow({ item, my, active, onClick }) {
282
+ const c = item.champion
283
+ const delta = my ? c.win_rate - my.champion.win_rate : null
284
+ return h('button', {
285
+ style: {
286
+ ...S.rowCard,
287
+ ...(active ? {
288
+ borderColor: 'var(--dsw-alias-brand-primary, #0F8A9D)',
289
+ boxShadow: 'inset 0 0 0 1px var(--dsw-alias-brand-primary, #0F8A9D)',
290
+ } : {}),
291
+ },
292
+ onClick,
293
+ title: '点击查看该英雄的出装与海克斯',
294
+ },
295
+ h(Avatar, { name: c.name, size: 32, tier: c.tier }),
296
+ h('div', { style: { minWidth: 0, flex: 1 } },
297
+ h('div', { style: { ...S.row, gap: 5 } },
298
+ h('span', { style: { fontWeight: 600 } }, c.name),
299
+ h(Tier, { tier: c.tier })),
300
+ h('div', { style: { ...S.muted, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } },
301
+ item.top_augments?.[0] ? `首选 ${item.top_augments[0].augment.name}` : '暂无英雄样本')),
302
+ h('div', { style: { textAlign: 'right', flex: '0 0 auto' } },
303
+ h('div', { style: { fontWeight: 700, fontVariantNumeric: 'tabular-nums' } }, c.win_rate_label),
304
+ h('div', {
305
+ style: { ...S.muted, color: delta == null ? undefined : delta >= 0 ? '#2F9E62' : '#C05050' },
306
+ }, delta == null ? '海斗胜率' : `${delta >= 0 ? '+' : ''}${(delta * 100).toFixed(1)} vs 我的`)))
307
+ }
308
+
309
+ function Candidate({ item }) {
310
+ const best = item.is_best
311
+ return h('div', {
312
+ style: {
313
+ ...S.card, padding: 11,
314
+ ...(best ? { borderColor: 'rgba(184,134,47,.65)', background: 'rgba(184,134,47,.055)' } : {}),
315
+ },
316
+ },
317
+ h('div', { style: { ...S.row, gap: 7 } },
318
+ h('span', {
319
+ style: {
320
+ width: 24, height: 24, borderRadius: 12, flex: '0 0 auto',
321
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
322
+ fontSize: 10, fontWeight: 700,
323
+ color: best ? '#8a5d14' : 'inherit',
324
+ background: best ? 'rgba(184,134,47,.14)' : 'rgba(128,128,128,.08)',
325
+ border: `1px solid ${best ? 'rgba(184,134,47,.4)' : 'rgba(128,128,128,.22)'}`,
326
+ },
327
+ }, item.rank),
328
+ h('span', {
329
+ style: {
330
+ fontWeight: 700, fontSize: 13.5, flex: '1 1 auto', minWidth: 0,
331
+ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
332
+ },
333
+ }, item.augment.name),
334
+ h(Rarity, { rarity: item.augment.rarity, label: item.augment.rarity_label }),
335
+ h(Tier, { tier: item.tier }),
336
+ h('span', { style: { fontSize: 19, fontWeight: 750, color: best ? '#B8862F' : 'inherit', fontVariantNumeric: 'tabular-nums' } }, Math.round(item.score)),
337
+ h('span', { style: { ...S.muted, fontSize: 10 } }, '/100')),
338
+ h('div', { style: { ...S.row, gap: 12, flexWrap: 'wrap', margin: '5px 0 6px' } },
339
+ h('span', { style: { fontWeight: 650 } }, `胜率 ${item.win_rate_label}`),
340
+ h('span', { style: { ...S.muted, color: item.delta >= 0 ? '#2F9E62' : '#C05050' } },
341
+ `差值 ${item.delta_label}pp`),
342
+ h('span', { style: S.muted }, `选取 ${item.pick_rate_label}`),
343
+ h('span', { style: S.muted }, `样本 ${Number(item.games || 0).toLocaleString('en-US')}`),
344
+ !item.champion_stats ? h('span', { style: S.muted }, '全服数据') : null),
345
+ h(Bar, { value: item.score, best }),
346
+ item.tags?.length
347
+ ? h('div', { style: { ...S.wrap, gap: 4, marginTop: 6 } },
348
+ item.tags.map(tag => h(Chip, { key: tag, tone: tag === '首选' ? 'gold' : tag.includes('偏低') ? 'red' : 'normal' }, tag)))
349
+ : null)
350
+ }
351
+
352
+ function BuildView({ summary }) {
353
+ if (!summary?.build) return h('div', { style: { ...S.card, padding: 16 } }, h('div', { style: S.muted }, '该英雄暂无出装数据。'))
354
+ const b = summary.build
355
+ const itemNames = items => (items || []).map(item => h(ItemChip, { key: item.id, item }))
356
+ return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } },
357
+ h('div', null,
358
+ h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '出门装'), h('span', { style: S.muted }, '按定位推荐')),
359
+ h('div', { style: S.wrap }, itemNames(b.starting_items))),
360
+ h('div', null,
361
+ h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '核心三件套'), h('span', { style: S.muted }, '统计样本')),
362
+ (b.core_builds || []).map((core, index) => h('div', {
363
+ key: index, style: { ...S.card, padding: '9px 10px', marginBottom: 7 },
364
+ },
365
+ h('div', { style: { ...S.row, gap: 6, marginBottom: 5 } },
366
+ h('span', { style: { color: index === 0 ? '#B8862F' : undefined, fontWeight: 650, fontSize: 11.5 } },
367
+ index === 0 ? '首选' : `方案 ${index + 1}`),
368
+ h('span', { style: { flex: 1 } }),
369
+ h('span', { style: { fontWeight: 650 } }, `${core.win_rate_label} 胜率`),
370
+ h('span', { style: S.muted }, `${Number(core.games || 0).toLocaleString('en-US')} 局`),
371
+ core.pick_rate_label ? h('span', { style: S.muted }, `选取 ${core.pick_rate_label}`) : null),
372
+ h('div', { style: { ...S.wrap, gap: 3 } },
373
+ (core.items || []).flatMap((item, itemIndex) => [
374
+ itemIndex ? h('span', { key: `a${itemIndex}`, style: S.muted }, '→') : null,
375
+ h(ItemChip, { key: item.id, item }),
376
+ ]))))),
377
+ h('div', null,
378
+ h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '鞋子与召唤师技能'), h('span', { style: S.muted }, '按定位 / 样本最高组合')),
379
+ h('div', { style: { ...S.wrap, gap: 6 } },
380
+ itemNames(b.boots),
381
+ (b.spells || []).map(spell => h('span', { key: spell, style: S.chip }, spell)))),
382
+ h('div', null,
383
+ h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '命运之武器'), h('span', { style: S.muted }, '首件传说参考')),
384
+ h('div', { style: { ...S.card, padding: 10 } },
385
+ b.destiny
386
+ ? h('div', null,
387
+ h('div', { style: { ...S.wrap, gap: 6 } }, itemNames(b.destiny.items)),
388
+ h('div', { style: { ...S.muted, marginTop: 6 } },
389
+ `${b.destiny.win_rate_label} 胜率 · ${Number(b.destiny.games || 0).toLocaleString('en-US')} 局${b.destiny.note ? ` · ${b.destiny.note}` : ''}`))
390
+ : h('div', { style: S.muted }, '该英雄暂无达标的命运之武器装备样本。'))),
391
+ h('div', null,
392
+ h('div', { style: S.section }, h('span', { style: S.sectionTitle }, '技能加点'), h('span', { style: S.muted }, '通用模板,非统计数据')),
393
+ h('div', { style: { ...S.row, gap: 5, flexWrap: 'wrap' } },
394
+ (b.skill_priority || []).map((skill, index) => h(React.Fragment, { key: skill + index },
395
+ index ? h('span', { key: `arrow${index}`, style: S.muted }, '›') : null,
396
+ h('span', { style: S.skill(['#4E78A8', '#238A78', '#8B5CF6'][index] || '#7B8798') }, skill))),
397
+ h('span', { style: { ...S.skill('#B8862F'), marginLeft: 6 } }, 'R'),
398
+ h('span', { style: { ...S.muted, marginLeft: 5 } }, '6 / 11 / 16 级')),
399
+ b.skill_note ? h('div', { style: { ...S.muted, marginTop: 6 } }, b.skill_note) : null),
400
+ h('div', { style: { ...S.muted, borderTop: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', paddingTop: 10 } },
401
+ b.notes || ''))
402
+ }
403
+
404
+ function Page() {
405
+ const [snap, setSnap] = useState(null)
406
+ const [loadError, setLoadError] = useState('')
407
+ const [tab, setTab] = useState('champ')
408
+ const [preview, setPreview] = useState(null)
409
+ const [search, setSearch] = useState('')
410
+ const [results, setResults] = useState([])
411
+ const [searchBusy, setSearchBusy] = useState(false)
412
+ const [searchError, setSearchError] = useState('')
413
+ const [searchEmpty, setSearchEmpty] = useState(false)
414
+ const [detected, setDetected] = useState([])
415
+ const [evals, setEvals] = useState([])
416
+ const [scanError, setScanError] = useState('')
417
+ const [scanning, setScanning] = useState(false)
418
+ const [autoScan, setAutoScan] = useState(() => {
419
+ try { return localStorage.getItem(AUTO_KEY) === '1' } catch { return false }
420
+ })
421
+ const [scanAt, setScanAt] = useState(0)
422
+ const [serviceWait, setServiceWait] = useState(false)
423
+ const [serviceOn, setServiceOn] = useState(null)
424
+ const [serviceBusy, setServiceBusy] = useState(false)
425
+ const [serviceError, setServiceError] = useState('')
426
+ const [overlayOn, setOverlayOn] = useState(null)
427
+ const [overlayBusy, setOverlayBusy] = useState(false)
428
+ const [overlayError, setOverlayError] = useState('')
429
+ const scanRef = useRef(null)
430
+ const scanningRef = useRef(false)
431
+ const lastScanRef = useRef(0)
432
+ const myIdRef = useRef(0)
433
+
434
+ useEffect(() => {
435
+ const timer = setTimeout(() => setServiceWait(true), 8000)
436
+ return () => clearTimeout(timer)
437
+ }, [])
438
+
439
+ useEffect(() => {
440
+ let alive = true
441
+ const pull = async () => {
442
+ try {
443
+ const data = await controlGet('/status', 4000)
444
+ if (!alive) return
445
+ setServiceOn(!!data.running)
446
+ setServiceError(data.error || '')
447
+ } catch {
448
+ if (alive) setServiceOn(false)
449
+ }
450
+ }
451
+ pull()
452
+ const timer = setInterval(pull, 3000)
453
+ return () => { alive = false; clearInterval(timer) }
454
+ }, [])
455
+
456
+ useEffect(() => {
457
+ if (!serviceOn) {
458
+ setOverlayOn(false)
459
+ return
460
+ }
461
+ let alive = true
462
+ const pull = async () => {
463
+ try {
464
+ const data = await get('/overlay/status', 4000)
465
+ if (!alive) return
466
+ setOverlayOn(!!data.running)
467
+ setOverlayError(data.pyside === false ? '缺少 PySide6,无法启动桌面图标' : '')
468
+ } catch {
469
+ if (alive) setOverlayOn(false)
470
+ }
471
+ }
472
+ pull()
473
+ const timer = setInterval(pull, 8000)
474
+ return () => { alive = false; clearInterval(timer) }
475
+ }, [serviceOn])
476
+
477
+ useEffect(() => {
478
+ if (!serviceOn) {
479
+ setSnap(null)
480
+ setLoadError('')
481
+ return
482
+ }
483
+ let alive = true
484
+ const pull = async () => {
485
+ try {
486
+ const data = await get('/snapshot', 6000)
487
+ if (!alive) return
488
+ setSnap(data)
489
+ setLoadError('')
490
+ if (data.last_scan && data.last_scan.at > lastScanRef.current) {
491
+ lastScanRef.current = data.last_scan.at
492
+ setDetected(data.last_scan.matches || [])
493
+ setEvals(data.last_scan.evaluations || [])
494
+ setScanAt(data.last_scan.at)
495
+ }
496
+ } catch (error) {
497
+ if (alive) setLoadError(`${error?.message || error}(服务已启动,但请求失败)`)
498
+ }
499
+ }
500
+ pull()
501
+ const timer = setInterval(pull, 2000)
502
+ return () => { alive = false; clearInterval(timer) }
503
+ }, [serviceOn])
504
+
505
+ const myId = snap?.champ_select?.my_champion_id || 0
506
+ useEffect(() => {
507
+ if (myId !== myIdRef.current) {
508
+ myIdRef.current = myId
509
+ setPreview(null)
510
+ setEvals([])
511
+ setDetected([])
512
+ setScanError('')
513
+ if (myId) setTab('champ')
514
+ }
515
+ }, [myId])
516
+
517
+ useEffect(() => {
518
+ try { localStorage.setItem(AUTO_KEY, autoScan ? '1' : '0') } catch { /* ignore */ }
519
+ }, [autoScan])
520
+
521
+ const active = preview || snap?.my_champion || null
522
+ const scanChampionId = snap?.my_champion?.champion?.id || myId || active?.champion?.id || null
523
+ const lcu = snap?.lcu || {}
524
+ const canScan = !!lcu.in_game || lcu.phase === 'InProgress' || lcu.phase === 'Reconnect'
525
+
526
+ const runScan = async (championOverride) => {
527
+ if (scanningRef.current) return
528
+ scanningRef.current = true
529
+ setScanning(true)
530
+ setScanError('')
531
+ try {
532
+ const body = { champion: championOverride || scanChampionId || undefined }
533
+ const data = await post('/scan', body)
534
+ if (!data.ok) {
535
+ setScanError(data.error || '识别失败')
536
+ setDetected([])
537
+ setEvals([])
538
+ return
539
+ }
540
+ setDetected(data.matches || [])
541
+ setEvals(data.evaluations || [])
542
+ setScanAt(data.at || Date.now() / 1000)
543
+ lastScanRef.current = data.at || Date.now() / 1000
544
+ } catch (error) {
545
+ setScanError(String(error?.message || error))
546
+ } finally {
547
+ scanningRef.current = false
548
+ setScanning(false)
549
+ }
550
+ }
551
+ scanRef.current = runScan
552
+
553
+ useEffect(() => {
554
+ if (!autoScan || !canScan || tab !== 'augment') return
555
+ const timer = setInterval(() => {
556
+ if (!scanningRef.current) scanRef.current?.(scanChampionId)
557
+ }, 6000)
558
+ return () => clearInterval(timer)
559
+ }, [autoScan, canScan, scanChampionId, tab])
560
+
561
+ const doSearch = async () => {
562
+ const q = search.trim()
563
+ if (!q) return
564
+ setSearchBusy(true)
565
+ setSearchError('')
566
+ setSearchEmpty(false)
567
+ try {
568
+ const data = await get(`/champions?q=${encodeURIComponent(q)}&limit=10`)
569
+ setResults(data.champions || [])
570
+ setSearchEmpty(!data.champions?.length)
571
+ } catch (error) {
572
+ setSearchError(String(error?.message || error))
573
+ } finally {
574
+ setSearchBusy(false)
575
+ }
576
+ }
577
+
578
+ const chooseResult = async champion => {
579
+ setSearchBusy(true)
580
+ setSearchError('')
581
+ setSearchEmpty(false)
582
+ try {
583
+ const data = await get(`/champion?champion=${champion.id}&top=5`)
584
+ setPreview(data.summary)
585
+ setTab('champ')
586
+ setResults([])
587
+ setSearch('')
588
+ } catch (error) {
589
+ setSearchError(String(error?.message || error))
590
+ } finally {
591
+ setSearchBusy(false)
592
+ }
593
+ }
594
+
595
+ const resetPreview = () => {
596
+ setPreview(null)
597
+ setTab('champ')
598
+ }
599
+
600
+ const previewBench = async item => {
601
+ setPreview(item)
602
+ setTab('champ')
603
+ try {
604
+ const data = await get(`/champion?champion=${item.champion.id}&top=5`)
605
+ setPreview(data.summary)
606
+ } catch {
607
+ // Keep the snapshot's top-three summary if the follow-up fails.
608
+ }
609
+ }
610
+
611
+ const toggleService = async () => {
612
+ if (serviceBusy || serviceOn === null) return
613
+ const turningOff = !!serviceOn
614
+ setServiceBusy(true)
615
+ setServiceError('')
616
+ try {
617
+ const data = turningOff
618
+ ? await controlPost('/stop', 15000)
619
+ : await controlPost('/start', 75000)
620
+ if (turningOff) {
621
+ setServiceOn(false)
622
+ setSnap(null)
623
+ setOverlayOn(false)
624
+ setDetected([])
625
+ setEvals([])
626
+ setScanError('')
627
+ if (data.running) throw new Error(data.error || '服务关闭失败')
628
+ } else if (data.running || data.starting) {
629
+ setServiceOn(true)
630
+ } else {
631
+ throw new Error(data.error || '服务启动失败')
632
+ }
633
+ } catch (error) {
634
+ setServiceError(String(error?.message || error))
635
+ try {
636
+ const status = await controlGet('/status', 4000)
637
+ setServiceOn(!!status.running)
638
+ } catch { /* keep previous state */ }
639
+ } finally {
640
+ setServiceBusy(false)
641
+ }
642
+ }
643
+
644
+ const toggleOverlay = async () => {
645
+ if (overlayBusy) return
646
+ if (!serviceOn) {
647
+ setOverlayError('请先启动本地服务,再打开桌面图标')
648
+ return
649
+ }
650
+ const turningOff = !!overlayOn
651
+ setOverlayBusy(true)
652
+ setOverlayError('')
653
+ try {
654
+ const data = turningOff
655
+ ? await post('/overlay/stop', { persist: true }, 15000)
656
+ : await post('/overlay/start', { persist: true }, 25000)
657
+ if (turningOff) {
658
+ if (data.running) throw new Error(data.note || '图标仍在运行')
659
+ setOverlayOn(false)
660
+ } else {
661
+ if (!data.running) throw new Error(data.note || '图标启动失败')
662
+ setOverlayOn(true)
663
+ }
664
+ } catch (error) {
665
+ setOverlayError(String(error?.message || error))
666
+ try {
667
+ const status = await get('/overlay/status', 4000)
668
+ setOverlayOn(!!status.running)
669
+ } catch { /* keep previous state */ }
670
+ } finally {
671
+ setOverlayBusy(false)
672
+ }
673
+ }
674
+
675
+ const meta = snap?.meta || {}
676
+ const bench = snap?.bench || []
677
+ const me = snap?.my_champion || null
678
+ const augmentName = active?.champion?.name || '等待英雄'
679
+ const recommendations = active?.top_augments || []
680
+ const scanChampionName = me?.champion?.name || augmentName
681
+ const phase = lcu.phase || 'Disconnected'
682
+ const phaseLabel = {
683
+ ChampSelect: '选人阶段', InProgress: '对局中', Reconnect: '重连中',
684
+ Lobby: '大厅', None: '空闲', Disconnected: '未连接', EndOfGame: '对局结束',
685
+ }[phase] || phase
686
+
687
+ const serviceSwitch = h('button', {
688
+ type: 'button',
689
+ role: 'switch',
690
+ 'aria-checked': !!serviceOn,
691
+ 'aria-label': '启动或关闭本地服务',
692
+ title: '启动/关闭本地 Python 服务(不会自动启动)',
693
+ disabled: serviceBusy || serviceOn === null,
694
+ onClick: toggleService,
695
+ style: {
696
+ ...S.chip,
697
+ fontFamily: 'inherit', fontSize: 11.5,
698
+ cursor: serviceBusy || serviceOn === null ? 'wait' : 'pointer',
699
+ background: serviceOn ? 'rgba(47,158,98,.12)' : 'transparent',
700
+ borderColor: serviceOn ? '#2F9E62' : 'var(--dsw-alias-border-l2, rgba(128,128,128,.3))',
701
+ opacity: serviceOn === null ? .6 : 1,
702
+ },
703
+ },
704
+ h('span', {
705
+ style: {
706
+ width: 7, height: 7, borderRadius: '50%',
707
+ background: serviceOn ? '#2F9E62' : '#8A8A8A',
708
+ },
709
+ }),
710
+ `服务 ${serviceBusy ? '…' : serviceOn === null ? '…' : serviceOn ? '开' : '关'}`)
711
+
712
+ if (serviceOn === false) {
713
+ return h('div', { style: S.page },
714
+ h('div', { style: S.header },
715
+ h('div', null,
716
+ h('h1', { style: S.title }, '海斗助手'),
717
+ h('div', { style: S.sub }, 'ARAM: Mayhem · 按需启动')),
718
+ serviceSwitch),
719
+ h('div', { style: S.card, padding: 18 },
720
+ h('div', { style: { fontWeight: 650, fontSize: 16, marginBottom: 6 } }, '本地服务未启动'),
721
+ h('div', { style: S.muted }, '服务不会随插件自动启动,也不会一直占用后台。点击「启动服务」后才加载英雄、海克斯、出装和 LCU 数据;不用时请关闭服务。'),
722
+ h('div', { style: { ...S.row, gap: 8, marginTop: 12, flexWrap: 'wrap' } },
723
+ h('button', {
724
+ type: 'button',
725
+ style: { ...S.primary, opacity: serviceBusy ? .55 : 1 },
726
+ disabled: serviceBusy,
727
+ onClick: toggleService,
728
+ }, serviceBusy ? '启动中…' : '启动服务')),
729
+ serviceError ? h('div', { style: { ...S.error, marginTop: 10 } }, serviceError) : null,
730
+ h('div', { style: { ...S.muted, marginTop: 10 } },
731
+ '启动后仍可在右上角关闭;桌面图标需要单独打开,服务关闭时会一并停止。')),
732
+ h('div', { style: S.muted },
733
+ '数据依赖本地 Python 服务(127.0.0.1:8123)。'))
734
+ }
735
+
736
+ if (!snap && serviceOn === null) {
737
+ return h('div', { style: { ...S.page, justifyContent: 'center', alignItems: 'center', opacity: .75 }, role: 'status' },
738
+ '正在检测本地服务…')
739
+ }
740
+
741
+ if (!snap && loadError) {
742
+ if (!serviceWait) {
743
+ return h('div', { style: { ...S.page, justifyContent: 'center', alignItems: 'center', opacity: .7 }, role: 'status' },
744
+ '服务已启动,正在连接数据…')
745
+ }
746
+ return h('div', { style: S.page },
747
+ h('div', { style: S.header },
748
+ h('div', null, h('h1', { style: S.title }, '海斗助手'), h('div', { style: S.sub }, 'ARAM: Mayhem · 服务已启动但数据不可用')),
749
+ serviceSwitch),
750
+ h('div', { style: S.error, role: 'alert' },
751
+ h('div', { style: { fontWeight: 650, marginBottom: 4 } }, '本地服务已启动,但数据请求失败'),
752
+ h('div', null, loadError),
753
+ h('div', { style: { ...S.muted, marginTop: 6 } }, '可以先关闭服务,再重新启动;也可以检查 Python 日志 logs\\dsh-service.log。'),
754
+ h('button', { style: { ...S.btn, marginTop: 8 }, onClick: toggleService }, '关闭服务')),
755
+ h('div', { style: { ...S.card, padding: 16, marginTop: 8 } },
756
+ h('div', { style: { fontWeight: 650, marginBottom: 6 } }, '仍无法启动时'),
757
+ h('div', { style: S.muted }, '在插件目录运行:python scripts/dsh_service.py --port 8123 --root .'),
758
+ h('div', { style: { ...S.muted, marginTop: 4 } }, '或检查 Python 依赖:python -m pip install -r requirements-dsh.txt')))
759
+ }
760
+ if (!snap) {
761
+ return h('div', { style: { ...S.page, justifyContent: 'center', alignItems: 'center', opacity: .65 }, role: 'status' }, '正在连接海斗助手服务…')
762
+ }
763
+
764
+ return h('div', { style: S.page },
765
+ h('div', { style: S.header },
766
+ h('div', null,
767
+ h('h1', { style: S.title }, '海斗助手'),
768
+ h('div', { style: S.sub }, `ARAM: Mayhem · ${meta.patch || '--'} · ${meta.source || '本地数据'}`)),
769
+ h('div', { style: { ...S.row, gap: 7, flexWrap: 'wrap', justifyContent: 'flex-end' } },
770
+ h(Chip, { tone: 'gold' }, `数据 ${meta.patch || '--'}`),
771
+ h(Chip, { tone: lcu.connected ? 'green' : 'normal', title: lcu.error || undefined },
772
+ `LCU ${lcu.connected ? '已连接' : '未连接'}`),
773
+ h(Chip, null, phaseLabel),
774
+ serviceSwitch,
775
+ h('button', {
776
+ type: 'button',
777
+ role: 'switch',
778
+ 'aria-checked': !!overlayOn,
779
+ 'aria-label': '显示屏幕置顶桌面图标',
780
+ title: serviceOn ? '显示或隐藏屏幕置顶的海斗助手图标' : '请先启动本地服务',
781
+ disabled: overlayBusy || overlayOn === null || !serviceOn,
782
+ onClick: toggleOverlay,
783
+ style: {
784
+ ...S.chip,
785
+ fontFamily: 'inherit', fontSize: 11.5,
786
+ cursor: overlayBusy || overlayOn === null || !serviceOn ? 'not-allowed' : 'pointer',
787
+ background: overlayOn ? 'rgba(47,158,98,.12)' : 'transparent',
788
+ borderColor: overlayOn ? '#2F9E62' : 'var(--dsw-alias-border-l2, rgba(128,128,128,.3))',
789
+ opacity: overlayOn === null || !serviceOn ? .6 : 1,
790
+ },
791
+ },
792
+ h('span', {
793
+ style: {
794
+ width: 7, height: 7, borderRadius: '50%',
795
+ background: overlayOn ? '#2F9E62' : '#8A8A8A',
796
+ },
797
+ }),
798
+ `桌面图标 ${overlayBusy || overlayOn === null ? '…' : overlayOn ? '开' : '关'}`),
799
+ h('input', {
800
+ style: S.input, value: search, placeholder: '搜索英雄,如 亚索',
801
+ 'aria-label': '搜索英雄',
802
+ onChange: event => {
803
+ setSearch(event.target.value)
804
+ setSearchError('')
805
+ setSearchEmpty(false)
806
+ },
807
+ onKeyDown: event => { if (event.key === 'Enter') doSearch() },
808
+ }),
809
+ h('button', { style: S.btn, onClick: doSearch, disabled: searchBusy }, searchBusy ? '…' : '查询'))),
810
+
811
+ loadError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, `服务暂时不可用:${loadError}`) : null,
812
+ serviceError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, `本地服务:${serviceError}`) : null,
813
+ overlayError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, `桌面图标:${overlayError}`) : null,
814
+ !lcu.connected && lcu.error
815
+ ? h('div', { style: { ...S.muted, flexShrink: 0 } }, `LCU:${lcu.error}。仍可搜索英雄;进入对局后可手动扫描。`)
816
+ : null,
817
+ lcu.connected && !lcu.is_mayhem && lcu.queue_id
818
+ ? h('div', { style: S.banner }, `当前队列:${lcu.queue_name || lcu.queue_id}。海斗统计仅供参考。`)
819
+ : null,
820
+ searchError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, searchError) : null,
821
+ searchEmpty
822
+ ? h('div', { style: { ...S.muted, flexShrink: 0 } }, '没有找到匹配的英雄。')
823
+ : null,
824
+ results.length
825
+ ? h('div', { style: { ...S.card, padding: 10, flexShrink: 0 } },
826
+ h('div', { style: { ...S.muted, marginBottom: 6 } }, '搜索结果'),
827
+ h('div', { style: S.wrap },
828
+ results.map(item => h('button', {
829
+ key: item.id, style: S.btn, onClick: () => chooseResult(item),
830
+ }, `${item.name} ${item.tier} ${item.win_rate_label}`))))
831
+ : null,
832
+
833
+ h('div', {
834
+ style: { ...S.row, gap: 3, borderBottom: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))', flexShrink: 0 },
835
+ role: 'tablist', 'aria-label': '海斗助手页签',
836
+ },
837
+ TABS.map(item => h('button', {
838
+ key: item.id, style: S.tab(tab === item.id), onClick: () => setTab(item.id),
839
+ role: 'tab', 'aria-selected': tab === item.id, type: 'button',
840
+ }, item.label, item.id === 'augment' && evals.length ? ' ●' : ''))),
841
+
842
+ h('div', { style: S.body },
843
+ tab === 'champ'
844
+ ? h(React.Fragment, null,
845
+ active
846
+ ? h(HeroCard, { summary: active, preview: !!preview, onReset: resetPreview })
847
+ : h('div', { style: { ...S.card, padding: 20, textAlign: 'center' } },
848
+ h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '等待选人'),
849
+ h('div', { style: S.muted }, '连接客户端后自动读取你的英雄;也可以在上方搜索英雄查看数据。')),
850
+ bench.length
851
+ ? h('div', null,
852
+ h('div', { style: S.section },
853
+ h('span', { style: S.sectionTitle }, '备战席'),
854
+ h('span', { style: S.muted }, `${bench.length} 位可选 · 点击预览`)),
855
+ h('div', { style: S.benchGrid },
856
+ bench.map(item => h(BenchRow, {
857
+ key: item.champion.id, item, my: me, active: preview?.champion?.id === item.champion.id,
858
+ onClick: () => previewBench(item),
859
+ }))))
860
+ : null,
861
+ h('div', { style: S.muted },
862
+ `数据快照:${meta.matches ? Number(meta.matches).toLocaleString('en-US') + ' 场' : '--'} · 更新 ${meta.updated_label || '--'}。`
863
+ + ' 统计为部分对局样本,胜率与选取是相关关系。'))
864
+ : tab === 'augment'
865
+ ? h(React.Fragment, null,
866
+ h('div', { style: { ...S.card, padding: '9px 11px' } },
867
+ h('div', { style: { ...S.row, gap: 9, flexWrap: 'wrap' } },
868
+ h(Avatar, { name: augmentName, size: 32, tier: active?.champion?.tier }),
869
+ h('div', { style: { flex: 1, minWidth: 130 } },
870
+ h('div', { style: { fontWeight: 650 } }, augmentName),
871
+ h('div', { style: S.muted }, active
872
+ ? `${active.champion.title || ''} · 胜率 ${active.champion.win_rate_label} · ${active.champion.tier}`
873
+ : '先选择英雄,或等待 LCU 选人')),
874
+ h('label', {
875
+ style: { ...S.row, gap: 5, fontSize: 11.5, opacity: .75, cursor: 'pointer' },
876
+ title: '仅在本页签打开时,每 6 秒扫描一次游戏客户区',
877
+ },
878
+ h('input', {
879
+ type: 'checkbox', checked: autoScan,
880
+ onChange: event => setAutoScan(event.target.checked),
881
+ }), '自动扫描 6s'),
882
+ h('button', {
883
+ style: { ...S.primary, opacity: scanning ? .55 : 1 },
884
+ disabled: scanning,
885
+ onClick: () => runScan(scanChampionId),
886
+ }, scanning ? '识别中…' : '立即扫描'))),
887
+ scanError ? h('div', { style: S.error, role: 'alert', 'aria-live': 'polite' }, scanError) : null,
888
+ !canScan
889
+ ? h('div', { style: { ...S.card, padding: 16, ...S.muted } },
890
+ '进入对局后,海克斯三选一出现时可扫描当前卡片;即使 LCU 未连接,也可以手动扫描。'
891
+ + '建议使用无边框/窗口化;首次 OCR 会加载本地模型,只读取游戏客户区。')
892
+ : null,
893
+ evals.length
894
+ ? h(React.Fragment, null,
895
+ h('div', { style: S.section },
896
+ h('span', { style: S.sectionTitle }, `本局识别 · ${scanChampionName}`),
897
+ h('span', { style: S.muted }, `${evals.length} 张 · 按推荐度排序${scanAt ? ' · ' + new Date(scanAt * 1000).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' }) : ''}`)),
898
+ evals.map(item => h(Candidate, { key: 'scan-' + item.augment.id, item })),
899
+ h('div', { style: S.muted },
900
+ '本局识别按当前客户端英雄评分;推荐分 = 英雄专属胜率(向全服收缩)+ 全服强度。'))
901
+ : detected.length
902
+ ? h('div', { style: { ...S.card, padding: 12 } },
903
+ h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '识别到卡片'),
904
+ h('div', { style: S.wrap }, detected.map(item => h(Chip, { key: item.id }, `${item.name} ${Math.round((item.confidence || 0) * 100)}%`))))
905
+ : null,
906
+ h('div', { style: S.section },
907
+ h('span', { style: S.sectionTitle }, `版本推荐 · ${augmentName}`),
908
+ h('span', { style: S.muted }, recommendations.length
909
+ ? `${recommendations.length} 个 · 英雄专属 + 全服样本`
910
+ : '暂无英雄推荐')),
911
+ recommendations.length
912
+ ? recommendations.map(item => h(Candidate, { key: 'rec-' + item.augment.id, item }))
913
+ : h('div', { style: { ...S.card, padding: 18, textAlign: 'center' } },
914
+ h('div', { style: { fontWeight: 650, marginBottom: 5 } }, active ? '暂无该英雄的推荐' : '还没有选择英雄'),
915
+ h('div', { style: S.muted }, active
916
+ ? '该英雄在本版本没有足够的海克斯样本。'
917
+ : '等待 LCU 选人,或在上方搜索英雄后查看推荐。')),
918
+ h('div', { style: S.muted },
919
+ '推荐分 = 英雄专属胜率(向全服收缩)+ 全服强度;低样本会被压低。'
920
+ + ' 差值单位为百分点。'))
921
+ : h(React.Fragment, null,
922
+ active
923
+ ? h('div', { style: { ...S.row, gap: 7, marginBottom: 2 } },
924
+ h(Avatar, { name: active.champion.name, size: 30, tier: active.champion.tier }),
925
+ h('span', { style: { fontWeight: 700 } }, active.champion.name),
926
+ h(Tier, { tier: active.champion.tier }),
927
+ preview ? h('button', { style: { ...S.btn, padding: '2px 8px', fontSize: 11 }, onClick: resetPreview }, '返回我的英雄') : null)
928
+ : h('div', { style: { ...S.card, padding: 18, textAlign: 'center' } },
929
+ h('div', { style: { fontWeight: 650, marginBottom: 5 } }, '还没有选择英雄'),
930
+ h('div', { style: S.muted }, '等待 LCU 选人,或在上方搜索英雄后查看出装。')),
931
+ active ? h(BuildView, { summary: active }) : null)),
932
+
933
+ h('div', {
934
+ style: {
935
+ ...S.row, justifyContent: 'space-between', gap: 8, flexWrap: 'wrap',
936
+ borderTop: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.2))',
937
+ paddingTop: 8, flexShrink: 0, fontSize: 11, opacity: .62,
938
+ },
939
+ },
940
+ h('span', null, `数据 ${meta.patch || '--'} · ${meta.source || '--'} · ${meta.license || '--'}`),
941
+ h('span', null, `服务 127.0.0.1:8123${lcu.summoner ? ' · ' + lcu.summoner : ''}`)))
942
+ }
943
+
944
+ function Icon({ size = 20, active = false }) {
945
+ return h('svg', {
946
+ width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
947
+ stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round',
948
+ style: { display: 'block', color: active ? 'var(--dsw-alias-brand-primary)' : 'currentColor' },
949
+ 'aria-hidden': true, focusable: false,
950
+ },
951
+ h('path', { d: 'M12 2.6l7.2 4.1v8.1L12 19l-7.2-4.2V6.7L12 2.6z' }),
952
+ h('path', { d: 'M12 7.2l3.4 2v4.1L12 15.5l-3.4-2.2V9.2L12 7.2z', opacity: 0.55 }),
953
+ h('path', { d: 'M8.4 19.1L12 21.5l3.6-2.4' }))
954
+ }
955
+
956
+ return {
957
+ inject: ['slots'],
958
+ apply(ctx) {
959
+ ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
960
+ name: 'sidebar.panellist',
961
+ id: 'aram-mayhem',
962
+ order: 25,
963
+ label: () => '海斗助手',
964
+ }, Icon))
965
+
966
+ ctx.slots.inject('main', () => ctx.slots.register({
967
+ name: 'main',
968
+ key: 'aram-mayhem',
969
+ }, Page))
970
+ },
971
+ }
972
+ },
973
+ })