mirror of
https://github.com/Hmbown/DeepSeek-TUI.git
synced 2026-09-03 06:50:13 +08:00
Use one 76rem container and shared hero/section rhythm across navigation, footer, ticker, feed, install, runtime, and portal pages. Also make clipboard feedback truthful, repair locale and anchor links, align digest/feed styling, and surface catalog/runtime facts without implying provider readiness. Signed-off-by: CodeWhale Bot <bot@codewhale.net>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
interface Props {
|
|
cmd: string;
|
|
copyLabel?: string;
|
|
copiedLabel?: string;
|
|
}
|
|
|
|
export function InstallCodeBlock({ cmd, copyLabel = "Copy", copiedLabel = "Copied ✓" }: Props) {
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
const copy = async () => {
|
|
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
try {
|
|
await navigator.clipboard.writeText(cmd);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 1400);
|
|
} catch {
|
|
// Clipboard write failed (permissions, non-secure context, or a focused
|
|
// write race) — never show a false "Copied" confirmation.
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="relative">
|
|
<button
|
|
onClick={copy}
|
|
aria-label={copied ? copiedLabel : copyLabel}
|
|
data-copied={copied}
|
|
className="copy-btn absolute top-3 right-3 z-10 px-3 py-1 bg-paper hairline-t hairline-b hairline-l hairline-r font-mono text-[0.7rem] uppercase tracking-wider hover:bg-indigo hover:text-paper transition-colors"
|
|
>
|
|
{copied ? copiedLabel : copyLabel}
|
|
</button>
|
|
<pre className="code-block text-[0.78rem] m-0 max-w-full pr-20">{cmd}</pre>
|
|
</div>
|
|
);
|
|
}
|