Compare commits

..
5 changed files with 689 additions and 158 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" }
]
}
+20
View File
@@ -0,0 +1,20 @@
# 项目域名清单与福云导航
项目面向用户的域名和用途维护在 [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,用于验证交互和本地请求。
发布只从指定 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。
+203 -158
View File
@@ -1,48 +1,37 @@
<!doctype html>
<html lang="zh-CN" data-theme="dark">
<!-- 从 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 rel="icon" href="./logo.svg" type="image/svg+xml">
<link id="brand-icon" rel="icon" href="./logo.svg?v=2" type="image/svg+xml" sizes="any">
<style>
:root {
color-scheme: light;
--page: #f5f3fb;
--panel: #fff;
--ink: #211b39;
--muted: #625a76;
--line: #e7e1f2;
--accent: #5941bf;
--action: #6045ce;
--tint: #f0ebff;
--glow: #e4dcff;
--shadow: rgb(49 31 102 / 9%);
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;
}
:root[data-theme="dark"] {
color-scheme: dark;
--page: #171426;
--panel: #201c34;
--ink: #f6f1ff;
--muted: #bbb2d0;
--line: #38304d;
--accent: #c6b7ff;
--action: #7256df;
--tint: #332851;
--glow: #2d214a;
--shadow: rgb(0 0 0 / 20%);
}
*, *::before, *::after { box-sizing: border-box; }
body {
min-height: 100vh;
margin: 0;
color: var(--ink);
background: radial-gradient(ellipse at 16% 30%, var(--glow), transparent 50%), var(--page);
background: linear-gradient(180deg, var(--page-wash), var(--page) 360px);
}
a { color: inherit; text-decoration: none; }
@@ -50,43 +39,30 @@
:is(a, button):focus-visible,
.entry:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.wrap { width: min(740px, calc(100% - 48px)); margin-inline: auto; }
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding-block: 26px;
border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 750; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.theme {
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;
width: 42px;
height: 42px;
place-items: center;
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: var(--panel);
background: color-mix(in srgb, var(--notice-warm-tone) 5%, var(--page));
font-size: 15px;
}
.theme:hover { color: var(--accent); border-color: var(--accent); }
.theme svg { width: 19px; height: 19px; }
[data-theme="dark"] .theme .moon, [data-theme="light"] .theme .sun { display: none; }
main {
display: grid;
grid-template-columns: .86fr 1fr;
align-items: center;
gap: clamp(28px, 6vw, 80px);
min-height: min(680px, calc(100svh - 100px));
padding-block: 64px;
.email-notice-icon {
width: 19px;
height: 19px;
margin-top: 2px;
color: var(--accent);
}
h1 { margin: 0 0 16px; font-size: clamp(38px, 6.5vw, 70px); line-height: 1.12; letter-spacing: -.045em; }
.intro p { max-width: 23em; margin: 0; color: var(--muted); }
.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;
@@ -94,13 +70,12 @@
gap: 5px;
padding: 0;
border: 0;
color: var(--accent);
background: none;
font-weight: 650;
text-decoration: underline dotted;
color: var(--accent);
font-weight: 700;
text-underline-offset: 4px;
}
.copy-email:hover { text-decoration-style: solid; }
.copy-email:hover { text-decoration: underline; }
.copy-feedback {
position: absolute;
inset-inline-end: 0;
@@ -111,7 +86,6 @@
padding: 3px 8px;
border: 1px solid var(--line);
border-radius: 6px;
color: var(--accent);
background: var(--panel);
box-shadow: 0 4px 12px var(--shadow);
font-size: 12px;
@@ -120,156 +94,227 @@
.copy-feedback:empty { opacity: 0; }
.entries {
padding: clamp(16px, 3vw, 28px);
padding: clamp(16px, 4vw, 28px);
border: 1px solid var(--line);
border-radius: 24px;
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 64px var(--shadow);
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: 12px;
font-size: 13px;
}
.entries h2 { margin: 0 0 14px; font-size: 16px; }
.routes { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.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); }
.entry {
display: grid;
grid-template-columns: 20px minmax(0, 1fr);
align-items: center;
gap: 14px;
min-height: 80px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 14px;
cursor: pointer;
transition: border-color .16s ease, background-color .16s ease;
@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; }
}
.entry:has(input:checked), .entry:hover { background: var(--tint); border-color: var(--accent); }
.entry input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.entry strong, .entry small { display: block; }
.entry strong { overflow-wrap: anywhere; font-size: 17px; }
.entry small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.panel-footer { min-height: 40px; margin-block: 12px 10px; }
@media (prefers-reduced-motion: reduce) {
.entry { transition: none; }
}
</style>
</head>
<body>
<header class="wrap">
<a class="brand" href="/"><img src="./logo.svg" alt="">福云</a>
<button class="theme" type="button" aria-label="切换到浅色">
<svg class="sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.4 1.4m11.2 11.2L19 19M5 19l1.4-1.4m11.2-11.2L19 5"/></svg>
<svg class="moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M20.9 13.3A9 9 0 0 1 10.7 3.1a9 9 0 1 0 10.2 10.2Z"/></svg>
</button>
</header>
<main class="wrap">
<section class="intro" aria-labelledby="page-title">
<h1 id="page-title">福云地址导航</h1>
<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>
</section>
<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">
<label class="entry">
<input type="radio" name="route" value="https://fu99.cloud/" data-domainhub-code="fuc.direct-current" checked>
<span><strong>fu99.cloud</strong><small>免翻墙入口 · 推荐</small></span>
</label>
<label class="entry">
<input type="radio" name="route" value="https://xn--123-9i9dj97q.com/" data-domainhub-code="fuc.direct-cn-backup">
<span><strong>福云123.com</strong><small>备用入口</small></span>
</label>
<label class="entry">
<!-- 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><strong>福云.com</strong><small>中文主域名</small></span>
<span class="entry-info"><strong>福云.com</strong><small>永久主域名(需翻墙)</small></span>
<span class="latency">—</span>
</label>
<label class="entry">
<label class="entry" data-role="primary">
<input type="radio" name="route" value="https://fuuu.cloud/" data-domainhub-code="fuc.main-en">
<span><strong>fuuu.cloud</strong><small>英文主域名</small></span>
<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>
<button class="countdown" type="button">开始 8 秒跳转</button>
</div>
</section>
</main>
<script>
const theme = document.querySelector('.theme');
const panel = document.querySelector('.entries');
const routes = document.querySelector('.routes');
const status = document.querySelector('#route-status');
const enter = document.querySelector('#enter');
const countdown = document.querySelector('.countdown');
const recheck = document.querySelector('.recheck');
const invite = new URLSearchParams(location.search).get('code');
const seconds = 8;
let remaining = seconds;
let timer;
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 = new URL(selected.value).origin;
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;
status.textContent = '已选择 ' + selected.closest('label').querySelector('strong').textContent;
const name = selected.closest('label').querySelector('strong').textContent;
status.textContent = ['已选择 ' + name, testStatus].filter(Boolean).join(' · ');
}
function pauseCountdown() {
clearInterval(timer);
timer = undefined;
countdown.textContent = remaining === seconds ? '开始 8 秒跳转' : '继续跳转 ' + remaining + ' 秒';
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.result.textContent = Math.max(1, Math.round(elapsed)) + ' ms';
return { entry, elapsed };
} catch {
entry.result.textContent = controller.signal.aborted ? '超时' : '不可用';
return null;
} finally {
clearTimeout(timeout);
}
}
theme.addEventListener('click', () => {
const dark = document.documentElement.dataset.theme === 'dark';
document.documentElement.dataset.theme = dark ? 'light' : 'dark';
theme.setAttribute('aria-label', dark ? '切换到深色' : '切换到浅色');
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 ? '本地测速完成' : '测速完成') : '未测得可用入口';
} 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', () => {
remaining = seconds;
pauseCountdown();
manualSelection = true;
selectRoute();
});
countdown.addEventListener('click', () => {
if (timer !== undefined) {
pauseCountdown();
return;
}
countdown.textContent = '暂停跳转 ' + remaining + ' 秒';
timer = setInterval(() => {
remaining -= 1;
if (remaining === 0) {
clearInterval(timer);
timer = undefined;
location.assign(enter.href);
} else {
countdown.textContent = '暂停跳转 ' + remaining + ' 秒';
}
}, 1000);
});
recheck.addEventListener('click', testRoutes);
selectRoute();
testRoutes();
</script>
<script type="module">
import { copyText } from './clipboard.mjs';
+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;
}
+337
View File
@@ -0,0 +1,337 @@
<!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.result.textContent = Math.max(1, Math.round(elapsed)) + ' ms';
return { entry, elapsed };
} catch {
entry.result.textContent = controller.signal.aborted ? '超时' : '不可用';
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 ? '本地测速完成' : '测速完成') : '未测得可用入口';
} 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>