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 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
| <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Docker Registry Mirror</title> <style> :root { --bg-color: #0f172a; --card-bg: rgba(30, 41, 59, 0.55); --card-bg-inner: rgba(15, 23, 42, 0.5); --accent-color: #38bdf8; --accent-glow: #0ea5e9; --accent-purple: #818cf8; --text-color: #e2e8f0; --text-muted: #94a3b8; --text-dim: #64748b; --code-bg: rgba(15, 15, 25, 0.7); --success-color: #4ade80; --warn-color: #fbbf24; --border-color: rgba(255, 255, 255, 0.1); --border-hover: rgba(56, 189, 248, 0.4); } * { box-sizing: border-box; margin: 0; padding: 0; } html { scroll-behavior: smooth; } body { font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: linear-gradient(-45deg, #0f172a, #1e1b4b, #312e81, #0f172a); background-size: 400% 400%; animation: gradientBG 20s ease infinite; color: var(--text-color); min-height: 100vh; padding: 40px 20px; line-height: 1.6; } @keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } body::before, body::after { content: ''; position: fixed; border-radius: 50%; filter: blur(80px); opacity: 0.4; pointer-events: none; z-index: 0; } body::before { top: -100px; left: -100px; width: 400px; height: 400px; background: radial-gradient(circle, #38bdf8 0%, transparent 70%); } body::after { bottom: -100px; right: -100px; width: 500px; height: 500px; background: radial-gradient(circle, #818cf8 0%, transparent 70%); } .container { width: 100%; max-width: 900px; margin: 0 auto; position: relative; z-index: 1; } .glass-card { background: var(--card-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border-color); border-radius: 24px; padding: 40px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); margin-bottom: 30px; } header { text-align: center; margin-bottom: 40px; } .logo-icon { font-size: 3rem; margin-bottom: 10px; display: inline-block; filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.6)); } h1 { font-size: 2.5rem; font-weight: 800; background: linear-gradient(to right, #38bdf8, #818cf8); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 10px; text-shadow: 0 0 30px rgba(56, 189, 248, 0.3); } .subtitle { color: var(--text-muted); font-size: 1.1rem; } .domain-badge { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 10px 20px; background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3); border-radius: 999px; font-family: 'Consolas', 'Monaco', monospace; font-size: 0.95rem; color: var(--accent-color); } .domain-badge::before { content: '●'; color: var(--success-color); animation: pulse 2s infinite; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } } .tabs { display: flex; gap: 8px; margin-bottom: 24px; padding: 6px; background: rgba(15, 23, 42, 0.5); border-radius: 14px; border: 1px solid var(--border-color); flex-wrap: wrap; } .tab-btn { flex: 1; min-width: 120px; padding: 10px 16px; background: transparent; border: none; color: var(--text-muted); cursor: pointer; border-radius: 10px; font-size: 0.95rem; font-weight: 500; transition: all 0.3s; font-family: inherit; } .tab-btn:hover { color: var(--text-color); background: rgba(255, 255, 255, 0.05); } .tab-btn.active { background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.2)); color: var(--accent-color); box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.4); } .tab-panel { display: none; } .tab-panel.active { display: block; animation: fadeIn 0.3s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } } .section-title { font-size: 1.15rem; margin: 24px 0 14px; color: var(--accent-color); display: flex; align-items: center; gap: 12px; font-weight: 600; } .section-title:first-child { margin-top: 0; } .step-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent-color), var(--accent-purple)); color: #000; border-radius: 50%; font-size: 0.85rem; font-weight: 700; box-shadow: 0 0 15px rgba(56, 189, 248, 0.4); } .section-title .hint { margin-left: auto; font-size: 0.8rem; color: var(--text-dim); font-weight: normal; } .code-wrapper { position: relative; margin-bottom: 20px; background: var(--code-bg); border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.05); overflow: hidden; transition: border-color 0.2s; } .code-wrapper:hover { border-color: var(--border-hover); } pre { padding: 18px 20px; padding-right: 80px; overflow-x: auto; color: #d4d4d4; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.9rem; line-height: 1.65; } pre::-webkit-scrollbar { height: 6px; } pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; } .copy-btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-color); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.78rem; transition: all 0.3s ease; font-family: inherit; backdrop-filter: blur(10px); } .copy-btn:hover { background: var(--accent-color); color: #000; border-color: var(--accent-color); } .copy-btn.copied { background: var(--success-color); color: #000; border-color: var(--success-color); } .notice { padding: 14px 18px; border-radius: 12px; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.6; display: flex; gap: 12px; align-items: flex-start; } .notice-info { background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.2); color: #bae6fd; } .notice-warn { background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.2); color: #fde68a; } .notice-icon { font-size: 1.1rem; flex-shrink: 0; } details { margin-bottom: 16px; background: rgba(15, 23, 42, 0.4); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; } summary { padding: 14px 18px; cursor: pointer; font-weight: 500; color: var(--text-color); list-style: none; display: flex; align-items: center; gap: 10px; transition: background 0.2s; } summary::-webkit-details-marker { display: none; } summary::before { content: '▸'; color: var(--accent-color); transition: transform 0.2s; } details[open] > summary::before { transform: rotate(90deg); } summary:hover { background: rgba(255, 255, 255, 0.03); } details > div { padding: 0 18px 16px; } a { color: var(--accent-color); text-decoration: none; transition: color 0.3s; } a:hover { color: var(--accent-purple); } footer { text-align: center; padding: 30px 20px 10px; color: var(--text-dim); font-size: 0.88rem; } .footer-link { color: var(--accent-color); font-weight: 600; } .footer-link:hover { color: var(--accent-purple); text-shadow: 0 0 10px rgba(129, 140, 248, 0.5); } .cmd { color: #f9c74f; } .path { color: #9cdcfe; } .str { color: #ce9178; } .key { color: #9cdcfe; } .comment { color: #6a9955; font-style: italic; } .flag { color: #c586c0; } .table-wrap { overflow-x: auto; margin-bottom: 16px; background: var(--code-bg); border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.05); } table { width: 100%; border-collapse: collapse; font-family: 'Consolas', 'Monaco', monospace; font-size: 0.85rem; } th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); } th { color: var(--accent-color); font-weight: 600; background: rgba(56, 189, 248, 0.05); } td { color: #d4d4d4; } tr:last-child td { border-bottom: none; } tr:hover td { background: rgba(255,255,255,0.02); } @media (max-width: 640px) { .glass-card { padding: 24px 18px; border-radius: 18px; } h1 { font-size: 1.9rem; } pre { font-size: 0.82rem; padding: 14px 16px; padding-right: 70px; } .tabs { padding: 4px; } .tab-btn { min-width: 80px; padding: 8px 10px; font-size: 0.85rem; } } </style> </head> <body> <div class="container"> <div class="glass-card"> <header> <div class="logo-icon">🐳</div> <h1>Docker Mirror</h1> <p class="subtitle">高速 • 稳定 • 私有化加速服务</p> <div class="domain-badge"> <span id="domain-display">hub.bravexist.cn</span> </div> </header>
<div class="section-title"> <span class="step-num">1</span>创建/编辑 Docker 配置文件 </div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="cmd">sudo mkdir</span> -p /etc/docker <span class="cmd">sudo vim</span> <span class="path">/etc/docker/daemon.json</span></code></pre> </div>
<div class="section-title"> <span class="step-num">2</span>添加镜像源配置 </div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code>{ <span class="key">"registry-mirrors"</span>: [<span class="str">"https://<span class="domain-placeholder">hub.bravexist.cn</span>"</span>] }</code></pre> </div>
<div class="section-title"> <span class="step-num">3</span>重启 Docker 服务 </div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="cmd">sudo</span> systemctl daemon-reload <span class="cmd">sudo</span> systemctl restart docker</code></pre> </div>
<div class="notice notice-info"> <span class="notice-icon">💡</span> <div>配置完成后执行 <code style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;">docker info</code>,在输出底部能看到 <b>Registry Mirrors</b> 中列出本站域名即代表生效。</div> </div> </div>
<div class="glass-card"> <header style="margin-bottom: 24px; text-align: left;"> <h1 style="font-size: 1.6rem; margin-bottom: 6px;">⚡ 速度优化指南</h1> <p class="subtitle" style="font-size: 0.95rem;"> Cloudflare 默认把你分配到的边缘节点,不一定是对你<b>下载速度</b>最快的那一个。通过 <b>CloudflareSpeedTest</b> 实测挑出最快 IP 并绑定 hosts,Docker 拉取速度常能提升数倍。 </p> </header>
<div class="notice notice-warn"> <span class="notice-icon">🎯</span> <div> <b>为什么必须在你本机跑?</b>CF 对你快的节点,对我可能很慢——节点速度由<b>你所在网络到该节点的路由</b>决定,没有"全球最优 IP"这种东西。服务端也不会预先优选,那样既无效(缓存命中根本不回源)又属于对 CF 的滥用扫描。<br> <span style="opacity: 0.8; font-size: 0.88rem;">优选 IP 会随路由变化漂移,建议每 1–2 周重测一次。</span> </div> </div>
<div class="notice notice-info"> <span class="notice-icon">💡</span> <div><b>看哪一列?</b>测速结果里真正决定你体验的是 <b>下载速度(MB/s)</b>,不是延迟。延迟只是初筛——延迟高的节点基本不可能快,但延迟低的节点也可能因为带宽被打满而慢。挑下载速度最高的那个即可。</div> </div>
<div class="tabs" role="tablist"> <button class="tab-btn active" onclick="switchTab(this, 'tab-linux')">🐧 Linux</button> <button class="tab-btn" onclick="switchTab(this, 'tab-windows')">🪟 Windows</button> <button class="tab-btn" onclick="switchTab(this, 'tab-macos')">🍎 macOS</button> <button class="tab-btn" onclick="switchTab(this, 'tab-hosts')">📝 写入 hosts</button> </div>
<div id="tab-linux" class="tab-panel active"> <div class="section-title"><span class="step-num">1</span>下载并解压</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="comment"># 建立独立目录(便于后续更新)</span> <span class="cmd">mkdir</span> -p cfst && <span class="cmd">cd</span> cfst
<span class="comment"># 下载(国内网络请用下方镜像之一替换 github.com)</span> <span class="cmd">wget</span> -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz
<span class="cmd">tar</span> -zxf cfst_linux_amd64.tar.gz <span class="cmd">chmod</span> +x cfst</code></pre> </div>
<details> <summary>国内下载加速镜像(任选其一替换上面的 github.com)</summary> <div> <div class="code-wrapper" style="margin-top: 10px;"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="cmd">wget</span> -N https://wget.la/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz <span class="cmd">wget</span> -N https://ghfast.top/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz <span class="cmd">wget</span> -N https://ghproxy.it/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz <span class="cmd">wget</span> -N https://gh-proxy.org/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz <span class="cmd">wget</span> -N https://cdn.gh-proxy.org/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz</code></pre> </div> </div> </details>
<div class="section-title"><span class="step-num">2</span>运行测速</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="comment"># 默认测速</span> ./cfst
<span class="comment"># 推荐参数:延迟上限 200ms,输出前 20 个</span> ./cfst <span class="flag">-tl</span> 200 <span class="flag">-dn</span> 20</code></pre> </div> </div>
<div id="tab-windows" class="tab-panel"> <div class="section-title"><span class="step-num">1</span>使用 Scoop 安装(推荐)</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="comment"># 添加中文软件源 dorado</span> <span class="cmd">scoop</span> bucket add dorado https://github.com/chawyehsu/dorado
<span class="comment"># 安装 CloudflareSpeedTest</span> <span class="cmd">scoop</span> install dorado/cloudflare-speedtest
<span class="comment"># 运行(在 PowerShell / CMD 里)</span> <span class="cmd">cfst</span> <span class="flag">-tl</span> 200 <span class="flag">-dn</span> 20</code></pre> </div>
<details> <summary>手动下载方式(无 Scoop 环境)</summary> <div> <p style="margin: 10px 0; color: var(--text-muted); font-size: 0.9rem;"> 访问 <a href="https://github.com/XIU2/CloudflareSpeedTest/releases" target="_blank" rel="noopener">Releases 页面</a>, 下载 <code style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;">cfst_windows_amd64.zip</code>, 解压后在目录内打开 PowerShell 运行: </p> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code>.\CloudflareST.exe <span class="flag">-tl</span> 200 <span class="flag">-dn</span> 20</code></pre> </div> </div> </details> </div>
<div id="tab-macos" class="tab-panel"> <div class="section-title"><span class="step-num">1</span>下载(根据芯片选择)</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="cmd">mkdir</span> -p cfst && <span class="cmd">cd</span> cfst
<span class="comment"># Apple Silicon (M1/M2/M3/M4)</span> <span class="cmd">curl</span> -LO https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_darwin_arm64.tar.gz <span class="cmd">tar</span> -zxf cfst_darwin_arm64.tar.gz
<span class="comment"># Intel 芯片</span> <span class="comment"># curl -LO https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_darwin_amd64.tar.gz</span> <span class="comment"># tar -zxf cfst_darwin_amd64.tar.gz</span>
<span class="cmd">chmod</span> +x cfst</code></pre> </div>
<div class="section-title"><span class="step-num">2</span>运行测速</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code>./cfst <span class="flag">-tl</span> 200 <span class="flag">-dn</span> 20</code></pre> </div>
<div class="notice notice-info"> <span class="notice-icon">🔒</span> <div>首次运行若提示"无法打开",请到 <b>系统设置 → 隐私与安全性</b> 底部点击"仍要打开",或执行 <code style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;">xattr -d com.apple.quarantine ./cfst</code>。</div> </div> </div>
<div id="tab-hosts" class="tab-panel"> <div class="section-title">示例输出</div> <p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px;"> 测速完成后会显示最快的若干个 IP,类似下表(实际结果因地区而异): </p> <div class="table-wrap"> <table> <thead> <tr> <th>IP 地址</th> <th>丢包率</th> <th>平均延迟</th> <th>下载速度(MB/s)</th> <th>地区</th> </tr> </thead> <tbody> <tr><td>104.27.200.69</td><td>0.00</td><td>146.23</td><td>28.64</td><td>LAX</td></tr> <tr><td>172.67.60.78</td><td>0.00</td><td>139.82</td><td>15.02</td><td>SEA</td></tr> <tr><td>104.25.140.153</td><td>0.00</td><td>146.49</td><td>14.90</td><td>SJC</td></tr> <tr><td>104.27.192.65</td><td>0.00</td><td>140.28</td><td>14.07</td><td>LAX</td></tr> <tr><td>172.67.62.214</td><td>0.00</td><td>139.29</td><td>12.71</td><td>LAX</td></tr> </tbody> </table> </div>
<div class="section-title">写入 hosts(Linux / macOS)</div> <p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px;"> 挑一个延迟低、下载速度高的 IP,追加一行到 <code style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;">/etc/hosts</code>: </p> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="cmd">sudo</span> sh -c <span class="str">'echo "104.27.200.69 <span class="domain-placeholder">hub.bravexist.cn</span>" >> /etc/hosts'</span></code></pre> </div>
<div class="section-title">写入 hosts(Windows)</div> <p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px;"> 以管理员身份编辑 <code style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;">C:\Windows\System32\drivers\etc\hosts</code>,追加: </p> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code>104.27.200.69 <span class="domain-placeholder">hub.bravexist.cn</span></code></pre> </div>
<div class="section-title">刷新 DNS 缓存</div> <div class="code-wrapper"> <button class="copy-btn" onclick="copyCode(this)">复制</button> <pre><code><span class="comment"># Linux (systemd-resolved)</span> <span class="cmd">sudo</span> systemctl restart systemd-resolved
<span class="comment"># macOS</span> <span class="cmd">sudo</span> dscacheutil -flushcache && <span class="cmd">sudo</span> killall -HUP mDNSResponder
<span class="comment"># Windows</span> ipconfig /flushdns</code></pre> </div>
<div class="notice notice-info"> <span class="notice-icon">✨</span> <div>绑定后 Docker 拉取会强制走你测出的这个 IP,绕过 CF Anycast 的默认分配。若过一段时间又变慢(说明这个节点负载升高或路由变了),重测换一个 IP 即可。</div> </div> </div> </div>
<footer> <p> Powered by qiankong | <a href="https://bravexist.cn" target="_blank" rel="noopener" class="footer-link">一世贪欢的私域</a> </p> </footer> </div>
<script> (function() { const host = window.location.hostname || 'hub.bravexist.cn'; document.title = 'Docker Registry Mirror - ' + host; document.getElementById('domain-display').textContent = host; document.querySelectorAll('.domain-placeholder').forEach(el => { el.textContent = host; }); })();
function copyCode(btn) { const code = btn.parentElement.querySelector('code').innerText; const done = () => { const original = btn.innerText; btn.innerText = '✓ 已复制'; btn.classList.add('copied'); setTimeout(() => { btn.innerText = original; btn.classList.remove('copied'); }, 1800); }; if (navigator.clipboard && window.isSecureContext) { navigator.clipboard.writeText(code).then(done).catch(fallbackCopy); } else { fallbackCopy(); } function fallbackCopy() { const ta = document.createElement('textarea'); ta.value = code; ta.style.position = 'fixed'; ta.style.opacity = '0'; document.body.appendChild(ta); ta.select(); try { document.execCommand('copy'); done(); } catch (e) { alert('复制失败,请手动复制'); } document.body.removeChild(ta); } }
function switchTab(btn, panelId) { document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active')); btn.classList.add('active'); document.getElementById(panelId).classList.add('active'); } </script> </body> </html>
|