Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。
feat: finish visual retry and tooltip previews
AAA0653b7a58a10
diff --git a/native/client/internal/clientapp/console.go b/native/client/internal/clientapp/console.goindex 1dc1cade..f7a2fb8f 100644--- a/native/client/internal/clientapp/console.go+++ b/native/client/internal/clientapp/console.go@@ -57,23 +57,23 @@ type clientConsole struct {var consoleCopy = map[string][3]string{"mode": {"Mode", "模式", ""},- "local": {"Local network", "局域网", " /\\ \n .-/ \\-.\n |[_]-[_]|\n '-------'"},- "link": {"Public link", "公网链接", " o o \n/|\\ ()=() > /|\\\n/ \\ / \\"},- "site": {"Screener Site", "Screener 站点", ".----. .---.\n|www |---| = |\n'----' '---'"},- "setup": {"Choose a mode in the browser", "在浏览器中选择模式", ".o.o--------.\n| [] [] [] <|\n'-----------'"},- "starting": {"Starting", "正在启动", "\\---/\n > < \n/---\\"},- "ready": {"Ready", "已就绪", " /\n\\ / \n \\/ "},- "stopping": {"Stopping", "正在退出", " __ \n| o|>\n|__| "},- "stopped": {"Stopped", "已停止", ".---.\n| x |\n'---'"},- "failed": {"Could not continue", "运行失败", " /!\\ \n/ \\\n-----"},- "entry": {"Open in browser", "打开网页", "[o]"},- "invite": {"Site address", "站点地址", "()=()"},+ "local": {"Local network", "局域网", "□"},+ "link": {"Public link", "公网链接", "↗"},+ "site": {"Screener Site", "Screener 站点", "@"},+ "setup": {"Choose a mode in the browser", "在浏览器中选择模式", "?"},+ "starting": {"Starting", "正在启动", "…"},+ "ready": {"Ready", "已就绪", "✓"},+ "stopping": {"Stopping", "正在退出", "→"},+ "stopped": {"Stopped", "已停止", "○"},+ "failed": {"Could not continue", "运行失败", "!"},+ "entry": {"Open in browser", "打开网页", "□"},+ "invite": {"Site address", "站点地址", "↗"},"access": {"Site access", "站点准入", ""},- "open": {"Open", "开放", " __ \n / \n|___|"},- "password": {"Password protected", "已设置密码", " ___ \n| |\n|_*_|"},- "error": {"Details", "详情", "[!]"},- "exit": {"quit", "退出", " __ \n--> |o|\n |_|"},- "openFailed": {"Could not open the browser; use the address above.", "无法打开浏览器,请使用上方地址。", "[!] -> www"},+ "open": {"Open", "开放", "○"},+ "password": {"Password protected", "已设置密码", "*"},+ "error": {"Details", "详情", "!"},+ "exit": {"quit", "退出", "↪"},+ "openFailed": {"Could not open the browser; use the address above.", "无法打开浏览器,请使用上方地址。", "! ↗"},}func newClientConsole(cancel context.CancelFunc, machine bool) *clientConsole {@@ -220,7 +220,7 @@ func (model consoleModel) text(key string) string {index = 1}if model.language == "vis" {- index = 2+ return consoleVisualToken(key)}return consoleCopy[key][index]}@@ -275,7 +275,11 @@ func (model consoleModel) content(styled bool) string {stateStyle = stateStyle.Foreground(lipgloss.Color("#e25a52"))}}- fmt.Fprintln(&out, lipgloss.JoinHorizontal(lipgloss.Center, accent.Render(model.text(model.view.mode)), " ", stateStyle.Render(state)))+ // Keep visual mode one line tall; multi-line scene art side by side+ // collapses on narrow terminals and reads like missing characters.+ fmt.Fprintln(&out, lipgloss.JoinHorizontal(lipgloss.Center,+ accent.Render(consoleVisualToken(model.view.mode)), " · ",+ stateStyle.Render(consoleVisualToken(model.view.state))))} else {fmt.Fprintln(&out, accent.Render(state))if model.view.mode != "" {@@ -296,10 +300,7 @@ func (model consoleModel) content(styled bool) string {style = style.Hyperlink(target)}if visual {- label := model.text(item[0])- if !styled && item[0] == "entry" {- label = "www"- }+ label := consoleVisualToken(item[0])fmt.Fprintf(&out, "\n%s %s\n", label, style.Render(address))} else {fmt.Fprintf(&out, "\n%s\n%s\n", muted.Render(model.text(item[0])), style.Render(address))@@ -312,7 +313,7 @@ func (model consoleModel) content(styled bool) string {access = "password"}if visual {- accessPicture = model.text(access) + " "+ accessPicture = consoleVisualToken(access) + " "} else {fmt.Fprintf(&out, "\n%s %s\n", muted.Render(model.text("access")), model.text(access))}@@ -331,7 +332,10 @@ func (model consoleModel) content(styled bool) string {}help := keys + " " + model.text("exit")if visual {- help = lipgloss.JoinHorizontal(lipgloss.Center, accessPicture, keys+" ", model.text("exit"))+ if model.view.entry != "" && styled {+ help = "[o] ↗ " + help+ }+ help = lipgloss.JoinHorizontal(lipgloss.Center, accessPicture, help)} else if model.view.entry != "" && styled {help = "[o] " + model.text("entry") + " " + help}@@ -354,6 +358,41 @@ func (model consoleModel) content(styled bool) string {Padding(padding, 1).Width(width).Render(content)}+func consoleVisualToken(key string) string {+ switch key {+ case "local":+ return "□"+ case "link":+ return "↗"+ case "site":+ return "@"+ case "setup":+ return "?"+ case "starting":+ return "…"+ case "ready":+ return "✓"+ case "stopping":+ return "→"+ case "stopped":+ return "○"+ case "failed", "error":+ return "!"+ case "open":+ return "○"+ case "password":+ return "*"+ case "entry":+ return "□"+ case "invite":+ return "↗"+ case "exit":+ return "↪"+ default:+ return "?"+ }+}+func consoleTV(frame int, animated, compact bool) string {phase := 0if animated {diff --git a/src/client/App.tsx b/src/client/App.tsxindex ec6f60c5..c87cec4e 100644--- a/src/client/App.tsx+++ b/src/client/App.tsx@@ -24,8 +24,12 @@ import { Btn, Pill } from "./components/living/primitives";import { ComicTooltip } from "./components/living/ComicTooltip";import { Glyph, type GlyphName } from "./ui/icons";import { useCopy } from "./ui/copy";+import { OverlayPreviewPage } from "./pages/OverlayPreviewPage";+import { TooltipPreviewPage } from "./pages/TooltipPreviewPage";const appRoute = parseAppRoute(window.location.pathname);+const overlayPreview = import.meta.env.DEV && window.location.pathname === "/__overlay-preview";+const tooltipPreview = import.meta.env.DEV && window.location.pathname === "/__tooltip-preview";const clientLaunchBootstrap =appRoute.kind === "host" || appRoute.kind === "viewer"? takeClientLaunchBootstrap()@@ -93,6 +97,12 @@ export function App() {}function AppRoute() {+ if (overlayPreview) {+ return <OverlayPreviewPage />;+ }+ if (tooltipPreview) {+ return <TooltipPreviewPage />;+ }if (appRoute.kind === "client") {return <ClientLauncherPage />;}diff --git a/src/client/components/living/Comic.tsx b/src/client/components/living/Comic.tsxindex b305d5fe..f138e8ab 100644--- a/src/client/components/living/Comic.tsx+++ b/src/client/components/living/Comic.tsx@@ -549,7 +549,7 @@ ${rmBlock(kills, pins)}<Frame x={216} w={96} theme={theme} /><Floor x1={20} x2={92} /><Pawn x={56} yb={76} s={11} eyes />- <Pawn x={128} yb={74} s={7} eyes />+ <Pawn x={128} yb={74} s={7} eyes color={SKY} />{sfu ? (<><g stroke={LINE} strokeWidth={2.5} strokeLinecap="round" fill="none" strokeDasharray="4 4">@@ -1212,7 +1212,7 @@ ${rmBlock(<g className="vls-bw-small"><MiniTv x={254} y={41} w={34} h={20} /></g>- <Pawn x={298} yb={76} s={6.5} eyes color={WARN} />+ <Pawn x={298} yb={76} s={6.5} eyes /></>);}@@ -1273,7 +1273,7 @@ ${rmBlock(<g className="vls-en-small"><MiniTv x={258} y={41} w={34} h={20} /></g>- <Pawn x={301} yb={76} s={6} eyes color={WARN} />+ <Pawn x={301} yb={76} s={6} eyes /></>);}diff --git a/src/client/components/living/Stage.tsx b/src/client/components/living/Stage.tsxindex 51f412ec..e5d96687 100644--- a/src/client/components/living/Stage.tsx+++ b/src/client/components/living/Stage.tsx@@ -101,18 +101,27 @@ export function StageOverlay({onActivate?: () => void;}) {const { vis } = useCopy();+ const showMascot =+ transition ||+ (vis && Boolean(comic) &&+ (Boolean(spin) || comic === "waiting-for-host" || comic === "recovering"));const content = (<>{vis && comic ? <Comic kind={comic} theme="stage" /> : null}<span className="lr-tv-status-content">- {transition ? (+ {showMascot ? (<BrandLoader />) : (<span className={`lr-tv-big${spin ? " lr-spin" : ""}${onActivate ? " is-action is-ripple" : ""}`}><Glyph name={icon} size={30} draw="stage-overlay" /></span>)}- {vis ? progress && <span className="lr-tv-msg">{progress}</span> :+ {vis ? progress && (+ <span className="lr-tv-progress" aria-label={progress}>+ <Glyph name="refresh" size={17} className="lr-spin" />+ <span className="lr-tv-msg">{progress}</span>+ </span>+ ) :<span className="lr-tv-msg">{message}</span>}</span></>diff --git a/src/client/locales/en.ts b/src/client/locales/en.tsindex dec8f6ac..5e164eec 100644--- a/src/client/locales/en.ts+++ b/src/client/locales/en.ts@@ -272,7 +272,7 @@ export const en: Record<CopyKey, string> = {"viewer.msg.joining": "Joining the room","viewer.msg.waitingHost": "Waiting for the host to share","viewer.msg.preparingP2p": "Establishing P2P",- "viewer.msg.connectionAttempt": "Connecting ({current}/{total})",+ "viewer.msg.connectionRetry": "Retrying ({current}/{total})","viewer.msg.preparingSfu": "Connecting backup route","viewer.msg.allocating": "Allocating a route","viewer.msg.receiving": "Receiving video",diff --git a/src/client/locales/zh.ts b/src/client/locales/zh.tsindex 1a7ffc57..4a89e9bc 100644--- a/src/client/locales/zh.ts+++ b/src/client/locales/zh.ts@@ -270,7 +270,7 @@ export const zh = {"viewer.msg.joining": "正在加入房间","viewer.msg.waitingHost": "等待开始分享","viewer.msg.preparingP2p": "正在建立 P2P",- "viewer.msg.connectionAttempt": "正在尝试连接({current}/{total})",+ "viewer.msg.connectionRetry": "正在重试({current}/{total})","viewer.msg.preparingSfu": "正在连接备用线路","viewer.msg.allocating": "正在分配线路","viewer.msg.receiving": "正在接收画面",diff --git a/src/client/pages/OverlayPreviewPage.tsx b/src/client/pages/OverlayPreviewPage.tsxnew file mode 100644index 00000000..8e1c4ca5--- /dev/null+++ b/src/client/pages/OverlayPreviewPage.tsx@@ -0,0 +1,59 @@+import { StageOverlay, StageTv } from "../components/living/Stage";+import { AppHeader } from "../components/living/Header";+import { useCopy } from "../ui/copy";+import type { ComicKind } from "../components/living/Comic";+import type { GlyphName } from "../ui/icons";++const STATES: readonly {+ title: string;+ comic: ComicKind;+ icon: GlyphName;+ message: string;+ progress?: string;+}[] = [+ { title: "首次连接", comic: "connecting-p2p", icon: "loader", message: "正在连接" },+ { title: "第一次重试", comic: "connecting-p2p", icon: "loader", message: "正在重试", progress: "1/2" },+ { title: "SFU 连接", comic: "connecting-sfu", icon: "loader", message: "正在连接中转" },+ { title: "等待分享者", comic: "waiting-for-host", icon: "door", message: "等待分享者" },+ { title: "分享者暂停", comic: "host-paused", icon: "pause", message: "分享者已暂停" },+ { title: "线路恢复", comic: "recovering", icon: "refresh", message: "正在恢复线路" },+ { title: "线路失败", comic: "route-failed", icon: "alert", message: "线路不可用" },+ { title: "播放失败", comic: "playback-failed", icon: "alert", message: "播放失败" },+ { title: "没有声音", comic: "no-audio", icon: "speaker", message: "没有可用音频" },+ { title: "分享者离线", comic: "host-offline", icon: "door", message: "分享者已离开" },+ { title: "带宽受限", comic: "bandwidth-limited", icon: "gauge", message: "线路受到带宽限制" },+ { title: "编码受限", comic: "encoder-limited", icon: "tv", message: "编码受到限制" },+];++export function OverlayPreviewPage() {+ const { vis } = useCopy();+ return (+ <div className="lr-app">+ <AppHeader />+ <main className="lr-room lr-overlay-preview">+ <header className="lr-overlay-preview-head">+ <h1>Overlay preview</h1>+ <p>{vis ? "状态漫画与重试提示预览" : "Stage overlay states"}</p>+ </header>+ <div className="lr-overlay-preview-grid">+ {STATES.map((state) => (+ <section className="lr-overlay-preview-card" key={state.title}>+ <h2>{state.title}</h2>+ <StageTv chin={state.progress ? "busy" : "off"} label={state.message}>+ <StageOverlay+ icon={state.icon}+ comic={state.comic}+ message={state.message}+ progress={state.progress}+ spin={state.icon === "loader"}+ transition={state.icon === "loader"}+ dim+ />+ </StageTv>+ </section>+ ))}+ </div>+ </main>+ </div>+ );+}diff --git a/src/client/pages/TooltipPreviewPage.tsx b/src/client/pages/TooltipPreviewPage.tsxnew file mode 100644index 00000000..d57df139--- /dev/null+++ b/src/client/pages/TooltipPreviewPage.tsx@@ -0,0 +1,36 @@+import { AppHeader } from "../components/living/Header";+import { ComicTooltip } from "../components/living/ComicTooltip";+import { HINT_KINDS, HintComic, type HintKind } from "../components/living/hints";+import { useCopy } from "../ui/copy";++export function TooltipPreviewPage() {+ const { vis } = useCopy();+ return (+ <div className="lr-app">+ <AppHeader />+ <main className="lr-room lr-tooltip-preview">+ <header className="lr-tooltip-preview-head">+ <h1>Tooltip preview</h1>+ <p>{vis ? "所有操作提示漫画" : "All control hint comics"}</p>+ </header>+ <div className="lr-tooltip-preview-grid">+ {HINT_KINDS.map((kind: HintKind) => (+ <section className="lr-tooltip-preview-card" key={kind}>+ <header>+ <code>{kind}</code>+ <ComicTooltip kind={kind} place="below">+ <button type="button" aria-label={`Preview ${kind}`} className="lr-tooltip-preview-trigger">+ ✦+ </button>+ </ComicTooltip>+ </header>+ <div className="lr-tooltip-preview-art">+ <HintComic kind={kind} size={320} />+ </div>+ </section>+ ))}+ </div>+ </main>+ </div>+ );+}diff --git a/src/client/pages/ViewerPage.tsx b/src/client/pages/ViewerPage.tsxindex 48c87327..977b36be 100644--- a/src/client/pages/ViewerPage.tsx+++ b/src/client/pages/ViewerPage.tsx@@ -2461,14 +2461,23 @@ export function ViewerPage({assignedRoute.revision === presentationState.revision? assignedRoute.connectionAttempt: undefined;- const stageMessage = connectionAttempt- ? t("viewer.msg.connectionAttempt", {- current: String(connectionAttempt.current),- total: String(connectionAttempt.total),+ // Keep the first candidate quiet; the counter describes a retry, not normal setup.+ const retryAttempt =+ connectionAttempt && connectionAttempt.current > 1+ ? {+ ...connectionAttempt,+ current: connectionAttempt.current - 1,+ total: Math.max(1, connectionAttempt.total - 1),+ }+ : undefined;+ const stageMessage = retryAttempt+ ? t("viewer.msg.connectionRetry", {+ current: String(retryAttempt.current),+ total: String(retryAttempt.total),}): t(presentation.messageKey);- const connectionProgress = connectionAttempt- ? `${connectionAttempt.current}/${connectionAttempt.total}`+ const connectionProgress = retryAttempt+ ? `${retryAttempt.current}/${retryAttempt.total}`: undefined;const noticeVisual = presentation.noticeKey? viewerNoticeVisual(presentation.noticeKey)diff --git a/src/client/styles.css b/src/client/styles.cssindex 51d51777..4cba9de8 100644--- a/src/client/styles.css+++ b/src/client/styles.css@@ -453,8 +453,28 @@ body.lr-theater-open { overflow: hidden; }}.lr-tv-overlay.is-dim { background: rgba(10, 16, 28, .62); }.lr-tv-status-content { display: flex; flex-direction: column; align-items: center; gap: 14px; }+.lr-tv-progress { display: inline-flex; align-items: center; gap: 6px; }+.lr-overlay-preview { max-width: 1440px; }+.lr-overlay-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 8px 0 20px; }+.lr-overlay-preview-head h1 { margin: 0; font-size: 1.1rem; }+.lr-overlay-preview-head p { margin: 0; color: var(--muted); }+.lr-overlay-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; }+.lr-overlay-preview-card { min-width: 0; }+.lr-overlay-preview-card h2 { margin: 0 0 8px; font-size: .85rem; color: var(--muted); }+.lr-overlay-preview-card .lr-tv { width: 100%; padding: 7px 7px 0; border-width: 2px; border-radius: 16px 16px 12px 12px; }+.lr-overlay-preview-card .lr-tv-screen { border-radius: 9px 9px 5px 5px; }+.lr-tooltip-preview { max-width: 1440px; }+.lr-tooltip-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 8px 0 20px; }+.lr-tooltip-preview-head h1 { margin: 0; font-size: 1.1rem; }+.lr-tooltip-preview-head p { margin: 0; color: var(--muted); }+.lr-tooltip-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; }+.lr-tooltip-preview-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--panel) 88%, transparent); }+.lr-tooltip-preview-card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }+.lr-tooltip-preview-card code { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }+.lr-tooltip-preview-trigger { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--accent); cursor: help; }+.lr-tooltip-preview-art { min-height: 106px; display: grid; place-items: center; overflow: hidden; }+.lr-tooltip-preview-art svg { max-width: 100%; height: auto; }.lr-tv-overlay.has-comic { gap: 8px; padding: 10px; }-.lr-tv-overlay.has-comic .lr-tv-status-content { flex-direction: row; gap: 8px; }.lr-tv-overlay.has-comic .lr-brand-loader,.lr-tv-overlay.has-comic .lr-tv-big { width: 40px; height: 40px; }.lr-tv-overlay.has-comic .lr-brand-mark { width: 32px; height: 32px; }diff --git a/src/client/ui/animation.ts b/src/client/ui/animation.tsindex 163cb728..683745d8 100644--- a/src/client/ui/animation.ts+++ b/src/client/ui/animation.ts@@ -18,12 +18,17 @@ export function bindSvgReplayOnPointerEnter(graphic: SVGSVGElement,): () => void {const owner =- graphic.closest<HTMLElement>("button, a, [role='button']") ?? graphic;- const handlePointerEnter = (event: Event) => {- if ((event as PointerEvent).pointerType !== "touch") {- replaySvgAnimations(graphic);+ graphic.closest<HTMLElement>(+ "button, a, [role='button'], [role='img'], .lr-tv-big",+ ) ?? graphic;+ const handlePointerOver = (event: Event) => {+ const pointer = event as PointerEvent;+ if (pointer.pointerType === "touch") return;+ if (pointer.relatedTarget instanceof Node && owner.contains(pointer.relatedTarget)) {+ return;}+ replaySvgAnimations(graphic);};- owner.addEventListener("pointerenter", handlePointerEnter);- return () => owner.removeEventListener("pointerenter", handlePointerEnter);+ owner.addEventListener("pointerover", handlePointerOver);+ return () => owner.removeEventListener("pointerover", handlePointerOver);}