Repository navigation
Expand file tree
/
Copy pathconnect_panel.html
More file actions
424 lines (420 loc) · 18.9 KB
/
Copy pathconnect_panel.html
File metadata and controls
424 lines (420 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<style id="connect-panel-style">
.connect-section {
background: var(--bg-card, #fff);
border: 1px solid var(--border, #e2e8f0);
border-radius: var(--radius-md, 8px);
padding: 0;
margin-bottom: var(--gap-section, 14px);
box-shadow: var(--shadow-sm, 0 1px 3px rgba(15, 23, 42, 0.08));
scroll-margin-top: 16px;
}
.connect-section > summary {
list-style: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 10px 16px;
font-size: 0.82rem;
font-weight: 600;
color: var(--text-primary, #0f172a);
user-select: none;
}
.connect-section > summary::-webkit-details-marker { display: none; }
.connect-section > summary::after {
content: '展开';
font-size: 0.72rem;
font-weight: 500;
color: var(--text-muted, #94a3b8);
}
.connect-section[open] > summary::after { content: '收起'; }
.connect-body { padding: 0 16px 16px; }
.connect-lead { margin: 4px 0 10px; font-size: 0.8rem; color: var(--text-secondary, #475569); }
.connect-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-bottom: 12px;
}
.connect-card {
border: 1px solid var(--border, #e2e8f0);
border-radius: 8px;
padding: 10px 12px;
background: var(--bg-muted, #f1f5f9);
}
.connect-card h3 {
font-size: 0.82rem;
margin: 0 0 6px;
color: var(--text-primary, #0f172a);
}
.connect-card p, .connect-card li {
font-size: 0.78rem;
color: var(--text-secondary, #475569);
line-height: 1.45;
}
.connect-card ul { margin: 6px 0 0; padding-left: 18px; }
.connect-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin: 8px 0 6px;
}
.connect-toolbar span { font-size: 0.75rem; color: var(--text-muted, #94a3b8); }
.copy-btn {
border: 1px solid rgba(14, 165, 233, 0.35);
background: #fff;
color: var(--primary-dark, #0284c7);
border-radius: 999px;
padding: 3px 10px;
font-size: 0.75rem;
font-weight: 600;
cursor: pointer;
white-space: nowrap;
}
.copy-btn:hover { background: rgba(14, 165, 233, 0.08); }
.copy-btn.is-copied { color: #047857; border-color: #10b981; }
.connect-code {
margin: 0;
padding: 10px 12px;
background: #0f172a;
color: #e2e8f0;
border-radius: 6px;
font-size: 0.74rem;
line-height: 1.45;
overflow-x: auto;
white-space: pre-wrap;
word-break: break-word;
}
.connect-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.connect-tabs button {
border: 1px solid var(--border, #e2e8f0);
background: #fff;
color: var(--text-secondary, #475569);
border-radius: 999px;
padding: 4px 12px;
font-size: 0.78rem;
font-weight: 600;
cursor: pointer;
}
.connect-tabs button.is-active {
background: linear-gradient(135deg, var(--primary, #0ea5e9), var(--secondary, #06b6d4));
color: #fff;
border-color: transparent;
}
.api-table-wrap { overflow-x: auto; margin: 8px 0 12px; }
.api-table {
width: 100%;
border-collapse: collapse;
font-size: 0.78rem;
}
.api-table th, .api-table td {
border: 1px solid var(--border, #e2e8f0);
padding: 6px 8px;
text-align: left;
vertical-align: top;
}
.api-table th { background: #f8fafc; color: var(--text-muted, #64748b); font-weight: 600; }
.api-table code { font-size: 0.75rem; }
.api-table .method {
font-weight: 700;
color: #047857;
font-size: 0.72rem;
}
.api-example { color: var(--text-muted, #64748b); font-size: 0.72rem; word-break: break-all; }
.connect-more { margin: 10px 0 0; font-size: 0.78rem; }
.connect-more a { color: var(--primary-dark, #0284c7); font-weight: 600; text-decoration: none; }
.connect-more a:hover { text-decoration: underline; }
@media (max-width: 800px) {
.connect-grid { grid-template-columns: 1fr; }
}
</style>
<details class="connect-section" id="connect">
<summary id="connectTitle">一键接入 API / MCP</summary>
<div class="connect-body">
<p class="connect-lead">查询日报、搜索资讯和 CVE。MCP 给 Cursor / Claude 用,REST API 给脚本和平台用。完整文档:<a href="{{ docs_url }}" target="_blank" rel="noopener noreferrer">API调用说明.md</a></p>
<div class="connect-grid">
<article class="connect-card" id="mcp">
<h3>MCP 一键接入</h3>
<p>默认连本机 <code>http://127.0.0.1:8765/mcp</code>。先运行 <code>python api_server.py</code>,再把配置贴进 Cursor / Claude。</p>
<div class="connect-toolbar">
<span>Cursor / Claude Desktop 配置</span>
<button type="button" class="copy-btn" data-copy-target="connectMcp">一键复制</button>
</div>
<pre class="connect-code" id="connectMcp">{
"mcpServers": {
"secdaily": {
"url": "http://127.0.0.1:8765/mcp"
}
}
}</pre>
<ul>
<li><code>secdaily_search</code> 关键词搜索</li>
<li><code>secdaily_get_digest</code> 某日日报</li>
<li><code>secdaily_search_cves</code> 查 CVE</li>
<li><code>secdaily_get_summary</code> AI 总结</li>
</ul>
</article>
<article class="connect-card" id="api">
<h3>REST API 一键接入</h3>
<p>Base URL:<code>http://127.0.0.1:8765/api/v1</code>。默认只监听本机。</p>
<div class="connect-toolbar">
<span>启动服务</span>
<button type="button" class="copy-btn" data-copy-target="connectApiStart">一键复制</button>
</div>
<pre class="connect-code" id="connectApiStart">git clone {{ github_url }}.git
cd SECDaily
python api_server.py</pre>
<ul>
<li>OpenAPI:<code>/api/v1/openapi.json</code></li>
<li>可选请求头:<code>X-API-Key</code></li>
<li>日报 <code>/digest</code> 默认返回当天全部,不用翻页</li>
<li>搜索 <code>/articles</code>、<code>/cves</code> 才分页:<code>page</code> / <code>pageSize</code>(默认 20,最大 100)</li>
</ul>
</article>
</div>
<div class="section-head"><h2>API 接口</h2></div>
<div class="api-table-wrap">
<table class="api-table">
<thead>
<tr>
<th>方法</th>
<th>路径</th>
<th>说明</th>
<th>调用示例</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="method">POST</span></td>
<td><code>/mcp</code></td>
<td>MCP(Streamable HTTP),默认本机 IP</td>
<td class="api-example">http://127.0.0.1:8765/mcp</td>
<td><button type="button" class="copy-btn" data-copy-text="http://127.0.0.1:8765/mcp">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/health</code></td>
<td>健康检查、最新日期</td>
<td class="api-example">curl http://127.0.0.1:8765/api/v1/health</td>
<td><button type="button" class="copy-btn" data-copy-text="curl http://127.0.0.1:8765/api/v1/health">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/dates</code></td>
<td>可用日报日期,可加 year、limit</td>
<td class="api-example">curl "http://127.0.0.1:8765/api/v1/dates?year=2026&limit=7"</td>
<td><button type="button" class="copy-btn" data-copy-text="curl "http://127.0.0.1:8765/api/v1/dates?year=2026&limit=7"">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/digest</code></td>
<td>最新一天日报</td>
<td class="api-example">curl http://127.0.0.1:8765/api/v1/digest</td>
<td><button type="button" class="copy-btn" data-copy-text="curl http://127.0.0.1:8765/api/v1/digest">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/digest/{date}</code></td>
<td>指定日期日报,可 cveOnly、source;默认当天全部</td>
<td class="api-example">curl "http://127.0.0.1:8765/api/v1/digest/2026-05-28?cveOnly=true"</td>
<td><button type="button" class="copy-btn" data-copy-text="curl "http://127.0.0.1:8765/api/v1/digest/2026-05-28?cveOnly=true"">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/articles</code></td>
<td>关键词搜索标题 / 来源 / CVE</td>
<td class="api-example">curl "http://127.0.0.1:8765/api/v1/articles?q=MCP&pageSize=5"</td>
<td><button type="button" class="copy-btn" data-copy-text="curl "http://127.0.0.1:8765/api/v1/articles?q=MCP&pageSize=5"">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/cves</code></td>
<td>按 CVE 编号检索</td>
<td class="api-example">curl "http://127.0.0.1:8765/api/v1/cves?q=2026-4893"</td>
<td><button type="button" class="copy-btn" data-copy-text="curl "http://127.0.0.1:8765/api/v1/cves?q=2026-4893"">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/sources</code></td>
<td>来源列表,可加 date</td>
<td class="api-example">curl "http://127.0.0.1:8765/api/v1/sources?date=2026-05-28"</td>
<td><button type="button" class="copy-btn" data-copy-text="curl "http://127.0.0.1:8765/api/v1/sources?date=2026-05-28"">复制</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/summary/{date}</code></td>
<td>当日 AI 总结(若已生成)</td>
<td class="api-example">curl http://127.0.0.1:8765/api/v1/summary/2025-12-03</td>
<td><button type="button" class="copy-btn" data-copy-text="curl http://127.0.0.1:8765/api/v1/summary/2025-12-03">复制</button></td>
</tr>
<tr>
<td><span class="method">POST</span></td>
<td><code>/api/v1/analyze</code></td>
<td>需求文本 8 类安全评估</td>
<td class="api-example">见下方 Python / curl 示例</td>
<td><button type="button" class="copy-btn" data-copy-target="connectExampleCurl">复制 curl</button></td>
</tr>
<tr>
<td><span class="method">GET</span></td>
<td><code>/api/v1/openapi.json</code></td>
<td>OpenAPI 描述</td>
<td class="api-example">curl http://127.0.0.1:8765/api/v1/openapi.json</td>
<td><button type="button" class="copy-btn" data-copy-text="curl http://127.0.0.1:8765/api/v1/openapi.json">复制</button></td>
</tr>
</tbody>
</table>
</div>
<div class="section-head"><h2>调用示例</h2></div>
<div class="connect-tabs" role="tablist" aria-label="调用示例">
<button type="button" class="is-active" data-connect-tab="curl" role="tab">curl</button>
<button type="button" data-connect-tab="pwsh" role="tab">PowerShell</button>
<button type="button" data-connect-tab="python" role="tab">Python</button>
<button type="button" data-connect-tab="mcp-chat" role="tab">MCP 对话</button>
</div>
<div data-connect-pane="curl">
<div class="connect-toolbar">
<span>启动后在终端执行</span>
<button type="button" class="copy-btn" data-copy-target="connectExampleCurl">一键复制</button>
</div>
<pre class="connect-code" id="connectExampleCurl">python api_server.py
curl http://127.0.0.1:8765/api/v1/health
curl "http://127.0.0.1:8765/api/v1/dates?limit=7"
curl http://127.0.0.1:8765/api/v1/digest
curl "http://127.0.0.1:8765/api/v1/digest/2026-05-28?cveOnly=true"
curl "http://127.0.0.1:8765/api/v1/articles?q=MCP&from=2026-04-01&pageSize=5"
curl "http://127.0.0.1:8765/api/v1/cves?q=2026-4893"
curl "http://127.0.0.1:8765/api/v1/sources?date=2026-05-28"
curl -X POST http://127.0.0.1:8765/api/v1/analyze -H "Content-Type: application/json" -d "{\"content\":\"需求:用户注册登录并绑定银行卡支付\",\"useKeywordAnalysis\":true}"</pre>
</div>
<div data-connect-pane="pwsh" hidden>
<div class="connect-toolbar">
<span>Windows PowerShell</span>
<button type="button" class="copy-btn" data-copy-target="connectExamplePwsh">一键复制</button>
</div>
<pre class="connect-code" id="connectExamplePwsh">python api_server.py
Invoke-RestMethod http://127.0.0.1:8765/api/v1/health
Invoke-RestMethod "http://127.0.0.1:8765/api/v1/articles?q=勒索&pageSize=5"
(Invoke-RestMethod "http://127.0.0.1:8765/api/v1/cves?q=2026-4893").data
Invoke-RestMethod -Method Post http://127.0.0.1:8765/api/v1/analyze -ContentType "application/json" -Body '{"content":"需求:用户注册登录并绑定银行卡支付","useKeywordAnalysis":true}'</pre>
</div>
<div data-connect-pane="python" hidden>
<div class="connect-toolbar">
<span>Python requests</span>
<button type="button" class="copy-btn" data-copy-target="connectExamplePython">一键复制</button>
</div>
<pre class="connect-code" id="connectExamplePython">import requests
base = "http://127.0.0.1:8765/api/v1"
print(requests.get(f"{base}/health").json()["latestDate"])
digest = requests.get(f"{base}/digest").json()
print(digest["date"], digest["stats"], len(digest["data"]))
news = requests.get(f"{base}/articles", params={"q": "MCP", "pageSize": 5}).json()
for item in news["data"]:
print(item["date"], item["title"], item["url"])
cves = requests.get(f"{base}/cves", params={"q": "2026-4893"}).json()
print(cves["data"])</pre>
</div>
<div data-connect-pane="mcp-chat" hidden>
<div class="connect-toolbar">
<span>在 Cursor / Claude 里直接说</span>
<button type="button" class="copy-btn" data-copy-target="connectExampleMcp">一键复制</button>
</div>
<pre class="connect-code" id="connectExampleMcp">用 secdaily 查最近关于 MCP 的资讯
用 secdaily_get_digest 看今天的安全日报,只要含 CVE 的
用 secdaily_search_cves 查 CVE-2026-4893
用 secdaily_list_sources 列出 2026-05-28 的资讯来源
用 secdaily_get_summary 读取最近一份 AI 总结</pre>
</div>
<p class="connect-more">错误码、分页字段与 MCP 工具参数见 <a href="{{ docs_url }}" target="_blank" rel="noopener noreferrer">API调用说明.md</a> · 仓库 <a href="{{ github_url }}" target="_blank" rel="noopener noreferrer">{{ github_url }}</a></p>
</div>
</details>
<script>
(function initConnectGuide() {
const root = document.getElementById('connect');
if (!root || root.dataset.bound === '1') return;
root.dataset.bound = '1';
const tabs = root.querySelectorAll('[data-connect-tab]');
const panes = root.querySelectorAll('[data-connect-pane]');
const copyTextSync = (text) => {
try {
const ta = document.createElement('textarea');
ta.value = text;
ta.setAttribute('readonly', '');
ta.style.cssText = 'position:fixed;left:-9999px;top:0;opacity:0';
document.body.appendChild(ta);
ta.focus();
ta.select();
const ok = document.execCommand('copy');
document.body.removeChild(ta);
return ok;
} catch (e) {
return false;
}
};
const copyText = async (text) => {
if (copyTextSync(text)) return true;
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch (e) {
return false;
}
}
return false;
};
const flash = (btn, ok) => {
const old = btn.textContent;
btn.textContent = ok ? '已复制' : '复制失败';
btn.classList.toggle('is-copied', ok);
btn.disabled = true;
setTimeout(() => {
btn.textContent = old;
btn.classList.remove('is-copied');
btn.disabled = false;
}, ok ? 2000 : 2800);
};
tabs.forEach((tab) => {
tab.addEventListener('click', () => {
const id = tab.dataset.connectTab;
tabs.forEach((item) => {
const on = item === tab;
item.classList.toggle('is-active', on);
item.setAttribute('aria-selected', on ? 'true' : 'false');
});
panes.forEach((pane) => {
pane.hidden = pane.dataset.connectPane !== id;
});
});
});
root.querySelectorAll('.copy-btn').forEach((btn) => {
btn.addEventListener('click', async () => {
let text = btn.getAttribute('data-copy-text') || '';
if (!text && btn.dataset.copyTarget) {
const el = document.getElementById(btn.dataset.copyTarget);
text = (el && el.textContent || '').replace(/\n$/, '');
}
text = text.replace(/&/g, '&');
const ok = await copyText(text);
flash(btn, ok);
if (!ok) window.prompt('请手动复制:', text);
});
});
const openConnect = () => {
root.open = true;
root.scrollIntoView({ behavior: 'smooth', block: 'start' });
};
if (location.hash === '#connect') {
root.open = true;
}
document.querySelectorAll('a[href="#connect"]').forEach((link) => {
link.addEventListener('click', (e) => {
e.preventDefault();
history.replaceState(null, '', '#connect');
openConnect();
});
});
})();
</script>