dsh-clash-subscription 0.2.3 → 0.4.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/README.md +132 -167
- package/client.js +223 -29
- package/index.js +687 -83
- package/lib/cn-cidr.js +5526 -0
- package/lib/core.js +323 -85
- package/lib/corefetch.js +618 -0
- package/lib/discovery.js +31 -73
- package/lib/geo.js +130 -0
- package/lib/routes.js +47 -3
- package/lib/subscription.js +196 -0
- package/lib/vendored.js +167 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +8 -3
- package/vendor/SHA256SUMS.json +7 -0
- package/vendor/mihomo.exe.gz +0 -0
package/client.js
CHANGED
|
@@ -10,15 +10,24 @@ const en = {
|
|
|
10
10
|
title: 'Subscription',
|
|
11
11
|
header: 'Clash subscription proxy',
|
|
12
12
|
close: 'Close',
|
|
13
|
-
subscriptionLabel: 'Import
|
|
13
|
+
subscriptionLabel: 'Import links',
|
|
14
14
|
subscriptionHint:
|
|
15
|
-
'
|
|
16
|
-
subscriptionPlaceholder: 'https://…/
|
|
17
|
-
probe: 'Check
|
|
15
|
+
'One subscription per line. A bare https:// URL or a clash://install-config?url=… import link both work; put a name in front of a URL to label it. There is no default: the plugin never reads another client’s configuration.',
|
|
16
|
+
subscriptionPlaceholder: 'https://…/subscribe?token=…\nbackup https://…/subscribe?token=…',
|
|
17
|
+
probe: 'Check all links',
|
|
18
18
|
probing: 'Checking…',
|
|
19
|
-
probeOk: '
|
|
19
|
+
probeOk: 'All {total} subscriptions reachable: {count} nodes, {size} KB.',
|
|
20
|
+
probePartial: '{reachable}/{total} subscriptions reachable — see the rows below.',
|
|
20
21
|
probeFailed: 'Check failed: {reason}',
|
|
21
|
-
probeNeedsSave: 'Save first — this page writes the
|
|
22
|
+
probeNeedsSave: 'Save first — this page writes the links, the running core reads the saved ones.',
|
|
23
|
+
subscriptions: 'Subscriptions',
|
|
24
|
+
subscriptionCount: '{count} configured',
|
|
25
|
+
subscriptionRow: '{name}',
|
|
26
|
+
subscriptionNodes: '{count} nodes',
|
|
27
|
+
subscriptionPending: 'not fetched',
|
|
28
|
+
subscriptionUpdated: 'updated {time}',
|
|
29
|
+
refreshOne: 'Refresh this one',
|
|
30
|
+
noSubscriptions: 'No subscription yet — add one above.',
|
|
22
31
|
routing: 'Exit node',
|
|
23
32
|
routingHint: 'The node foreign traffic leaves through. Domestic sites stay direct either way.',
|
|
24
33
|
autoSelect: 'Automatic (lowest latency, working nodes only)',
|
|
@@ -52,10 +61,19 @@ const en = {
|
|
|
52
61
|
proxyDomainsHint: 'Comma-separated domain suffixes that must always use the node, even if they resolve to a Chinese address.',
|
|
53
62
|
runtime: 'Runtime',
|
|
54
63
|
corePath: 'Core binary',
|
|
55
|
-
corePathHint: 'Path to a mihomo/
|
|
64
|
+
corePathHint: 'Path to a mihomo/mihomo-compatible executable. Leave empty to use the copy bundled with this plugin.',
|
|
65
|
+
autoFetchCore: 'Fetch a core automatically',
|
|
66
|
+
autoFetchCoreHint: 'When no mihomo binary is present, download a verified private copy on startup instead of waiting for you to press Download.',
|
|
56
67
|
dns: 'DNS servers',
|
|
57
68
|
dnsHint: 'Comma-separated resolvers the core uses for its own lookups.',
|
|
58
69
|
start: 'Start',
|
|
70
|
+
downloadCore: 'Download core',
|
|
71
|
+
downloadingCore: 'Downloading…',
|
|
72
|
+
coreMissing: 'The bundled core could not be unpacked. This platform has no bundled build — download one here, verified against the publisher’s SHA-256.',
|
|
73
|
+
coreProgress: 'Downloading {mb} MB…',
|
|
74
|
+
coreInstalled: 'Core installed: {tag}',
|
|
75
|
+
coreFailed: 'Core download failed: {reason}',
|
|
76
|
+
coreUnsupported: 'No released core build for this platform; set the core binary path instead.',
|
|
59
77
|
stop: 'Stop',
|
|
60
78
|
refresh: 'Refresh subscription',
|
|
61
79
|
save: 'Save',
|
|
@@ -80,15 +98,24 @@ const zh = {
|
|
|
80
98
|
title: '订阅',
|
|
81
99
|
header: 'Clash 订阅代理',
|
|
82
100
|
close: '关闭',
|
|
83
|
-
subscriptionLabel: '
|
|
101
|
+
subscriptionLabel: '订阅链接',
|
|
84
102
|
subscriptionHint:
|
|
85
|
-
'
|
|
86
|
-
subscriptionPlaceholder: 'https://…/
|
|
87
|
-
probe: '
|
|
103
|
+
'一行一条订阅。裸 https:// 地址和 clash://install-config?url=… 一键导入链接都可以;想在面板里有名字,就在地址前加一个名字。没有默认值:插件不会读取其他客户端的配置。',
|
|
104
|
+
subscriptionPlaceholder: 'https://…/subscribe?token=…\n备用 https://…/subscribe?token=…',
|
|
105
|
+
probe: '检测全部',
|
|
88
106
|
probing: '检测中…',
|
|
89
|
-
probeOk: '
|
|
107
|
+
probeOk: '全部 {total} 条可达:共 {count} 个节点,{size} KB。',
|
|
108
|
+
probePartial: '{reachable}/{total} 条可达——看下面的逐条结果。',
|
|
90
109
|
probeFailed: '检测失败:{reason}',
|
|
91
110
|
probeNeedsSave: '先保存——这个面板写的是配置,跑着的内核读的是已保存的那份。',
|
|
111
|
+
subscriptions: '订阅列表',
|
|
112
|
+
subscriptionCount: '已配置 {count} 条',
|
|
113
|
+
subscriptionRow: '{name}',
|
|
114
|
+
subscriptionNodes: '{count} 个节点',
|
|
115
|
+
subscriptionPending: '未拉到节点',
|
|
116
|
+
subscriptionUpdated: '更新于 {time}',
|
|
117
|
+
refreshOne: '刷新这一条',
|
|
118
|
+
noSubscriptions: '还没有订阅——在上面的输入框里添一条。',
|
|
92
119
|
routing: '出口节点',
|
|
93
120
|
routingHint: '外网流量从这个节点出去;国内站点无论选哪个都保持直连。',
|
|
94
121
|
autoSelect: '自动(选延迟最低的可用节点)',
|
|
@@ -121,10 +148,19 @@ const zh = {
|
|
|
121
148
|
proxyDomainsHint: '逗号分隔的域名后缀,即使解析到中国 IP 也走节点。',
|
|
122
149
|
runtime: '运行时',
|
|
123
150
|
corePath: '内核程序',
|
|
124
|
-
corePathHint: 'mihomo
|
|
151
|
+
corePathHint: 'mihomo 兼容内核的可执行文件路径。留空则使用插件自带的那个。',
|
|
152
|
+
autoFetchCore: '自动获取内核',
|
|
153
|
+
autoFetchCoreHint: '机器上没有 mihomo 时,启动时自动下载一份经过校验的私有内核,不用手动点下载。',
|
|
125
154
|
dns: 'DNS 服务器',
|
|
126
155
|
dnsHint: '逗号分隔,内核自己解析时使用。',
|
|
127
156
|
start: '启动',
|
|
157
|
+
downloadCore: '下载内核',
|
|
158
|
+
downloadingCore: '下载中…',
|
|
159
|
+
coreMissing: '自带内核解压失败,或本平台没有自带构建。可以在这里下载一个——会用发布页的 SHA-256 校验,通过才使用。',
|
|
160
|
+
coreProgress: '正在下载 {mb} MB…',
|
|
161
|
+
coreInstalled: '内核已安装:{tag}',
|
|
162
|
+
coreFailed: '内核下载失败:{reason}',
|
|
163
|
+
coreUnsupported: '本平台没有可用的内核构建,请改为手动指定内核路径。',
|
|
128
164
|
stop: '停止',
|
|
129
165
|
refresh: '刷新订阅',
|
|
130
166
|
save: '保存',
|
|
@@ -160,6 +196,36 @@ function fill(template, values) {
|
|
|
160
196
|
/** Read the row form's saved values as a flat object. */
|
|
161
197
|
const readValues = (value) => (value !== null && typeof value === 'object' ? { ...value } : {})
|
|
162
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Split the multi-line subscription field into display rows.
|
|
201
|
+
*
|
|
202
|
+
* A panel function, deliberately not a second parser: the host owns URL validation and
|
|
203
|
+
* duplicate removal, and duplicating that here would let the two disagree. This only
|
|
204
|
+
* needs enough to draw "name — URL" rows before the first status poll lands.
|
|
205
|
+
*
|
|
206
|
+
* @param text - the field value.
|
|
207
|
+
* @returns `{ name, provider, url }` rows.
|
|
208
|
+
*/
|
|
209
|
+
function parseLines(text) {
|
|
210
|
+
const rows = []
|
|
211
|
+
for (const line of String(text ?? '').split(/\r?\n/)) {
|
|
212
|
+
const trimmed = line.trim()
|
|
213
|
+
if (trimmed === '' || trimmed.startsWith('#') || trimmed.startsWith('//')) continue
|
|
214
|
+
const split = trimmed.match(/^(\S+)\s+(\S.*)$/)
|
|
215
|
+
const named = split !== null && !split[1].includes('://') && split[2].includes('://')
|
|
216
|
+
const name = named ? split[1] : ''
|
|
217
|
+
const url = named ? split[2].trim() : trimmed
|
|
218
|
+
const index = rows.length
|
|
219
|
+
rows.push({
|
|
220
|
+
name: name !== '' ? name : `订阅 ${index + 1}`,
|
|
221
|
+
provider: `sub${index}`,
|
|
222
|
+
url,
|
|
223
|
+
index,
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
return rows
|
|
227
|
+
}
|
|
228
|
+
|
|
163
229
|
/** Page styles, registered once per mount and removed with it. */
|
|
164
230
|
const CSS = `
|
|
165
231
|
.clxp { display: flex; flex-direction: column; gap: 14px; font-size: 13px; line-height: 1.5; color: var(--dsh-text-primary, #1f2328); }
|
|
@@ -179,8 +245,15 @@ const CSS = `
|
|
|
179
245
|
.clxp-ok { color: #1a7f37; font-size: 12px; margin: 0; }
|
|
180
246
|
.clxp input[type="text"], .clxp input[type="number"], .clxp select { font: inherit; padding: 5px 8px; border: 1px solid var(--dsh-border-default, #d8dee4); border-radius: 6px; background: var(--dsh-surface-default, #fff); color: inherit; min-width: 0; }
|
|
181
247
|
.clxp input:focus, .clxp select:focus { outline: 2px solid var(--dsh-accent, #0969da); outline-offset: -1px; }
|
|
182
|
-
.clxp-inline { display: flex; gap: 6px; align-items:
|
|
183
|
-
.clxp-inline > input { flex: 1 1 auto; }
|
|
248
|
+
.clxp-inline { display: flex; gap: 6px; align-items: flex-start; }
|
|
249
|
+
.clxp-inline > input, .clxp-inline > textarea { flex: 1 1 auto; }
|
|
250
|
+
.clxp-field.wide { grid-column: 1 / -1; }
|
|
251
|
+
.clxp-pre { margin: 0; padding: 6px 8px; border-radius: 6px; background: var(--dsh-surface-subtle, #f6f8fa); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
|
|
252
|
+
.clxp-subs { display: flex; flex-direction: column; gap: 6px; }
|
|
253
|
+
.clxp-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--dsh-border-muted, #eaeef2); border-radius: 6px; }
|
|
254
|
+
.clxp-sub .clxp-node-name { flex: 1 1 140px; }
|
|
255
|
+
.clxp-probe { display: flex; flex-direction: column; gap: 2px; }
|
|
256
|
+
.clxp-probe > p { margin: 0; }
|
|
184
257
|
.clxp button { font: inherit; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--dsh-border-default, #d8dee4); background: var(--dsh-surface-default, #fff); color: inherit; cursor: pointer; }
|
|
185
258
|
.clxp button:hover:not(:disabled) { background: var(--dsh-surface-subtle, #f6f8fa); }
|
|
186
259
|
.clxp button:disabled { opacity: 0.55; cursor: default; }
|
|
@@ -209,7 +282,7 @@ function sections(t) {
|
|
|
209
282
|
id: 'subscription',
|
|
210
283
|
title: t('title'),
|
|
211
284
|
fields: [
|
|
212
|
-
{ key: '
|
|
285
|
+
{ key: 'subscriptionUrls', kind: 'textarea', label: t('subscriptionLabel'), hint: t('subscriptionHint'), placeholder: t('subscriptionPlaceholder'), probe: true },
|
|
213
286
|
],
|
|
214
287
|
},
|
|
215
288
|
{
|
|
@@ -231,6 +304,7 @@ function sections(t) {
|
|
|
231
304
|
{ key: 'proxyDomains', kind: 'text', label: t('proxyDomains'), hint: t('proxyDomainsHint'), placeholder: 'openai.com, githubusercontent.com' },
|
|
232
305
|
{ key: 'dnsServers', kind: 'text', label: t('dns'), hint: t('dnsHint'), placeholder: '223.5.5.5, 119.29.29.29' },
|
|
233
306
|
{ key: 'corePath', kind: 'text', label: t('corePath'), hint: t('corePathHint'), placeholder: 'C:\\path\\to\\mihomo.exe' },
|
|
307
|
+
{ key: 'autoFetchCore', kind: 'switch', label: t('autoFetchCore'), hint: t('autoFetchCoreHint') },
|
|
234
308
|
],
|
|
235
309
|
},
|
|
236
310
|
]
|
|
@@ -249,6 +323,12 @@ function sections(t) {
|
|
|
249
323
|
function Panel(props) {
|
|
250
324
|
const { t, draft, live, delays, busy, message, probe, saving, dirty, open, editable } = props
|
|
251
325
|
const nodes = Array.isArray(live?.nodes) ? live.nodes : []
|
|
326
|
+
const subscriptions = Array.isArray(live?.subscriptions) && live.subscriptions.length > 0
|
|
327
|
+
? live.subscriptions
|
|
328
|
+
: // Before the first status poll resolves, fall back to the draft's own lines so the
|
|
329
|
+
// list does not flash "no subscription" on a configured profile.
|
|
330
|
+
parseLines(editable ? draft.subscriptionUrls : live?.config?.subscriptionUrls)
|
|
331
|
+
const providers = Array.isArray(live?.providers) ? live.providers : []
|
|
252
332
|
const running = live?.running === true
|
|
253
333
|
const routingOn = live?.routing === true
|
|
254
334
|
const [expanded, setExpanded] = useState({})
|
|
@@ -262,10 +342,15 @@ function Panel(props) {
|
|
|
262
342
|
|
|
263
343
|
const field = (spec) => {
|
|
264
344
|
const value = editable ? draft[spec.key] : live?.config?.[spec.key]
|
|
345
|
+
// The multi-line subscription editor needs the full width: a grid cell clips both a
|
|
346
|
+
// long URL and the "one per line" shape the field is asking for.
|
|
347
|
+
const wide = spec.kind === 'textarea'
|
|
265
348
|
if (!editable) {
|
|
266
|
-
return h('div', { className:
|
|
349
|
+
return h('div', { className: `clxp-field${wide ? ' wide' : ''}`, key: spec.key }, [
|
|
267
350
|
h('span', { key: 'l', className: 'clxp-label' }, spec.label),
|
|
268
|
-
|
|
351
|
+
wide
|
|
352
|
+
? h('pre', { key: 'v', className: 'clxp-pre' }, value === '' || value === undefined ? '—' : String(value))
|
|
353
|
+
: h('code', { key: 'v' }, value === '' || value === undefined ? '—' : String(value)),
|
|
269
354
|
])
|
|
270
355
|
}
|
|
271
356
|
const control =
|
|
@@ -279,21 +364,61 @@ function Panel(props) {
|
|
|
279
364
|
spec.options.map((option) => h('option', { key: option.value, value: option.value }, option.label)))
|
|
280
365
|
: spec.kind === 'number'
|
|
281
366
|
? h('input', { type: 'number', value: value ?? 0, min: spec.min, max: spec.max, step: spec.step, disabled: saving, onChange: (event) => props.onEdit(spec.key, event.target.value === '' ? '' : Number(event.target.value)) })
|
|
282
|
-
: h('
|
|
283
|
-
|
|
284
|
-
|
|
367
|
+
: h('textarea', {
|
|
368
|
+
rows: 4,
|
|
369
|
+
value: value ?? '',
|
|
370
|
+
placeholder: spec.placeholder ?? '',
|
|
371
|
+
disabled: saving,
|
|
372
|
+
spellCheck: false,
|
|
373
|
+
onChange: (event) => props.onEdit(spec.key, event.target.value),
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
return h('div', { className: `clxp-field${wide ? ' wide' : ''}`, key: spec.key }, [
|
|
285
377
|
h('span', { key: 'l', className: 'clxp-label' }, spec.label),
|
|
286
378
|
spec.probe
|
|
287
379
|
? h('div', { key: 'r', className: 'clxp-inline' }, [control, h('button', { key: 'p', type: 'button', disabled: saving || busy === 'probe', onClick: () => void props.onProbe() }, busy === 'probe' ? t('probing') : t('probe'))])
|
|
288
380
|
: control,
|
|
289
381
|
spec.hint !== undefined && spec.kind !== 'switch' ? h('p', { key: 'h', className: 'clxp-hint' }, spec.hint) : null,
|
|
290
|
-
spec.key === '
|
|
291
|
-
? h('p', { key: 'pr', className: probe.ok ? 'clxp-ok' : 'clxp-error', role: 'status' },
|
|
292
|
-
probe.ok ? fill(t('probeOk'), { format: probe.format, count: probe.nodeCount, size: Math.round((probe.bytes ?? 0) / 1024) }) : fill(t('probeFailed'), { reason: probe.error ?? 'unknown' }))
|
|
293
|
-
: null,
|
|
382
|
+
spec.key === 'subscriptionUrls' && probe !== undefined ? probeReport(probe) : null,
|
|
294
383
|
].filter(Boolean))
|
|
295
384
|
}
|
|
296
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Render the multi-subscription probe answer.
|
|
388
|
+
*
|
|
389
|
+
* One line per subscription, because the whole reason to support several is that
|
|
390
|
+
* one of them breaks while the others keep working — a single OK/FAIL hides exactly
|
|
391
|
+
* the case a user needs to see.
|
|
392
|
+
*
|
|
393
|
+
* @param answer - the `/clash-proxy/probe` body.
|
|
394
|
+
* @returns the report element.
|
|
395
|
+
*/
|
|
396
|
+
const probeReport = (answer) => {
|
|
397
|
+
const results = Array.isArray(answer.results) ? answer.results : []
|
|
398
|
+
const headline =
|
|
399
|
+
results.length <= 1
|
|
400
|
+
? answer.ok
|
|
401
|
+
? fill(t('probeOk'), { total: 1, count: answer.nodeCount ?? 0, size: Math.round((answer.bytes ?? 0) / 1024) })
|
|
402
|
+
: fill(t('probeFailed'), { reason: answer.error ?? 'unknown' })
|
|
403
|
+
: answer.ok
|
|
404
|
+
? fill(t('probeOk'), { total: answer.total ?? results.length, count: answer.nodeCount ?? 0, size: Math.round((answer.bytes ?? 0) / 1024) })
|
|
405
|
+
: fill(t('probePartial'), { reachable: answer.reachable ?? 0, total: answer.total ?? results.length })
|
|
406
|
+
return h('div', { key: 'pr', className: 'clxp-probe', role: 'status' }, [
|
|
407
|
+
h('p', { key: 'h', className: answer.ok ? 'clxp-ok' : 'clxp-error' }, headline),
|
|
408
|
+
...results.map((row) =>
|
|
409
|
+
h('p', { key: `r-${row.provider ?? row.url}`, className: row.ok ? 'clxp-note' : 'clxp-error' }, [
|
|
410
|
+
h('span', { key: 'n' }, `${row.name ?? row.url}:`),
|
|
411
|
+
row.ok
|
|
412
|
+
? `${fill(t('subscriptionNodes'), { count: row.nodeCount ?? 0 })},${row.format ?? ''},${Math.round((row.bytes ?? 0) / 1024)} KB`
|
|
413
|
+
: (row.error ?? `the server answered ${row.status}`),
|
|
414
|
+
]),
|
|
415
|
+
),
|
|
416
|
+
...(Array.isArray(answer.errors) && answer.errors.length > 0
|
|
417
|
+
? answer.errors.map((row) => h('p', { key: `e-${row.line}`, className: 'clxp-error' }, `第 ${row.line} 行:${row.reason}`))
|
|
418
|
+
: []),
|
|
419
|
+
])
|
|
420
|
+
}
|
|
421
|
+
|
|
297
422
|
const sectionsList = sections(t)
|
|
298
423
|
|
|
299
424
|
return h('div', { className: 'clxp' }, [
|
|
@@ -314,6 +439,75 @@ function Panel(props) {
|
|
|
314
439
|
]),
|
|
315
440
|
live?.blocker !== undefined ? h('p', { key: 'bl', className: 'clxp-error' }, live.blocker) : null,
|
|
316
441
|
|
|
442
|
+
// No core yet: this is the one blocker the panel can fix without the user finding a
|
|
443
|
+
// binary themselves, so it gets a control instead of only being named.
|
|
444
|
+
live?.ready === false
|
|
445
|
+
? h('section', { key: 'core', className: 'clxp-card' }, [
|
|
446
|
+
h('h4', { key: 'ti' }, t('corePath')),
|
|
447
|
+
h('p', { key: 'h', className: 'clxp-hint' }, t('coreMissing')),
|
|
448
|
+
h('div', { key: 'a', className: 'clxp-actions' }, [
|
|
449
|
+
h('button', {
|
|
450
|
+
key: 'd',
|
|
451
|
+
type: 'button',
|
|
452
|
+
className: 'clxp-primary',
|
|
453
|
+
disabled: busy !== '' || live?.platformSupported === false,
|
|
454
|
+
onClick: () => void props.onAction('bootstrap'),
|
|
455
|
+
}, busy === 'bootstrap' ? t('downloadingCore') : t('downloadCore')),
|
|
456
|
+
]),
|
|
457
|
+
live?.platformSupported === false
|
|
458
|
+
? h('p', { key: 'u', className: 'clxp-error' }, t('coreUnsupported'))
|
|
459
|
+
: null,
|
|
460
|
+
live?.bootstrap !== undefined
|
|
461
|
+
? h('p', { key: 'p', className: live.bootstrap.phase === 'failed' ? 'clxp-error' : 'clxp-note', role: 'status' },
|
|
462
|
+
live.bootstrap.phase === 'failed'
|
|
463
|
+
? fill(t('coreFailed'), { reason: live.bootstrap.error ?? 'unknown' })
|
|
464
|
+
: live.bootstrap.phase === 'done'
|
|
465
|
+
? fill(t('coreInstalled'), { tag: live.bootstrap.tag ?? '' })
|
|
466
|
+
: live.bootstrap.phase === 'downloading'
|
|
467
|
+
? fill(t('coreProgress'), { mb: (Math.round(((live.bootstrap.received ?? 0) / 1024 / 1024) * 10) / 10).toFixed(1) })
|
|
468
|
+
: live.bootstrap.phase)
|
|
469
|
+
: null,
|
|
470
|
+
])
|
|
471
|
+
: null,
|
|
472
|
+
|
|
473
|
+
// Subscription rows: one per configured link, with its own fetch state. This is the
|
|
474
|
+
// surface that makes several subscriptions manageable — a single "nodes: 54" cannot
|
|
475
|
+
// say which provider is stale or dead.
|
|
476
|
+
h('section', { key: 'subs', className: 'clxp-card' }, [
|
|
477
|
+
h('h4', { key: 'ti' }, t('subscriptions')),
|
|
478
|
+
h('p', { key: 'ct', className: 'clxp-note' },
|
|
479
|
+
subscriptions.length === 0
|
|
480
|
+
? t('noSubscriptions')
|
|
481
|
+
: fill(t('subscriptionCount'), { count: subscriptions.length })),
|
|
482
|
+
subscriptions.length === 0
|
|
483
|
+
? null
|
|
484
|
+
: h('div', { key: 'ls', className: 'clxp-subs' },
|
|
485
|
+
subscriptions.map((row) => {
|
|
486
|
+
const state = providers.find((candidate) => candidate.provider === row.provider)
|
|
487
|
+
return h('div', { key: row.provider, className: 'clxp-sub' }, [
|
|
488
|
+
h('span', { key: 'n', className: 'clxp-node-name', title: row.url }, row.name),
|
|
489
|
+
h('span', {
|
|
490
|
+
key: 's',
|
|
491
|
+
className: `clxp-delay${state === undefined ? '' : state.ok ? ' good' : ' bad'}`,
|
|
492
|
+
}, state === undefined
|
|
493
|
+
? t('subscriptionPending')
|
|
494
|
+
: fill(t('subscriptionNodes'), { count: state.nodeCount ?? 0 })),
|
|
495
|
+
state?.updatedAt !== undefined && state.updatedAt !== null
|
|
496
|
+
? h('span', { key: 'u', className: 'clxp-note' }, fill(t('subscriptionUpdated'), { time: new Date(state.updatedAt).toLocaleTimeString() }))
|
|
497
|
+
: null,
|
|
498
|
+
h('button', {
|
|
499
|
+
key: 'r',
|
|
500
|
+
type: 'button',
|
|
501
|
+
className: 'clxp-node-act',
|
|
502
|
+
title: `${t('refreshOne')}: ${row.name}`,
|
|
503
|
+
'aria-label': `${t('refreshOne')}: ${row.name}`,
|
|
504
|
+
disabled: busy !== '' || !running,
|
|
505
|
+
onClick: () => void props.onAction('refreshOne', { provider: row.provider }),
|
|
506
|
+
}, '⟳'),
|
|
507
|
+
].filter(Boolean))
|
|
508
|
+
})),
|
|
509
|
+
]),
|
|
510
|
+
|
|
317
511
|
// Exit node table.
|
|
318
512
|
h('section', { key: 'nodes', className: 'clxp-card' }, [
|
|
319
513
|
h('h4', { key: 'ti' }, t('routing')),
|
|
@@ -368,8 +562,8 @@ function Panel(props) {
|
|
|
368
562
|
|
|
369
563
|
// A missing subscription is the one blocker a user can fix here, so it is named
|
|
370
564
|
// explicitly next to the save control instead of only in the status blob.
|
|
371
|
-
editable && String(props.draft?.subscriptionUrl ?? '').trim() === '' && props.live?.source !== 'configured'
|
|
372
|
-
? h('p', { key: 'need', className: 'clxp-error', role: 'status' }, '
|
|
565
|
+
editable && String(props.draft?.subscriptionUrls ?? '').trim() === '' && String(props.draft?.subscriptionUrl ?? '').trim() === '' && props.live?.source !== 'configured'
|
|
566
|
+
? h('p', { key: 'need', className: 'clxp-error', role: 'status' }, '还没有订阅链接:粘贴到上方「订阅链接」(一行一条)并保存,内核才会启动。')
|
|
373
567
|
: null,
|
|
374
568
|
|
|
375
569
|
editable
|
|
@@ -506,7 +700,7 @@ function RowConfigPage(props) {
|
|
|
506
700
|
method: 'POST',
|
|
507
701
|
credentials: 'same-origin',
|
|
508
702
|
headers: { 'content-type': 'application/json' },
|
|
509
|
-
body: JSON.stringify({ url: draft.subscriptionUrl ?? '' }),
|
|
703
|
+
body: JSON.stringify({ url: draft.subscriptionUrls ?? draft.subscriptionUrl ?? '' }),
|
|
510
704
|
})
|
|
511
705
|
setProbe(await response.json())
|
|
512
706
|
} catch (error) {
|
|
@@ -692,7 +886,7 @@ function SettingsSection(props) {
|
|
|
692
886
|
method: 'POST',
|
|
693
887
|
credentials: 'same-origin',
|
|
694
888
|
headers: { 'content-type': 'application/json' },
|
|
695
|
-
body: JSON.stringify({ url: draft?.subscriptionUrl ?? '' }),
|
|
889
|
+
body: JSON.stringify({ url: draft?.subscriptionUrls ?? draft?.subscriptionUrl ?? '' }),
|
|
696
890
|
})
|
|
697
891
|
setProbe(await response.json())
|
|
698
892
|
} catch (error) {
|