Compare commits

...
11 changed files with 1134 additions and 0 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
{
"domains": [
{ "domain": "福云.com", "role": "primary", "access": "requires_proxy", "domainhub": "fuc.main-cn" },
{ "domain": "fuuu.cloud", "role": "primary", "access": "requires_proxy", "domainhub": "fuc.main-en" },
{ "domain": "福云123.com", "role": "direct", "access": "suspected_blocked", "domainhub": "fuc.direct-cn-backup" },
{ "domain": "fuuu.online", "role": "direct", "domainhub": "fuc.fuuu-online" },
{ "domain": "fu99.cloud", "role": "direct", "domainhub": "fuc.direct-current", "recommended": true },
{ "domain": "fu-nav3.com", "role": "navigation", "domainhub": "fuc.navigation" }
]
}
+24
View File
@@ -0,0 +1,24 @@
# 项目域名清单与福云导航
项目面向用户的域名和用途维护在 [config/project-domains/](../../config/project-domains/)。每个项目使用独立的 JSON 文件,文件名为项目代号。DomainHub 继续维护 DNS、资源关系和地址发布台账;清单里的 `domainhub` 是对应记录代号,不包含凭据或私有入口。
- `role`:`primary` 永久主域名、`direct` 免翻墙域名、`navigation` 导航站域名。
- `access`:按需填写 `requires_proxy`(需翻墙)或 `suspected_blocked`(疑似被墙)。未填写表示没有登记额外限制,不表示做过当地线路测试。
- `recommended`:最多一个,只用于未标注限制的免翻墙域名。
```sh
node scripts/project-domains/manage.mjs list
node scripts/project-domains/manage.mjs list fuc
node scripts/project-domains/manage.mjs build fuc
node scripts/project-domains/manage.mjs check fuc
```
[比利版福云导航](http://xb.loc/theme/Fuc/assets/connect.html)的设计源为 [connect.html](../../theme/Fuc/assets/connect.html)。调整设计或 [FUC 清单](../../config/project-domains/fuc.json)后重新生成,生成器同步本地预览的入口列表,并从同一设计源生成独立导航站的 HTML 和资源。测速前默认选中 fu99.cloud。两条永久主域名固定在最前,其余入口在每轮测速后按耗时从低到高排列,未测通的放在末尾。福云123.com 的「疑似被墙」是清单标注。导航站本身只登记为导航入口。
打开页面或点「重新检测」时,浏览器并行请求五个入口的 `/api/v1/guest/comm/config`,确认是 XB 访客响应后显示耗时。每次请求最多 3 秒,不带登录态和邀请码。成功时优先选中最快的入口,手动选择保留;全部失败保留当前选项。只有点击「立即进入」才跳转,邀请码随注册链接传递。本地预览的测速和注册均使用 xb.loc,用于验证交互和本地请求。
每轮测速结束后,正式导航和反代分别向同源 `POST /_nav-stats` 提交一次五条结果。统计只存按日期、导航来源和域名汇总的成功、超时、其他失败计数。统计量是提交成功的测速轮次,用户在测速结束前离开不计入。北京时间每天 08:00 统计过去 24 小时,并通过 TeleHub 的 `info` 发往 `base`。首期注明开始采集时间。日报正文和回执保存在独立 SQLite,同一天的重试沿用原幂等键。
采集和日报在 site-jp01 执行。部署从 Git 同步导航资产和统计脚本,使用独立系统服务 `fuc-navigation-stats.service` 和 `fuc-navigation-report.timer`。日报凭据由后者通过 systemd 私有凭据读取。停止统计时先切回上一版导航,再撤销两端的统计入口并停用服务和定时器。保留统计库及已发回执。
发布只从指定 Git 提交提取 `public/brand/fuc-navigation/` 下的 `index.html`、`clipboard.mjs`、`logo.svg`,落在 `/var/www/wwwroot/fuc-navigation/releases/<SHA>`,再切换 `current`。静态清单不依赖面板或 DomainHub 在线。导航站的 CSP `connect-src` 放行五个面板域名及对应 tomtojapan 反代的测速接口,以及两个导航入口的统计地址。发布时分别核对两个导航域名发起的 CORS 请求,并回读 [导航根域](https://fu-nav3.com/)与已登记的 tomtojapan 反代。异常时将 `current` 指回上一次验收的版本,并恢复上一次导航 CSP。
@@ -0,0 +1,9 @@
export async function copyText(text,{clipboard=globalThis.navigator?.clipboard,document=globalThis.document}={}){
if(clipboard?.writeText){try{await clipboard.writeText(text);return;}catch{}}
// Same fallback used by the original ClipboardJS, including HTTP local previews.
const active=document.activeElement,input=document.createElement('textarea');
input.value=text;input.readOnly=true;input.style.cssText='position:fixed;left:-9999px;top:0';
document.body.append(input);
try{input.focus({preventScroll:true});input.select();input.setSelectionRange(0,input.value.length);if(!document.execCommand?.('copy'))throw Error('复制失败,请选中链接手动复制');}
finally{input.remove();if(active?.isConnected)active.focus();}
}
+347
View File
@@ -0,0 +1,347 @@
<!doctype html>
<!-- 从 theme/Fuc/assets/connect.html 和项目域名清单生成。 -->
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer">
<title>福云地址导航</title>
<link id="brand-icon" rel="icon" href="./logo.svg?v=2" type="image/svg+xml" sizes="any">
<style>
:root {
color-scheme: dark;
--page: #171426;
--page-wash: #241b3a;
--panel: #201c34;
--ink: #f6f1ff;
--muted: #bbb2d0;
--line: #38304d;
--accent: #c6b7ff;
--fastest: #b6ff40;
--notice-warm-tone: #f4d36c;
--action: #7256df;
--tint: #332851;
--shadow: rgb(0 0 0 / 20%);
font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
min-height: 100vh;
margin: 0;
color: var(--ink);
background: linear-gradient(180deg, var(--page-wash), var(--page) 360px);
}
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; cursor: pointer; }
:is(a, button):focus-visible,
.entry:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(740px, calc(100% - 48px)); margin-inline: auto; }
main { padding-block: clamp(32px, 6vw, 64px) 40px; }
h1 { margin: 0 0 24px; font-size: clamp(32px, 5vw, 48px); line-height: 1.18; letter-spacing: -.04em; }
.email-notice {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: start;
gap: 12px;
margin-bottom: 16px;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 12px;
background: color-mix(in srgb, var(--notice-warm-tone) 5%, var(--page));
font-size: 15px;
}
.email-notice-icon {
width: 19px;
height: 19px;
margin-top: 2px;
color: var(--accent);
}
.email-notice p { margin: 0; }
.email-notice .email-detail { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.65; text-wrap: pretty; }
.copy-control { position: relative; display: inline-block; }
.copy-email {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 0;
border: 0;
background: none;
color: var(--accent);
font-weight: 700;
text-underline-offset: 4px;
}
.copy-email:hover { text-decoration: underline; }
.copy-feedback {
position: absolute;
inset-inline-end: 0;
inset-block-end: calc(100% + 6px);
z-index: 1;
width: max-content;
max-width: 100%;
padding: 3px 8px;
border: 1px solid var(--line);
border-radius: 6px;
background: var(--panel);
box-shadow: 0 4px 12px var(--shadow);
font-size: 12px;
pointer-events: none;
}
.copy-feedback:empty { opacity: 0; }
.entries {
padding: clamp(16px, 4vw, 28px);
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 48px var(--shadow);
}
.entries h2 { margin: 0 0 16px; font-size: 18px; }
.routes { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.entry {
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
gap: 14px;
min-height: 60px;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 10px;
cursor: pointer;
transition: border-color .16s ease, background-color .16s ease;
}
.entry:hover { background: color-mix(in srgb, var(--tint) 50%, var(--panel)); }
.entry:has(input:checked) { background: var(--tint); border-color: var(--accent); }
.entry input { grid-area: 1 / 3; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.entry-info { grid-area: 1 / 1; display: flex; align-items: baseline; gap: 12px; }
.entry .latency { grid-area: 1 / 2; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .latency[data-fastest] { color: var(--fastest); font-weight: 700; }
.entry strong { overflow-wrap: anywhere; font-size: 17px; }
.entry small { color: var(--muted); font-size: 13px; }
.entry:has(input:checked) small { color: var(--accent); }
.panel-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 36px;
margin-block: 12px;
color: var(--muted);
font-size: 13px;
}
.recheck { border: 0; background: none; padding: 6px 0; color: var(--accent); white-space: nowrap; }
.recheck:hover { text-decoration: underline; }
.recheck:disabled { opacity: .55; cursor: wait; }
.enter { display: grid; place-items: center; min-height: 46px; border-radius: 9px; font-size: 14px; }
.enter { padding-inline: 12px; color: #fff; background: var(--action); font-weight: 700; }
.enter:hover { filter: brightness(1.1); }
@media (max-width: 520px) {
.wrap { width: calc(100% - 32px); }
h1 { margin-bottom: 18px; }
.entry { gap: 10px; padding: 10px 12px; }
.entry-info { flex-direction: column; gap: 1px; }
}
@media (prefers-reduced-motion: reduce) {
.entry { transition: none; }
}
</style>
</head>
<body>
<main class="wrap">
<h1>福云地址导航</h1>
<aside class="email-notice" aria-label="备用网址获取方式">
<svg class="email-notice-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="2.5" y="5" width="19" height="14" rx="2"/>
<path d="m3.5 6.5 8.5 7 8.5-7"/>
</svg>
<div>
<p>务必,请收藏我们的邮箱
<span class="copy-control">
<button class="copy-email" type="button" aria-label="复制邮箱地址 [email protected]">
[email protected]
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true">
<path d="M8 8h9l3 3v10H8V8Z M15 8V3H3v13h5"/>
</svg>
</button>
<span class="copy-feedback" role="status"></span>
</span>。
</p>
<p class="email-detail">导航地址也被墙时,可发送任意邮件至该邮箱,会自动回复最新地址,这是最保险的防失联方式。</p>
</div>
</aside>
<section class="entries" aria-labelledby="entry-title">
<h2 id="entry-title">访问入口</h2>
<fieldset class="routes" aria-labelledby="entry-title">
<!-- project-domains:start -->
<label class="entry" data-role="primary">
<input type="radio" name="route" value="https://xn--9kqy16h.com/" data-domainhub-code="fuc.main-cn">
<span class="entry-info"><strong>福云.com</strong><small>永久主域名(需翻墙)</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="primary">
<input type="radio" name="route" value="https://fuuu.cloud/" data-domainhub-code="fuc.main-en">
<span class="entry-info"><strong>fuuu.cloud</strong><small>永久主域名(需翻墙)</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://fu99.cloud/" data-domainhub-code="fuc.direct-current" checked>
<span class="entry-info"><strong>fu99.cloud</strong><small>免翻墙域名</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://fuuu.online/" data-domainhub-code="fuc.fuuu-online">
<span class="entry-info"><strong>fuuu.online</strong><small>免翻墙域名</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://xn--123-9i9dj97q.com/" data-domainhub-code="fuc.direct-cn-backup">
<span class="entry-info"><strong>福云123.com</strong><small>免翻墙域名(疑似被墙)</small></span>
<span class="latency">—</span>
</label>
<!-- project-domains:end -->
</fieldset>
<div class="panel-footer">
<span id="route-status" role="status">已选择 fu99.cloud</span>
<button class="recheck" type="button">重新检测</button>
</div>
<div class="actions">
<a id="enter" class="enter" href="https://fu99.cloud/#/register">立即进入 →</a>
</div>
</section>
</main>
<script>
const panel = document.querySelector('.entries');
const routes = document.querySelector('.routes');
const status = document.querySelector('#route-status');
const enter = document.querySelector('#enter');
const recheck = document.querySelector('.recheck');
const invite = new URLSearchParams(location.search).get('code');
const entries = [...routes.querySelectorAll('input[name="route"]')].map(input => {
const row = input.closest('label');
return { input, row, result: row.querySelector('.latency') };
});
const isLocal = location.hostname === 'xb.loc';
const probePath = '/api/v1/guest/comm/config';
const probeTimeoutMs = 3000;
let manualSelection = false;
let testStatus = '';
function selectRoute() {
const selected = routes.querySelector('input:checked');
const origin = isLocal ? location.origin : new URL(selected.value).origin;
const code = invite && /^[A-Za-z0-9_-]{1,64}$/.test(invite) ? '?code=' + encodeURIComponent(invite) : '';
enter.href = origin + '/#/register' + code;
const name = selected.closest('label').querySelector('strong').textContent;
status.textContent = ['已选择 ' + name, testStatus].filter(Boolean).join(' · ');
}
async function measure(entry, sample) {
const url = new URL(probePath, isLocal ? location.origin : entry.input.value);
url.searchParams.set('nav_probe', sample);
const controller = new AbortController();
const started = performance.now();
const timeout = setTimeout(() => controller.abort(), probeTimeoutMs);
try {
const response = await fetch(url, {
mode: 'cors', cache: 'no-store', credentials: 'omit', redirect: 'error',
referrerPolicy: 'no-referrer', signal: controller.signal,
});
if (!response.ok) throw new Error('Probe failed');
const { data } = await response.json();
if (typeof data?.app_name !== 'string') throw new Error('Invalid XB response');
const elapsed = performance.now() - started;
entry.outcome = 'success';
entry.result.textContent = Math.max(1, Math.round(elapsed)) + ' ms';
return { entry, elapsed };
} catch {
entry.outcome = controller.signal.aborted ? 'timeout' : 'failure';
entry.result.textContent = entry.outcome === 'timeout' ? '超时' : '不可用';
return null;
} finally {
clearTimeout(timeout);
}
}
async function testRoutes() {
if (recheck.disabled) return;
recheck.disabled = true;
panel.setAttribute('aria-busy', 'true');
testStatus = isLocal ? '本地测速中…' : '正在测速…';
selectRoute();
for (const { result } of entries) {
result.removeAttribute('data-fastest');
result.textContent = '测速中…';
}
try {
const round = Date.now().toString(36);
const results = await Promise.all(entries.map((entry, index) => measure(entry, round + '-' + index)));
const ranked = results.filter(Boolean).sort((a, b) => a.elapsed - b.elapsed);
const measured = new Set(ranked.map(({ entry }) => entry));
const ordered = [...ranked.map(({ entry }) => entry), ...entries.filter(entry => !measured.has(entry))];
const focused = document.activeElement;
for (const { row } of ordered) {
if (row.dataset.role !== 'primary') routes.append(row);
}
if (routes.contains(focused) && document.activeElement !== focused) focused.focus({ preventScroll: true });
const fastest = ranked[0];
if (fastest) {
fastest.entry.result.setAttribute('data-fastest', '');
if (!manualSelection) fastest.entry.input.checked = true;
}
testStatus = fastest ? (isLocal ? '本地测速完成' : '测速完成') : '未测得可用入口';
if (!isLocal) {
const outcomes = Object.fromEntries(entries.map(({ input, outcome }) => [input.dataset.domainhubCode, outcome]));
fetch('/_nav-stats', {
method: 'POST', body: JSON.stringify(outcomes), credentials: 'omit',
keepalive: true, referrerPolicy: 'no-referrer', redirect: 'error',
}).catch(() => {});
}
} finally {
recheck.disabled = false;
panel.removeAttribute('aria-busy');
selectRoute();
}
}
routes.addEventListener('click', event => {
if (event.target.matches('input[name="route"]')) manualSelection = true;
});
routes.addEventListener('change', () => {
manualSelection = true;
selectRoute();
});
recheck.addEventListener('click', testRoutes);
selectRoute();
testRoutes();
</script>
<script type="module">
import { copyText } from './clipboard.mjs';
const email = document.querySelector('.copy-email');
const feedback = document.querySelector('.copy-feedback');
let feedbackTimer;
email.addEventListener('click', async () => {
clearTimeout(feedbackTimer);
feedback.textContent = '';
try {
await copyText(email.textContent.trim());
feedback.textContent = '已复制';
feedbackTimer = setTimeout(() => { feedback.textContent = ''; }, 1600);
} catch {
feedback.textContent = '复制失败,请选中邮箱地址手动复制。';
}
});
</script>
</body>
</html>
+5
View File
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<title>福云</title>
<!-- Original Cool theme logo, embedded unchanged for the local brand preview. -->
<image x="4" y="12.465116" width="56" height="39.069768" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFYAAAA8CAYAAAD8OU3LAAAKsGlDQ1BJQ0MgcHJvZmlsZQAASImVlwdUk9kSgO//pzdaIAJSQg1dOgGkhNBCkV5thCRAIIQYCCqiorK4gmtBRQQsoKsiCq5KkcWGBduioNh1g4iKui4WbKi8P3AIu/vOe++8OWcyXyZz587c89+c+QGg6HElEhGsBkC2OE8aHeRHT0xKpuOGAAx0AAGQAJ7Ly5WwIiPDACKT9u/y4RaAFPaGrSLXv//+X0WdL8jlAQBFIpzKz+VlI3wM0Q88iTQPANRBxG+yME+i4OsIa0qRAhF+ouD0Cf6k4NRxRpPHY2Kj2QjTAcCTuVxpOgBkG8RPz+elI3nIih7sxXyhGOFChL2zs3P4CHcgbIHESBBW5Gem/iVP+t9ypipzcrnpSp7oZVzw/sJciYi7+P88jv8t2SLZ5B4MRMkZ0uBoxGogZ/YkKydUyeLUWRGTLOSPx49zhiw4bpJ5uezkSc4VxXAmmc/1D1XmEc0Km+Q0YaAyRp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1bL5+u9/W8DF8zd84V44/z7NTi/X7bDvUA6IDpxRgPmlMQSbA6/MC6wzTsvYLine truncated
</svg>

After

Width:  |  Height:  |  Size: 7.8 KiB

@@ -0,0 +1,227 @@
#!/usr/bin/env python3
"""Count browser probe outcomes and deliver the FUC navigation digest."""
import argparse
import fcntl
import json
import os
import re
import sqlite3
import time
from contextlib import closing
from datetime import date, datetime, timedelta
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import HTTPRedirectHandler, Request, build_opener
from zoneinfo import ZoneInfo
SHANGHAI = ZoneInfo("Asia/Shanghai")
ORIGINS = {
"https://fu-nav3.com": "正式导航",
"https://fu-nav3.tomtojapan.online": "反代导航",
}
OUTCOMES = ("success", "timeout", "failure")
TERMINAL = {"sent", "failed", "uncertain", "cancelled", "rejected"}
REPORT_ENDPOINT = "https://telehub.gemcook.net/api/v1/messages"
REPORT_ROUTE = "/_nav-stats"
def current_end(now):
return (now - timedelta(hours=8)).date() + timedelta(days=1)
def connect(path):
db = sqlite3.connect(path, timeout=4)
db.row_factory = sqlite3.Row
return db
def initialize(db, now):
db.execute("PRAGMA journal_mode=WAL")
db.executescript("""
CREATE TABLE IF NOT EXISTS metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS totals (
day TEXT NOT NULL, source TEXT NOT NULL, domain TEXT NOT NULL,
success INTEGER NOT NULL, timeout INTEGER NOT NULL, failure INTEGER NOT NULL,
PRIMARY KEY (day, source, domain)
);
CREATE TABLE IF NOT EXISTS reports (
day TEXT PRIMARY KEY, text TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending',
receipt TEXT, retry_at INTEGER NOT NULL DEFAULT 0, error TEXT
);
""")
with db:
db.execute("INSERT OR IGNORE INTO metadata VALUES ('started', ?)", (now.isoformat(),))
def count_round(db, catalog, origin, values, now):
if origin not in ORIGINS or not isinstance(values, dict) or set(values) != set(catalog):
raise ValueError("invalid sample")
if any(value not in OUTCOMES for value in values.values()):
raise ValueError("invalid outcome")
rows = [
(str(current_end(now)), origin, domain, *(outcome == status for status in OUTCOMES))
for domain, outcome in values.items()
]
with db:
db.executemany("""
INSERT INTO totals VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(day, source, domain) DO UPDATE SET
success = success + excluded.success,
timeout = timeout + excluded.timeout,
failure = failure + excluded.failure
""", rows)
def format_report(db, catalog, day):
started = datetime.fromisoformat(db.execute("SELECT value FROM metadata WHERE key='started'").fetchone()[0])
first = day - timedelta(days=1)
lines = ["【福云 - 导航测速日报】", f"{first} 08:00 至 {day} 08:00(北京时间)"]
if day == current_end(started):
lines.append(f"本期从 {started:%m-%d %H:%M} 开始采集")
rows = db.execute("SELECT * FROM totals WHERE day = ?", (str(day),))
totals = {(row["source"], row["domain"]): row for row in rows}
for origin, title in ORIGINS.items():
lines.extend(("", title))
if not any((origin, key) in totals for key in catalog):
lines.append("暂无样本")
continue
for key, name in catalog.items():
row = totals.get((origin, key))
counts = [row[value] if row else 0 for value in OUTCOMES]
total = sum(counts)
if not total:
lines.append(f"{name}:暂无样本")
continue
parts = [f"{label} {count / total:.1%}({count})"
for label, count in zip(("成功", "超时", "其他失败"), counts)]
lines.append(f"{name}:{total} 次," + ",".join(parts))
return "\n".join(lines)
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, *_args, **_kwargs):
return None
def telehub_request(token, report):
if not re.fullmatch(r"telehub_[a-f0-9]{64}", token):
raise ValueError("invalid TeleHub credential format")
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
if report["receipt"]:
req = Request(REPORT_ENDPOINT + "/" + report["receipt"], headers=headers)
else:
headers.update({
"Content-Type": "application/json",
"Idempotency-Key": "fuc.navigation.latency." + report["day"],
})
body = json.dumps({"bot": "info", "target": "base", "text": report["text"]}, ensure_ascii=False).encode()
req = Request(REPORT_ENDPOINT, data=body, headers=headers)
with build_opener(NoRedirect()).open(req, timeout=8) as result:
return json.load(result)["data"]
def deliver(db, catalog, now, send):
started = datetime.fromisoformat(db.execute("SELECT value FROM metadata WHERE key='started'").fetchone()[0])
day = current_end(started)
latest = current_end(now) - timedelta(days=1)
while day <= latest:
if not db.execute("SELECT 1 FROM reports WHERE day=?", (str(day),)).fetchone():
with db:
db.execute("INSERT INTO reports (day,text) VALUES (?,?)", (str(day), format_report(db, catalog, day)))
day += timedelta(days=1)
timestamp = int(now.timestamp())
reports = db.execute("""
SELECT * FROM reports WHERE status IN ('pending','queued','sending') AND retry_at <= ? ORDER BY day LIMIT 4
""", (timestamp,)).fetchall()
for report in reports:
receipt, status, delay, error = report["receipt"], report["status"], 900, None
try:
response = send(report)
if not isinstance(response, dict):
raise ValueError("invalid TeleHub response")
new_receipt = response.get("id", "")
new_status = response.get("status")
if (not isinstance(new_receipt, str)
or not re.fullmatch(r"[a-f0-9-]{36}", new_receipt)
or (receipt and receipt != new_receipt)
or new_status not in TERMINAL | {"queued", "sending"}
or response.get("bot_code") != "info" or response.get("target_code") != "base"):
raise ValueError("invalid TeleHub receipt")
receipt, status = new_receipt, new_status
except HTTPError as exc:
error = "telehub_http_" + str(exc.code)
if exc.code == 429:
retry = exc.headers.get("Retry-After", "")
if retry.isdigit():
delay = max(delay, int(retry))
elif 400 <= exc.code < 500:
status = "rejected"
except (ValueError, KeyError, OSError, URLError):
error = "telehub_transport_or_response"
with db:
db.execute("UPDATE reports SET receipt=?, status=?, retry_at=?, error=? WHERE day=?",
(receipt, status, timestamp + delay, error, report["day"]))
print(report["day"], status, receipt or "-", error or "-", flush=True)
def serve(path, catalog, port):
class Handler(BaseHTTPRequestHandler):
timeout = 4
def do_POST(self):
if self.path != REPORT_ROUTE:
self.send_error(404)
return
try:
origin = self.headers.get("Origin")
length = int(self.headers.get("Content-Length", "0"))
if origin not in ORIGINS or not 1 <= length <= 1024:
raise ValueError("invalid request")
values = json.loads(self.rfile.read(length))
with closing(connect(path)) as db:
count_round(db, catalog, origin, values, datetime.now(SHANGHAI))
except (ValueError, OSError, RecursionError):
self.send_error(400)
return
except sqlite3.Error:
self.send_error(503)
return
self.send_response(204)
self.end_headers()
def log_message(self, *_args):
pass
ThreadingHTTPServer(("127.0.0.1", port), Handler).serve_forever()
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--database", type=Path, required=True)
parser.add_argument("--catalog", type=Path, required=True)
sub = parser.add_subparsers(dest="mode", required=True)
sub.add_parser("serve").add_argument("--port", type=int, default=18248)
sub.add_parser("report")
sub.add_parser("preview").add_argument("day", type=date.fromisoformat)
args = parser.parse_args()
catalog = {item["domainhub"]: item["domain"] for item in json.loads(args.catalog.read_text())["domains"]
if item["role"] in {"primary", "direct"}}
now = datetime.now(SHANGHAI)
with closing(connect(args.database)) as db:
initialize(db, now)
if args.mode == "preview":
print(format_report(db, catalog, args.day))
elif args.mode == "report":
credential = Path(os.environ["CREDENTIALS_DIRECTORY"])/"telehub-token"
token = credential.read_text().strip()
with args.database.with_suffix(".report.lock").open("a") as lock:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
deliver(db, catalog, now, lambda report: telehub_request(token, report))
if args.mode == "serve":
serve(args.database, catalog, args.port)
if __name__ == "__main__":
main()
+119
View File
@@ -0,0 +1,119 @@
import { readFileSync, readdirSync, writeFileSync } from 'node:fs';
import { domainToASCII, domainToUnicode } from 'node:url';
const configs = new URL('../../config/project-domains/', import.meta.url);
const roles = new Map([
['primary', '永久主域名'],
['direct', '免翻墙域名'],
['navigation', '导航站域名'],
]);
const accessLabels = new Map([
['requires_proxy', '需翻墙'],
['suspected_blocked', '疑似被墙'],
]);
function load(project) {
if (!/^[a-z][a-z0-9-]*$/.test(project)) throw new Error('无效项目代号');
const { domains } = JSON.parse(readFileSync(new URL(project + '.json', configs), 'utf8'));
if (!Array.isArray(domains) || !domains.length) throw new Error(project + ' 未配置域名');
const seenHosts = new Set();
const seenCodes = new Set();
const records = domains.map(({ domain, role, access, domainhub, recommended = false }) => {
const fail = () => { throw new Error(project + ' 域名记录无效:' + domain); };
if (typeof domain !== 'string' || /[\s:/@?#%\\]/u.test(domain)) fail();
const host = domainToASCII(domain);
const labels = host.split('.');
if (host.length > 253 || labels.length < 2 || !/[a-z]/.test(labels.at(-1))
|| labels.some(label => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))
|| seenHosts.has(host)) fail();
if (!roles.has(role) || (access !== undefined && !accessLabels.has(access))
|| typeof recommended !== 'boolean' || (recommended && (role !== 'direct' || access))) fail();
if (domainhub !== undefined) {
if (typeof domainhub !== 'string' || !/^[a-z0-9][a-z0-9.-]*$/.test(domainhub)
|| !domainhub.startsWith(project + '.') || seenCodes.has(domainhub)) fail();
seenCodes.add(domainhub);
}
seenHosts.add(host);
return {
name: domainToUnicode(host), origin: 'https://' + host + '/', role, access, domainhub, recommended,
label: roles.get(role) + (access ? '(' + accessLabels.get(access) + ')' : ''),
};
});
if (records.filter(record => record.recommended).length > 1) throw new Error(project + ' 有多个默认推荐域名');
return records;
}
function escapeHtml(value) {
const entities = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
return value.replace(/[&<>"']/g, char => entities[char]);
}
function renderNavigation(project, records, source) {
const recommended = records.find(record => record.recommended);
if (!recommended || records.filter(record => record.role === 'navigation').length !== 1) {
throw new Error(project + ' 导航需要一个导航域名和一个默认推荐域名');
}
const panels = records.filter(record => record.role !== 'navigation');
const priority = ({ recommended, role, access }) => role === 'primary' ? 0
: recommended ? 1 : access === 'suspected_blocked' ? 3 : 2;
panels.sort((a, b) => priority(a) - priority(b));
const options = panels.map(({ origin, name, label, recommended, domainhub, role }) => {
const code = domainhub ? ' data-domainhub-code="' + escapeHtml(domainhub) + '"' : '';
return [
' <label class="entry" data-role="' + role + '">',
' <input type="radio" name="route" value="' + escapeHtml(origin) + '"' + code + (recommended ? ' checked' : '') + '>',
' <span class="entry-info"><strong>' + escapeHtml(name) + '</strong><small>' + escapeHtml(label) + '</small></span>',
' <span class="latency">—</span>',
' </label>',
].join('\n');
}).join('\n');
function replaceOnce(html, pattern, replacement) {
if ([...html.matchAll(pattern)].length !== 1) throw new Error('导航源标记不唯一:' + pattern);
return html.replace(pattern, replacement);
}
const preview = replaceOnce(source, /<!-- project-domains:start -->[\s\S]*?<!-- project-domains:end -->/g,
() => '<!-- project-domains:start -->\n' + options + '\n <!-- project-domains:end -->');
const withDefault = replaceOnce(preview, /(<span id="route-status" role="status">)[^<]*(<\/span>)/g,
(_, start, end) => start + '已选择 ' + escapeHtml(recommended.name) + end);
// The standalone release serves its own logo and does not require the XB theme path.
const withLogo = replaceOnce(withDefault, /(id="brand-icon" rel="icon" href=")\.\/native\/images\/brand\/fuc-mark\.svg/g,
(_, start) => start + './logo.svg');
const withFallback = replaceOnce(withLogo, /(id="enter" class="enter" href=")\/#\/register"/g,
(_, start) => start + escapeHtml(recommended.origin) + '#/register"');
return {
preview: withDefault,
standalone: withFallback.replace('<!doctype html>', '<!doctype html>\n<!-- 从 theme/Fuc/assets/connect.html 和项目域名清单生成。 -->'),
};
}
try {
const [action, project, ...rest] = process.argv.slice(2);
if (action === 'list' && rest.length === 0) {
const projects = project ? [project] : readdirSync(configs)
.filter(name => /^[a-z][a-z0-9-]*\.json$/.test(name)).sort().map(name => name.slice(0, -5));
for (const key of projects) {
for (const record of load(key)) console.log([key, record.name, record.label, record.domainhub ?? ''].join('\t'));
}
} else if (['build', 'check'].includes(action) && project === 'fuc' && rest.length === 0) {
const source = new URL('../../theme/Fuc/assets/connect.html', import.meta.url);
const read = path => readFileSync(new URL('../../' + path, import.meta.url));
const { preview, standalone } = renderNavigation(project, load(project), readFileSync(source, 'utf8'));
const files = [
['theme/Fuc/assets/connect.html', Buffer.from(preview)],
['public/brand/fuc-navigation/index.html', Buffer.from(standalone)],
['public/brand/fuc-navigation/logo.svg', read('theme/Fuc/assets/native/images/brand/fuc-mark.svg')],
['public/brand/fuc-navigation/clipboard.mjs', read('theme/Fuc/assets/clipboard.mjs')],
];
for (const [path, content] of files) {
if (action === 'build') writeFileSync(new URL('../../' + path, import.meta.url), content);
else if (!read(path).equals(content)) throw new Error(path + ' 已过期,请重新生成');
}
} else {
throw new Error('用法:manage.mjs list [项目代号] | build fuc | check fuc');
}
} catch (error) {
console.error(error.message);
process.exitCode = 1;
}
@@ -0,0 +1,19 @@
[Unit]
Description=FUC navigation daily TeleHub report
After=network-online.target fuc-navigation-stats.service
Wants=network-online.target
[Service]
Type=oneshot
User=fuc-nav-stats
Group=fuc-nav-stats
StateDirectory=fuc-navigation-stats
StateDirectoryMode=0700
UMask=0077
LoadCredential=telehub-token:/etc/fuc-navigation-stats/telehub-token
ExecStart=/usr/bin/python3 /var/www/wwwroot/fuc-navigation/current/ops/fuc_navigation_stats.py --catalog /var/www/wwwroot/fuc-navigation/current/ops/fuc.json --database /var/lib/fuc-navigation-stats/counters.sqlite3 report
TimeoutStartSec=55
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
@@ -0,0 +1,9 @@
[Unit]
Description=FUC navigation daily report and receipt checks
[Timer]
OnCalendar=*-*-* *:00/15:00 Asia/Shanghai
Persistent=true
[Install]
WantedBy=timers.target
@@ -0,0 +1,19 @@
[Unit]
Description=FUC navigation probe counters
After=network.target
[Service]
User=fuc-nav-stats
Group=fuc-nav-stats
StateDirectory=fuc-navigation-stats
StateDirectoryMode=0700
UMask=0077
ExecStart=/usr/bin/python3 /var/www/wwwroot/fuc-navigation/current/ops/fuc_navigation_stats.py --catalog /var/www/wwwroot/fuc-navigation/current/ops/fuc.json --database /var/lib/fuc-navigation-stats/counters.sqlite3 serve
Restart=on-failure
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+346
View File
@@ -0,0 +1,346 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer">
<title>福云地址导航</title>
<link id="brand-icon" rel="icon" href="./native/images/brand/fuc-mark.svg?v=2" type="image/svg+xml" sizes="any">
<style>
:root {
color-scheme: dark;
--page: #171426;
--page-wash: #241b3a;
--panel: #201c34;
--ink: #f6f1ff;
--muted: #bbb2d0;
--line: #38304d;
--accent: #c6b7ff;
--fastest: #b6ff40;
--notice-warm-tone: #f4d36c;
--action: #7256df;
--tint: #332851;
--shadow: rgb(0 0 0 / 20%);
font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
min-height: 100vh;
margin: 0;
color: var(--ink);
background: linear-gradient(180deg, var(--page-wash), var(--page) 360px);
}
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; cursor: pointer; }
:is(a, button):focus-visible,
.entry:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(740px, calc(100% - 48px)); margin-inline: auto; }
main { padding-block: clamp(32px, 6vw, 64px) 40px; }
h1 { margin: 0 0 24px; font-size: clamp(32px, 5vw, 48px); line-height: 1.18; letter-spacing: -.04em; }
.email-notice {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: start;
gap: 12px;
margin-bottom: 16px;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 12px;
background: color-mix(in srgb, var(--notice-warm-tone) 5%, var(--page));
font-size: 15px;
}
.email-notice-icon {
width: 19px;
height: 19px;
margin-top: 2px;
color: var(--accent);
}
.email-notice p { margin: 0; }
.email-notice .email-detail { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.65; text-wrap: pretty; }
.copy-control { position: relative; display: inline-block; }
.copy-email {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 0;
border: 0;
background: none;
color: var(--accent);
font-weight: 700;
text-underline-offset: 4px;
}
.copy-email:hover { text-decoration: underline; }
.copy-feedback {
position: absolute;
inset-inline-end: 0;
inset-block-end: calc(100% + 6px);
z-index: 1;
width: max-content;
max-width: 100%;
padding: 3px 8px;
border: 1px solid var(--line);
border-radius: 6px;
background: var(--panel);
box-shadow: 0 4px 12px var(--shadow);
font-size: 12px;
pointer-events: none;
}
.copy-feedback:empty { opacity: 0; }
.entries {
padding: clamp(16px, 4vw, 28px);
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 48px var(--shadow);
}
.entries h2 { margin: 0 0 16px; font-size: 18px; }
.routes { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.entry {
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
gap: 14px;
min-height: 60px;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 10px;
cursor: pointer;
transition: border-color .16s ease, background-color .16s ease;
}
.entry:hover { background: color-mix(in srgb, var(--tint) 50%, var(--panel)); }
.entry:has(input:checked) { background: var(--tint); border-color: var(--accent); }
.entry input { grid-area: 1 / 3; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.entry-info { grid-area: 1 / 1; display: flex; align-items: baseline; gap: 12px; }
.entry .latency { grid-area: 1 / 2; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .latency[data-fastest] { color: var(--fastest); font-weight: 700; }
.entry strong { overflow-wrap: anywhere; font-size: 17px; }
.entry small { color: var(--muted); font-size: 13px; }
.entry:has(input:checked) small { color: var(--accent); }
.panel-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 36px;
margin-block: 12px;
color: var(--muted);
font-size: 13px;
}
.recheck { border: 0; background: none; padding: 6px 0; color: var(--accent); white-space: nowrap; }
.recheck:hover { text-decoration: underline; }
.recheck:disabled { opacity: .55; cursor: wait; }
.enter { display: grid; place-items: center; min-height: 46px; border-radius: 9px; font-size: 14px; }
.enter { padding-inline: 12px; color: #fff; background: var(--action); font-weight: 700; }
.enter:hover { filter: brightness(1.1); }
@media (max-width: 520px) {
.wrap { width: calc(100% - 32px); }
h1 { margin-bottom: 18px; }
.entry { gap: 10px; padding: 10px 12px; }
.entry-info { flex-direction: column; gap: 1px; }
}
@media (prefers-reduced-motion: reduce) {
.entry { transition: none; }
}
</style>
</head>
<body>
<main class="wrap">
<h1>福云地址导航</h1>
<aside class="email-notice" aria-label="备用网址获取方式">
<svg class="email-notice-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="2.5" y="5" width="19" height="14" rx="2"/>
<path d="m3.5 6.5 8.5 7 8.5-7"/>
</svg>
<div>
<p>务必,请收藏我们的邮箱
<span class="copy-control">
<button class="copy-email" type="button" aria-label="复制邮箱地址 [email protected]">
[email protected]
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true">
<path d="M8 8h9l3 3v10H8V8Z M15 8V3H3v13h5"/>
</svg>
</button>
<span class="copy-feedback" role="status"></span>
</span>。
</p>
<p class="email-detail">导航地址也被墙时,可发送任意邮件至该邮箱,会自动回复最新地址,这是最保险的防失联方式。</p>
</div>
</aside>
<section class="entries" aria-labelledby="entry-title">
<h2 id="entry-title">访问入口</h2>
<fieldset class="routes" aria-labelledby="entry-title">
<!-- project-domains:start -->
<label class="entry" data-role="primary">
<input type="radio" name="route" value="https://xn--9kqy16h.com/" data-domainhub-code="fuc.main-cn">
<span class="entry-info"><strong>福云.com</strong><small>永久主域名(需翻墙)</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="primary">
<input type="radio" name="route" value="https://fuuu.cloud/" data-domainhub-code="fuc.main-en">
<span class="entry-info"><strong>fuuu.cloud</strong><small>永久主域名(需翻墙)</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://fu99.cloud/" data-domainhub-code="fuc.direct-current" checked>
<span class="entry-info"><strong>fu99.cloud</strong><small>免翻墙域名</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://fuuu.online/" data-domainhub-code="fuc.fuuu-online">
<span class="entry-info"><strong>fuuu.online</strong><small>免翻墙域名</small></span>
<span class="latency">—</span>
</label>
<label class="entry" data-role="direct">
<input type="radio" name="route" value="https://xn--123-9i9dj97q.com/" data-domainhub-code="fuc.direct-cn-backup">
<span class="entry-info"><strong>福云123.com</strong><small>免翻墙域名(疑似被墙)</small></span>
<span class="latency">—</span>
</label>
<!-- project-domains:end -->
</fieldset>
<div class="panel-footer">
<span id="route-status" role="status">已选择 fu99.cloud</span>
<button class="recheck" type="button">重新检测</button>
</div>
<div class="actions">
<a id="enter" class="enter" href="/#/register">立即进入 →</a>
</div>
</section>
</main>
<script>
const panel = document.querySelector('.entries');
const routes = document.querySelector('.routes');
const status = document.querySelector('#route-status');
const enter = document.querySelector('#enter');
const recheck = document.querySelector('.recheck');
const invite = new URLSearchParams(location.search).get('code');
const entries = [...routes.querySelectorAll('input[name="route"]')].map(input => {
const row = input.closest('label');
return { input, row, result: row.querySelector('.latency') };
});
const isLocal = location.hostname === 'xb.loc';
const probePath = '/api/v1/guest/comm/config';
const probeTimeoutMs = 3000;
let manualSelection = false;
let testStatus = '';
function selectRoute() {
const selected = routes.querySelector('input:checked');
const origin = isLocal ? location.origin : new URL(selected.value).origin;
const code = invite && /^[A-Za-z0-9_-]{1,64}$/.test(invite) ? '?code=' + encodeURIComponent(invite) : '';
enter.href = origin + '/#/register' + code;
const name = selected.closest('label').querySelector('strong').textContent;
status.textContent = ['已选择 ' + name, testStatus].filter(Boolean).join(' · ');
}
async function measure(entry, sample) {
const url = new URL(probePath, isLocal ? location.origin : entry.input.value);
url.searchParams.set('nav_probe', sample);
const controller = new AbortController();
const started = performance.now();
const timeout = setTimeout(() => controller.abort(), probeTimeoutMs);
try {
const response = await fetch(url, {
mode: 'cors', cache: 'no-store', credentials: 'omit', redirect: 'error',
referrerPolicy: 'no-referrer', signal: controller.signal,
});
if (!response.ok) throw new Error('Probe failed');
const { data } = await response.json();
if (typeof data?.app_name !== 'string') throw new Error('Invalid XB response');
const elapsed = performance.now() - started;
entry.outcome = 'success';
entry.result.textContent = Math.max(1, Math.round(elapsed)) + ' ms';
return { entry, elapsed };
} catch {
entry.outcome = controller.signal.aborted ? 'timeout' : 'failure';
entry.result.textContent = entry.outcome === 'timeout' ? '超时' : '不可用';
return null;
} finally {
clearTimeout(timeout);
}
}
async function testRoutes() {
if (recheck.disabled) return;
recheck.disabled = true;
panel.setAttribute('aria-busy', 'true');
testStatus = isLocal ? '本地测速中…' : '正在测速…';
selectRoute();
for (const { result } of entries) {
result.removeAttribute('data-fastest');
result.textContent = '测速中…';
}
try {
const round = Date.now().toString(36);
const results = await Promise.all(entries.map((entry, index) => measure(entry, round + '-' + index)));
const ranked = results.filter(Boolean).sort((a, b) => a.elapsed - b.elapsed);
const measured = new Set(ranked.map(({ entry }) => entry));
const ordered = [...ranked.map(({ entry }) => entry), ...entries.filter(entry => !measured.has(entry))];
const focused = document.activeElement;
for (const { row } of ordered) {
if (row.dataset.role !== 'primary') routes.append(row);
}
if (routes.contains(focused) && document.activeElement !== focused) focused.focus({ preventScroll: true });
const fastest = ranked[0];
if (fastest) {
fastest.entry.result.setAttribute('data-fastest', '');
if (!manualSelection) fastest.entry.input.checked = true;
}
testStatus = fastest ? (isLocal ? '本地测速完成' : '测速完成') : '未测得可用入口';
if (!isLocal) {
const outcomes = Object.fromEntries(entries.map(({ input, outcome }) => [input.dataset.domainhubCode, outcome]));
fetch('/_nav-stats', {
method: 'POST', body: JSON.stringify(outcomes), credentials: 'omit',
keepalive: true, referrerPolicy: 'no-referrer', redirect: 'error',
}).catch(() => {});
}
} finally {
recheck.disabled = false;
panel.removeAttribute('aria-busy');
selectRoute();
}
}
routes.addEventListener('click', event => {
if (event.target.matches('input[name="route"]')) manualSelection = true;
});
routes.addEventListener('change', () => {
manualSelection = true;
selectRoute();
});
recheck.addEventListener('click', testRoutes);
selectRoute();
testRoutes();
</script>
<script type="module">
import { copyText } from './clipboard.mjs';
const email = document.querySelector('.copy-email');
const feedback = document.querySelector('.copy-feedback');
let feedbackTimer;
email.addEventListener('click', async () => {
clearTimeout(feedbackTimer);
feedback.textContent = '';
try {
await copyText(email.textContent.trim());
feedback.textContent = '已复制';
feedbackTimer = setTimeout(() => { feedback.textContent = ''; }, 1600);
} catch {
feedback.textContent = '复制失败,请选中邮箱地址手动复制。';
}
});
</script>
</body>
</html>