fingerprint 0.2.3: History expands saved runs in place, an About tab, and a launcher fallback address (#858)
KaranocaVe (#858): History expands a saved run in place (results, cancel and
export for that run, by id) instead of replacing the current run; a new About
tab links the project and lm-detector (anchors standalone, copy buttons in
magpie's frame); the desktop launcher shows the local service address after
4s if navigation stalls; integration.md documents Windows' excluded port
ranges. Version 0.2.3.
Reviewed at d272d0c14fed1c1b654f970f358fabea4b2fe210, run on mote (macOS) in
a copy of the PR tree with a temp HOME in the run folder:
- packages/fingerprint: bun install --frozen-lockfile, typecheck ok, bun test
37 pass 0 fail, bun run build. diff -r of the PR's dist against the rebuild:
identical (dist/ui, plugin.js, cli.js).
- bun scripts/check.mjs fingerprint: registry.json ok, fingerprint ok.
- Bundle: the only new URL strings are the two About links
(github.com/KaranocaVe/magpie-fingerprint, github.com/Ikaleio/lm-detector);
no new fetch/eval/Function/WebSocket/sendBeacon; CSS has only the existing
data: SVG.
- Playwright 1.62.0, Chromium and WebKit, en and zh-CN, 1100px and 380px,
standalone and inside a parent frame, with the API stubbed from the demo
server's /api/bootstrap (a running, a completed and a failed run): History
expands a row (aria-expanded true), cancel from an expanded running row sends
one cancel and the row shows Cancelled, About shows 2 anchors standalone and
2 copy buttons framed (copy shows Copied in both engines), ArrowRight/Left
wrap across the three tabs, no horizontal overflow, no request off the stub
origin. 48 screenshots checked.
- The one page error, standalone only ("Cannot destructure property 'context'"
from the vendored bridge's hello), is the same on main 03ab6d66f (same load
harness on main's dist).
Not tried: the launcher fallback in a real Windows magpie window (covered by
the new boot test only). src/service-identity.ts VERSION still says 0.2.2
(health/bootstrap report it; nothing compares it), filed separately.
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-2
@@ -5,8 +5,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#f7f7f5" />
|
||||
<title>Magpie · 模型指纹</title>
|
||||
<script type="module" crossorigin src="./assets/index-BzHYFND5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-C9z1QhHD.css">
|
||||
<script type="module" crossorigin src="./assets/index-1yjBrEfd.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-DeacCGXr.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -21,6 +21,15 @@ WebKitGTK, magpie's Linux window, matches nothing to it there, so a policy of
|
||||
`'self'` alone loads no script and the page stays blank. The launcher origin changes
|
||||
only the document policy; the API bearer token and Host/Origin checks still apply.
|
||||
|
||||
On Windows, port 3488 can be in an excluded TCP range. Check
|
||||
`netsh interface ipv4 show excludedportrange protocol=tcp` and the Magpie
|
||||
plugin host log if the service cannot bind; configure the plugin's `port`
|
||||
option to an available port, such as 4388. If the launcher remains on
|
||||
"Connecting" after its handshake, it shows the local service address for
|
||||
opening in a browser. Magpie's "page didn't answer" message instead means the
|
||||
page did not complete the initial host handshake; inspect the host log and
|
||||
page loading errors to identify its cause.
|
||||
|
||||
## UI integration
|
||||
|
||||
The service page reconnects to Magpie using the upstream page bridge, vendored
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/page-fingerprint",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"description": "Check for suspected model substitution with numeric response fingerprints in Magpie, powered by lm-detector.",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
'Upgrade Magpie for remote plugin services, or forward the service port to this computer over SSH.',
|
||||
invalidPort: 'Invalid Fingerprint service port.',
|
||||
failed: 'Could not connect',
|
||||
fallback: 'If the page does not open, copy this address into a browser on this computer:',
|
||||
},
|
||||
'zh-Hans': {
|
||||
title: '模型指纹',
|
||||
@@ -14,6 +15,7 @@
|
||||
remote: '请升级 Magpie 以支持远程插件服务,或将服务器的服务端口通过 SSH 转发到本机。',
|
||||
invalidPort: '模型指纹服务端口无效。',
|
||||
failed: '连接失败',
|
||||
fallback: '如果页面未打开,请将此地址复制到本机浏览器:',
|
||||
},
|
||||
'zh-Hant': {
|
||||
title: '模型指紋',
|
||||
@@ -21,6 +23,7 @@
|
||||
remote: '請升級 Magpie 以支援遠端外掛服務,或透過 SSH 將伺服器的服務連接埠轉送至本機。',
|
||||
invalidPort: '模型指紋服務連接埠無效。',
|
||||
failed: '連線失敗',
|
||||
fallback: '如果頁面未開啟,請將此網址複製到本機瀏覽器:',
|
||||
},
|
||||
ja: {
|
||||
title: 'モデル指紋',
|
||||
@@ -29,6 +32,8 @@
|
||||
'リモートプラグインサービスを利用するには、Magpie を更新するか、SSH でサービスポートをこのコンピューターに転送してください。',
|
||||
invalidPort: 'モデル指紋サービスのポートが無効です。',
|
||||
failed: '接続できませんでした',
|
||||
fallback:
|
||||
'ページが開かない場合は、このアドレスをこのコンピューターのブラウザーにコピーしてください:',
|
||||
},
|
||||
de: {
|
||||
title: 'Modell-Fingerabdruck',
|
||||
@@ -37,6 +42,8 @@
|
||||
'Aktualisieren Sie Magpie für entfernte Plugin-Dienste oder leiten Sie den Dienstport per SSH an diesen Computer weiter.',
|
||||
invalidPort: 'Ungültiger Port für den Fingerabdruck-Dienst.',
|
||||
failed: 'Verbindung fehlgeschlagen',
|
||||
fallback:
|
||||
'Falls sich die Seite nicht öffnet, diese Adresse im Browser auf diesem Computer öffnen:',
|
||||
},
|
||||
};
|
||||
let text = messages.en;
|
||||
@@ -67,6 +74,7 @@
|
||||
const port = Number(config.port ?? 3488);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(text.invalidPort);
|
||||
let service = window.magpie?.service;
|
||||
let localFallback = '';
|
||||
if (!service) {
|
||||
// This computer's window: wails://localhost on macOS and Linux,
|
||||
// http://wails.localhost on Windows (Wails v3, WebView2).
|
||||
@@ -84,6 +92,7 @@
|
||||
return;
|
||||
}
|
||||
service = `http://127.0.0.1:${port}/`;
|
||||
localFallback = service;
|
||||
}
|
||||
const url = new URL(service, location.href);
|
||||
// Opaque Magpie web frames need the concrete proxy origin in connect-src.
|
||||
@@ -100,6 +109,15 @@
|
||||
location.replace(url.href);
|
||||
}
|
||||
});
|
||||
if (localFallback) {
|
||||
setTimeout(() => {
|
||||
status.textContent = text.fallback;
|
||||
const field = document.getElementById('service-url');
|
||||
field.value = localFallback;
|
||||
field.onclick = () => field.select();
|
||||
document.getElementById('fallback').hidden = false;
|
||||
}, 4000);
|
||||
}
|
||||
location.replace(url.href);
|
||||
})().catch((error) => {
|
||||
status.textContent = `${text.failed}: ${String(error?.message || error)}`;
|
||||
|
||||
@@ -28,12 +28,20 @@
|
||||
p {
|
||||
color: var(--magpie-muted, GrayText);
|
||||
}
|
||||
input {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 6px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<strong id="title">Fingerprint</strong>
|
||||
<p id="status">Connecting to Fingerprint…</p>
|
||||
<div id="fallback" hidden>
|
||||
<input id="service-url" readonly aria-label="Fingerprint service URL" />
|
||||
</div>
|
||||
</main>
|
||||
<script src="_magpie/bridge.js"></script>
|
||||
<script src="boot.js"></script>
|
||||
|
||||
@@ -7,6 +7,8 @@ async function boot(lang?: string, remote = false, port = 3488, desktopHost = ''
|
||||
const elements = {
|
||||
status: { textContent: 'Connecting to Fingerprint…' },
|
||||
title: { textContent: 'Fingerprint' },
|
||||
fallback: { hidden: true },
|
||||
'service-url': { value: '', onclick: () => {}, select: () => {} },
|
||||
};
|
||||
const document = {
|
||||
title: 'Fingerprint',
|
||||
@@ -14,10 +16,14 @@ async function boot(lang?: string, remote = false, port = 3488, desktopHost = ''
|
||||
getElementById: (id: keyof typeof elements) => elements[id],
|
||||
};
|
||||
let destination: URL | undefined;
|
||||
let fallback: (() => void) | undefined;
|
||||
// magpie hands no service to its desktop window, only to magpie web
|
||||
const service = remote || desktopHost ? '' : 'http://127.0.0.1:3488/';
|
||||
await runInNewContext(source, {
|
||||
URL,
|
||||
setTimeout: (callback: () => void) => {
|
||||
fallback = callback;
|
||||
},
|
||||
document,
|
||||
window: {
|
||||
magpie: {
|
||||
@@ -37,7 +43,7 @@ async function boot(lang?: string, remote = false, port = 3488, desktopHost = ''
|
||||
},
|
||||
},
|
||||
});
|
||||
return { document, elements, destination };
|
||||
return { document, elements, destination, fallback };
|
||||
}
|
||||
|
||||
test('boot defaults to English and follows host languages before navigation', async () => {
|
||||
@@ -60,6 +66,17 @@ test('boot defaults to English and follows host languages before navigation', as
|
||||
}
|
||||
});
|
||||
|
||||
test('a stalled desktop navigation offers the local service address', async () => {
|
||||
const result = await boot('zh-CN', false, 4388, 'wails.localhost');
|
||||
expect(result.elements.fallback.hidden).toBe(true);
|
||||
result.fallback?.();
|
||||
expect(result.elements.fallback.hidden).toBe(false);
|
||||
expect(result.elements['service-url'].value).toBe('http://127.0.0.1:4388/');
|
||||
expect(result.elements.status.textContent).toContain('本机浏览器');
|
||||
const remote = await boot('en');
|
||||
expect(remote.fallback).toBeUndefined();
|
||||
});
|
||||
|
||||
test('boot localizes remote-service guidance and invalid-port errors', async () => {
|
||||
const remote = await boot('zh-TW', true);
|
||||
expect(remote.destination).toBeUndefined();
|
||||
|
||||
@@ -2,12 +2,15 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import {
|
||||
ArrowClockwise,
|
||||
ArrowSquareOut,
|
||||
CaretDown,
|
||||
Check,
|
||||
CheckCircle,
|
||||
CircleNotch,
|
||||
Clipboard,
|
||||
ClockCounterClockwise,
|
||||
DownloadSimple,
|
||||
GithubLogo,
|
||||
Lightning,
|
||||
List,
|
||||
MagnifyingGlass,
|
||||
@@ -49,6 +52,7 @@ type Text = {
|
||||
locale: Locale;
|
||||
detect: string;
|
||||
history: string;
|
||||
about: string;
|
||||
settings: string;
|
||||
ready: string;
|
||||
offline: string;
|
||||
@@ -85,6 +89,7 @@ const zh: Text = {
|
||||
locale: 'zh-Hans',
|
||||
detect: '指纹检测',
|
||||
history: '检测历史',
|
||||
about: '关于',
|
||||
settings: '运行设置',
|
||||
ready: '服务已连接',
|
||||
offline: '服务离线',
|
||||
@@ -121,6 +126,7 @@ const zhHant: Text = {
|
||||
locale: 'zh-Hant',
|
||||
detect: '指紋檢測',
|
||||
history: '檢測歷史',
|
||||
about: '關於',
|
||||
settings: '執行設定',
|
||||
ready: '服務已連線',
|
||||
offline: '服務離線',
|
||||
@@ -157,6 +163,7 @@ const en: Text = {
|
||||
locale: 'en',
|
||||
detect: 'Fingerprint',
|
||||
history: 'History',
|
||||
about: 'About',
|
||||
settings: 'Run settings',
|
||||
ready: 'Service connected',
|
||||
offline: 'Service offline',
|
||||
@@ -240,7 +247,7 @@ function App() {
|
||||
});
|
||||
const [boot, setBoot] = useState<Bootstrap | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
const [section, setSection] = useState<'detect' | 'history'>('detect');
|
||||
const [section, setSection] = useState<'detect' | 'history' | 'about'>('detect');
|
||||
const [job, setJob] = useState<Job | null>(null);
|
||||
const [history, setHistory] = useState<Job[]>([]);
|
||||
const [query, setQuery] = useState('');
|
||||
@@ -454,26 +461,25 @@ function App() {
|
||||
setStarting(false);
|
||||
}
|
||||
};
|
||||
const cancel = async () => {
|
||||
if (!job) return;
|
||||
const cancel = async (id: string) => {
|
||||
try {
|
||||
const x = await api<Job>(`api/jobs/${job.id}/cancel`, { method: 'POST' });
|
||||
setJob(x);
|
||||
const x = await api<Job>(`api/jobs/${id}/cancel`, { method: 'POST' });
|
||||
setJob((current) => (current?.id === id ? x : current));
|
||||
setHistory((list) => list.map((item) => (item.id === id ? x : item)));
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
}
|
||||
};
|
||||
const download = async () => {
|
||||
if (!job) return;
|
||||
const download = async (id: string) => {
|
||||
try {
|
||||
const r = await fetch(apiUrl(`api/jobs/${job.id}/export`), {
|
||||
const r = await fetch(apiUrl(`api/jobs/${id}/export`), {
|
||||
headers: token() ? { Authorization: `Bearer ${token()}` } : {},
|
||||
});
|
||||
if (!r.ok) throw new Error('Export failed');
|
||||
const blob = await r.blob();
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = `fingerprint-${job.id}.json`;
|
||||
a.download = `fingerprint-${id}.json`;
|
||||
a.click();
|
||||
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
||||
} catch (e) {
|
||||
@@ -500,14 +506,14 @@ function App() {
|
||||
onKeyDown={(e) => {
|
||||
if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
const tabs = ['detect', 'history', 'about'] as const;
|
||||
const index = tabs.indexOf(section);
|
||||
const next =
|
||||
e.key === 'Home'
|
||||
? 'detect'
|
||||
? tabs[0]
|
||||
: e.key === 'End'
|
||||
? 'history'
|
||||
: section === 'detect'
|
||||
? 'history'
|
||||
: 'detect';
|
||||
? tabs[2]
|
||||
: tabs[(index + (e.key === 'ArrowRight' ? 1 : 2)) % tabs.length];
|
||||
setSection(next);
|
||||
document.getElementById(`tab-${next}`)?.focus();
|
||||
}
|
||||
@@ -536,6 +542,17 @@ function App() {
|
||||
{t.history}
|
||||
{history.length > 0 && <span className="tab-count">{history.length}</span>}
|
||||
</button>
|
||||
<button
|
||||
className={`opt ${section === 'about' ? 'on' : ''}`}
|
||||
id="tab-about"
|
||||
role="tab"
|
||||
aria-selected={section === 'about'}
|
||||
aria-controls="fingerprint-panel"
|
||||
tabIndex={section === 'about' ? 0 : -1}
|
||||
onClick={() => setSection('about')}
|
||||
>
|
||||
{t.about}
|
||||
</button>
|
||||
</nav>
|
||||
<div className="page-status">
|
||||
{boot?.demo ? (
|
||||
@@ -613,13 +630,12 @@ function App() {
|
||||
<History
|
||||
history={history}
|
||||
t={t}
|
||||
onSelect={(j) => {
|
||||
setJob(j);
|
||||
setExpanded(j.results[0]?.id || null);
|
||||
setSection('detect');
|
||||
}}
|
||||
onCancel={cancel}
|
||||
onDownload={download}
|
||||
onDelete={deleteJob}
|
||||
/>
|
||||
) : section === 'about' ? (
|
||||
<About t={t} />
|
||||
) : (
|
||||
<>
|
||||
<div className="intro">
|
||||
@@ -955,8 +971,8 @@ function App() {
|
||||
t={t}
|
||||
expanded={expanded}
|
||||
setExpanded={setExpanded}
|
||||
onCancel={cancel}
|
||||
onDownload={download}
|
||||
onCancel={() => cancel(job.id)}
|
||||
onDownload={() => download(job.id)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
@@ -1284,14 +1300,18 @@ function ResultRow({
|
||||
function History({
|
||||
history,
|
||||
t,
|
||||
onSelect,
|
||||
onCancel,
|
||||
onDownload,
|
||||
onDelete,
|
||||
}: {
|
||||
history: Job[];
|
||||
t: Text;
|
||||
onSelect: (j: Job) => void;
|
||||
onCancel: (id: string) => void;
|
||||
onDownload: (id: string) => void;
|
||||
onDelete: (id: string) => void;
|
||||
}) {
|
||||
const [open, setOpen] = useState<string | null>(null);
|
||||
const [expanded, setExpanded] = useState<string | null>(null);
|
||||
return (
|
||||
<div className="history-page">
|
||||
<div className="history-tools">
|
||||
@@ -1307,31 +1327,59 @@ function History({
|
||||
<div className="list history-list">
|
||||
{history.length ? (
|
||||
history.map((j) => (
|
||||
<div className="history-row" key={j.id}>
|
||||
<button onClick={() => onSelect(j)}>
|
||||
<span className={`history-state ${j.state}`} />
|
||||
<span>
|
||||
<strong>
|
||||
{j.config.targets[0]?.model || j.id.slice(0, 12)}
|
||||
{j.config.targets.length > 1 ? ` +${j.config.targets.length - 1}` : ''}
|
||||
</strong>
|
||||
<small>
|
||||
{new Date(j.createdAt).toLocaleString()} · {j.config.targets.length}{' '}
|
||||
{localize(t, '个模型', '個模型', 'models')} · {j.id.slice(0, 8)}
|
||||
</small>
|
||||
<div className="history-item" key={j.id}>
|
||||
<div className="history-row">
|
||||
<button
|
||||
aria-expanded={open === j.id}
|
||||
aria-controls={`history-${j.id}`}
|
||||
onClick={() => {
|
||||
setOpen(open === j.id ? null : j.id);
|
||||
setExpanded(j.results[0]?.id || null);
|
||||
}}
|
||||
>
|
||||
<span className={`history-state ${j.state}`} />
|
||||
<span>
|
||||
<strong>
|
||||
{j.config.targets[0]?.model || j.id.slice(0, 12)}
|
||||
{j.config.targets.length > 1 ? ` +${j.config.targets.length - 1}` : ''}
|
||||
</strong>
|
||||
<small>
|
||||
{new Date(j.createdAt).toLocaleString()} · {j.config.targets.length}{' '}
|
||||
{localize(t, '个模型', '個模型', 'models')} · {j.id.slice(0, 8)}
|
||||
</small>
|
||||
</span>
|
||||
<CaretDown
|
||||
className={open === j.id ? 'history-caret open' : 'history-caret'}
|
||||
size={15}
|
||||
/>
|
||||
</button>
|
||||
<span className={`status ${j.state}`}>
|
||||
{j.demo ? t.demo : stateLabel(t, j.state)}
|
||||
</span>
|
||||
</button>
|
||||
<span className={`status ${j.state}`}>
|
||||
{j.demo ? t.demo : stateLabel(t, j.state)}
|
||||
</span>
|
||||
<button
|
||||
className="icon icon-button danger-icon"
|
||||
title={localize(t, '删除', '刪除', 'Delete')}
|
||||
aria-label={`${localize(t, '删除检测记录', '刪除檢測紀錄', 'Delete run')} ${j.id.slice(0, 8)}`}
|
||||
onClick={() => onDelete(j.id)}
|
||||
>
|
||||
<Trash size={17} />
|
||||
</button>
|
||||
<button
|
||||
className="icon icon-button danger-icon"
|
||||
title={localize(t, '删除', '刪除', 'Delete')}
|
||||
aria-label={`${localize(t, '删除检测记录', '刪除檢測紀錄', 'Delete run')} ${j.id.slice(0, 8)}`}
|
||||
onClick={() => {
|
||||
if (open === j.id) setOpen(null);
|
||||
onDelete(j.id);
|
||||
}}
|
||||
>
|
||||
<Trash size={17} />
|
||||
</button>
|
||||
</div>
|
||||
{open === j.id && (
|
||||
<div className="history-detail" id={`history-${j.id}`}>
|
||||
<JobView
|
||||
job={j}
|
||||
t={t}
|
||||
expanded={expanded}
|
||||
setExpanded={setExpanded}
|
||||
onCancel={() => onCancel(j.id)}
|
||||
onDownload={() => onDownload(j.id)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
@@ -1344,4 +1392,112 @@ function History({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function About({ t }: { t: Text }) {
|
||||
const [copied, setCopied] = useState('');
|
||||
const [copyFailed, setCopyFailed] = useState('');
|
||||
const links = [
|
||||
{
|
||||
label: localize(t, '项目仓库', '專案儲存庫', 'Project repository'),
|
||||
url: 'https://github.com/KaranocaVe/magpie-fingerprint',
|
||||
},
|
||||
{
|
||||
label: localize(t, '上游指纹项目', '上游指紋專案', 'Upstream fingerprint project'),
|
||||
url: 'https://github.com/Ikaleio/lm-detector',
|
||||
},
|
||||
];
|
||||
useEffect(() => {
|
||||
if (!copied) return;
|
||||
const timer = setTimeout(() => setCopied(''), 2500);
|
||||
return () => clearTimeout(timer);
|
||||
}, [copied]);
|
||||
const copy = async (url: string, index: number) => {
|
||||
setCopyFailed('');
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
setCopied(url);
|
||||
} catch {
|
||||
const address = document.getElementById(`about-address-${index}`);
|
||||
const selection = window.getSelection();
|
||||
if (address && selection) {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(address);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
let success = false;
|
||||
try {
|
||||
success = document.execCommand('copy');
|
||||
} catch {
|
||||
// Leave the address selected so it can be copied manually.
|
||||
}
|
||||
if (success) {
|
||||
selection?.removeAllRanges();
|
||||
setCopied(url);
|
||||
} else {
|
||||
setCopied('');
|
||||
setCopyFailed(url);
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="about-page">
|
||||
<header className="about-heading">
|
||||
<h2>Fingerprint</h2>
|
||||
<p>
|
||||
{localize(t, '模型响应指纹检测', '模型回應指紋檢測', 'Model response fingerprinting')}
|
||||
</p>
|
||||
</header>
|
||||
<ul className="about-links">
|
||||
{links.map((link, index) => (
|
||||
<li className="about-link" key={link.url}>
|
||||
<GithubLogo className="about-github" size={20} aria-hidden="true" />
|
||||
<div className="about-link-content">
|
||||
<strong>{link.label}</strong>
|
||||
{embedded ? (
|
||||
<span className="about-url" id={`about-address-${index}`}>
|
||||
{link.url}
|
||||
</span>
|
||||
) : (
|
||||
<a className="about-url" href={link.url} target="_blank" rel="noopener noreferrer">
|
||||
{link.url}
|
||||
<ArrowSquareOut size={14} aria-hidden="true" />
|
||||
</a>
|
||||
)}
|
||||
{embedded && copyFailed === link.url && (
|
||||
<span className="about-copy-error" role="status">
|
||||
{localize(t, '请复制选中的地址', '請複製選取的網址', 'Copy the selected address')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{embedded && (
|
||||
<div className="about-copy">
|
||||
<button
|
||||
className="icon icon-button"
|
||||
onClick={() => void copy(link.url, index)}
|
||||
aria-label={localize(
|
||||
t,
|
||||
`复制${link.label}地址`,
|
||||
`複製${link.label}網址`,
|
||||
`Copy ${link.label} URL`,
|
||||
)}
|
||||
title={
|
||||
copied === link.url
|
||||
? localize(t, '已复制', '已複製', 'Copied')
|
||||
: localize(t, '复制地址', '複製網址', 'Copy URL')
|
||||
}
|
||||
>
|
||||
{copied === link.url ? <Check size={16} /> : <Clipboard size={16} />}
|
||||
</button>
|
||||
<span className="about-copy-status" role="status">
|
||||
{copied === link.url && localize(t, '已复制', '已複製', 'Copied')}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
createRoot(document.getElementById('root')!).render(<App />);
|
||||
|
||||
@@ -50,6 +50,7 @@ button:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
button:focus-visible,
|
||||
a:focus-visible,
|
||||
input:focus-visible,
|
||||
select:focus-visible,
|
||||
summary:focus-visible,
|
||||
@@ -836,9 +837,103 @@ pre {
|
||||
min-height: 54px;
|
||||
padding: 0 10px 0 12px;
|
||||
}
|
||||
.history-row + .history-row {
|
||||
.history-item + .history-item {
|
||||
border-top: 1px solid var(--line-2);
|
||||
}
|
||||
.history-detail {
|
||||
padding: 0 12px 16px;
|
||||
border-top: 1px solid var(--line-2);
|
||||
}
|
||||
.history-detail .results {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.history-caret {
|
||||
margin-left: auto;
|
||||
flex: none;
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
.history-caret.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.about-page {
|
||||
max-width: 600px;
|
||||
}
|
||||
.about-heading {
|
||||
padding: 8px 0 20px;
|
||||
}
|
||||
.about-heading h2 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
.about-heading p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.about-links {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.about-link {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 16px 0;
|
||||
border-top: 1px solid var(--line-2);
|
||||
font-size: 12px;
|
||||
}
|
||||
.about-github {
|
||||
flex: none;
|
||||
margin-top: 1px;
|
||||
color: var(--fg-2);
|
||||
}
|
||||
.about-link-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.about-link-content strong {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
}
|
||||
.about-url {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin-top: 4px;
|
||||
max-width: 100%;
|
||||
color: var(--muted);
|
||||
font-size: 11.5px;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-word;
|
||||
}
|
||||
a.about-url {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
a.about-url:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.about-url svg {
|
||||
flex: none;
|
||||
}
|
||||
.about-copy {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-width: 38px;
|
||||
}
|
||||
.about-copy-status,
|
||||
.about-copy-error {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.about-copy-error {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.history-row > button:first-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -954,6 +1049,8 @@ pre {
|
||||
}
|
||||
.page-tools {
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
padding: 6px 0;
|
||||
}
|
||||
.page-status {
|
||||
gap: 3px;
|
||||
@@ -967,6 +1064,29 @@ pre {
|
||||
.sample-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.result-summary {
|
||||
display: grid;
|
||||
grid-template-columns: 20px minmax(0, 1fr) 17px;
|
||||
align-items: start;
|
||||
}
|
||||
.result-icon {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
}
|
||||
.result-model {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
.result-summary > svg {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
}
|
||||
.result-label,
|
||||
.evidence-caveat {
|
||||
grid-column: 2;
|
||||
text-align: left;
|
||||
max-width: none;
|
||||
}
|
||||
.sample-tile {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
|
||||
Reference in New Issue
Block a user