mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-03 20:09:47 +08:00
* fix(desktop): improve startup endpoint error feedback Signed-off-by: Dash <dashhuang@gmail.com> * fix(desktop): show clipboard failure feedback Signed-off-by: Dash <dashhuang@gmail.com> --------- Signed-off-by: Dash <dashhuang@gmail.com>
640 lines
18 KiB
HTML
640 lines
18 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Cindy 启动提示原型</title>
|
|
<style>
|
|
:root {
|
|
color-scheme: light;
|
|
--surface: #f8f8f6;
|
|
--surface-elevated: #ffffff;
|
|
--surface-chip: #e5e5e5;
|
|
--surface-hover: #ededeb;
|
|
--border-default: #d7d7d4;
|
|
--text-primary: #262626;
|
|
--text-secondary: #737373;
|
|
--text-tertiary: #a3a3a3;
|
|
--text-placeholder: #c4c4c4;
|
|
--accent-cta-bg: #000000;
|
|
--accent-cta-fg: #ffffff;
|
|
--warning-accent: #ea6b17;
|
|
--overlay-modal: rgba(20, 20, 18, 0.32);
|
|
--radius-card: 12px;
|
|
--radius-control: 8px;
|
|
--radius-pill: 9999px;
|
|
}
|
|
|
|
[data-theme="dark"] {
|
|
color-scheme: dark;
|
|
--surface: #1f1f1e;
|
|
--surface-elevated: #2c2c2a;
|
|
--surface-chip: #3c3c3a;
|
|
--surface-hover: #454543;
|
|
--border-default: #3c3c3a;
|
|
--text-primary: #d4d4d4;
|
|
--text-secondary: #a3a3a3;
|
|
--text-tertiary: #737373;
|
|
--text-placeholder: #525252;
|
|
--accent-cta-bg: #ffffff;
|
|
--accent-cta-fg: #000000;
|
|
--overlay-modal: rgba(0, 0, 0, 0.56);
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html,
|
|
body {
|
|
min-height: 100%;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
background: var(--surface);
|
|
color: var(--text-primary);
|
|
font-family:
|
|
Inter,
|
|
system-ui,
|
|
-apple-system,
|
|
BlinkMacSystemFont,
|
|
"Segoe UI",
|
|
sans-serif;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
|
|
button,
|
|
select {
|
|
font: inherit;
|
|
}
|
|
|
|
.prototype-shell {
|
|
min-height: 100vh;
|
|
padding: 28px;
|
|
background:
|
|
linear-gradient(
|
|
90deg,
|
|
transparent 0,
|
|
transparent calc(50% - 520px),
|
|
var(--border-default) calc(50% - 520px),
|
|
transparent calc(50% - 519px),
|
|
transparent 100%
|
|
),
|
|
var(--surface);
|
|
}
|
|
|
|
.prototype-toolbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 16px;
|
|
max-width: 1080px;
|
|
margin: 0 auto 26px;
|
|
}
|
|
|
|
.prototype-label {
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
letter-spacing: 0.08em;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.toolbar-controls {
|
|
display: flex;
|
|
gap: 8px;
|
|
align-items: center;
|
|
}
|
|
|
|
.toolbar-controls select,
|
|
.theme-toggle {
|
|
min-height: 34px;
|
|
padding: 0 12px;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: var(--radius-pill);
|
|
background: var(--surface-elevated);
|
|
color: var(--text-primary);
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.app-stage {
|
|
position: relative;
|
|
min-height: calc(100vh - 112px);
|
|
max-width: 1080px;
|
|
margin: 0 auto;
|
|
overflow: hidden;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: var(--radius-card);
|
|
background: var(--surface);
|
|
}
|
|
|
|
.app-chrome {
|
|
display: grid;
|
|
grid-template-columns: 190px 1fr;
|
|
min-height: 580px;
|
|
}
|
|
|
|
.sidebar {
|
|
border-right: 1px solid var(--border-default);
|
|
padding: 24px 18px;
|
|
}
|
|
|
|
.brand {
|
|
display: flex;
|
|
gap: 9px;
|
|
align-items: center;
|
|
margin-bottom: 42px;
|
|
font-size: 18px;
|
|
letter-spacing: -0.03em;
|
|
}
|
|
|
|
.brand-mark {
|
|
display: inline-grid;
|
|
place-items: center;
|
|
width: 24px;
|
|
height: 24px;
|
|
border-radius: 50%;
|
|
background: var(--text-primary);
|
|
color: var(--surface);
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.nav-item {
|
|
height: 34px;
|
|
margin: 5px 0;
|
|
padding: 0 11px;
|
|
border-radius: var(--radius-pill);
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
line-height: 34px;
|
|
}
|
|
|
|
.nav-item.active {
|
|
background: var(--surface-chip);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.workspace {
|
|
position: relative;
|
|
padding: 32px 40px;
|
|
}
|
|
|
|
.workspace-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding-bottom: 20px;
|
|
border-bottom: 1px solid var(--border-default);
|
|
}
|
|
|
|
.workspace-title {
|
|
font-size: 22px;
|
|
font-weight: 500;
|
|
letter-spacing: -0.03em;
|
|
}
|
|
.workspace-meta {
|
|
color: var(--text-tertiary);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.empty-state {
|
|
display: grid;
|
|
place-items: center;
|
|
min-height: 390px;
|
|
color: var(--text-secondary);
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-state p {
|
|
max-width: 270px;
|
|
margin: 10px 0 0;
|
|
font-size: 14px;
|
|
line-height: 1.55;
|
|
}
|
|
|
|
.empty-orb {
|
|
width: 58px;
|
|
height: 58px;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: 50%;
|
|
background: var(--surface-elevated);
|
|
}
|
|
|
|
.modal-scrim {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: grid;
|
|
place-items: center;
|
|
padding: 24px;
|
|
background: var(--overlay-modal);
|
|
}
|
|
|
|
.dialog {
|
|
width: min(100%, 440px);
|
|
padding: 24px;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: var(--radius-card);
|
|
background: var(--surface-elevated);
|
|
}
|
|
|
|
.dialog-head {
|
|
display: flex;
|
|
gap: 14px;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.status-icon {
|
|
display: grid;
|
|
flex: 0 0 auto;
|
|
place-items: center;
|
|
width: 30px;
|
|
height: 30px;
|
|
border: 1px solid
|
|
color-mix(in srgb, var(--warning-accent) 45%, var(--border-default));
|
|
border-radius: 50%;
|
|
color: var(--warning-accent);
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.dialog-title {
|
|
margin: 1px 0 0;
|
|
font-size: 22px;
|
|
font-weight: 500;
|
|
letter-spacing: -0.03em;
|
|
}
|
|
|
|
.dialog-body {
|
|
margin: 20px 0 0 44px;
|
|
color: var(--text-secondary);
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.error-panel {
|
|
margin: 18px 0 0 44px;
|
|
padding: 12px 14px;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: var(--radius-control);
|
|
background: var(--surface);
|
|
}
|
|
|
|
.error-label {
|
|
color: var(--text-tertiary);
|
|
font-size: 11px;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.error-value {
|
|
display: block;
|
|
margin-top: 4px;
|
|
color: var(--text-primary);
|
|
font-family:
|
|
"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
|
|
Consolas, monospace;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
letter-spacing: 0.04em;
|
|
}
|
|
|
|
.dialog-note {
|
|
margin: 12px 0 0 44px;
|
|
color: var(--text-tertiary);
|
|
font-size: 12px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.dialog-actions {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
justify-content: flex-end;
|
|
gap: 8px;
|
|
margin-top: 26px;
|
|
}
|
|
|
|
.button {
|
|
min-height: 38px;
|
|
padding: 0 16px;
|
|
border-radius: var(--radius-pill);
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
transition:
|
|
background 120ms ease,
|
|
border-color 120ms ease,
|
|
transform 120ms ease;
|
|
}
|
|
|
|
.button:active {
|
|
transform: translateY(1px);
|
|
}
|
|
.button:focus-visible,
|
|
.toolbar-controls select:focus-visible,
|
|
.theme-toggle:focus-visible {
|
|
outline: 2px solid #417cdd;
|
|
outline-offset: 2px;
|
|
}
|
|
|
|
.button-primary {
|
|
border: 1px solid var(--accent-cta-bg);
|
|
background: var(--accent-cta-bg);
|
|
color: var(--accent-cta-fg);
|
|
}
|
|
.button-primary:hover {
|
|
opacity: 0.88;
|
|
}
|
|
.button-secondary {
|
|
border: 1px solid var(--border-default);
|
|
background: var(--surface-elevated);
|
|
color: var(--text-primary);
|
|
}
|
|
.button-secondary:hover {
|
|
background: var(--surface-hover);
|
|
}
|
|
.button-quiet {
|
|
border: 1px solid transparent;
|
|
background: transparent;
|
|
color: var(--text-secondary);
|
|
}
|
|
.button-quiet:hover {
|
|
background: var(--surface-hover);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.toast {
|
|
position: absolute;
|
|
right: 24px;
|
|
bottom: 24px;
|
|
max-width: 270px;
|
|
padding: 10px 13px;
|
|
border: 1px solid var(--border-default);
|
|
border-radius: var(--radius-pill);
|
|
background: var(--surface-elevated);
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
opacity: 0;
|
|
transform: translateY(8px);
|
|
pointer-events: none;
|
|
transition:
|
|
opacity 160ms ease,
|
|
transform 160ms ease;
|
|
}
|
|
|
|
.toast.visible {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
@media (max-width: 720px) {
|
|
.prototype-shell {
|
|
padding: 16px;
|
|
}
|
|
.prototype-toolbar {
|
|
align-items: flex-start;
|
|
flex-direction: column;
|
|
}
|
|
.app-chrome {
|
|
display: block;
|
|
}
|
|
.sidebar {
|
|
display: none;
|
|
}
|
|
.workspace {
|
|
min-height: 620px;
|
|
padding: 22px;
|
|
}
|
|
.dialog {
|
|
padding: 20px;
|
|
}
|
|
.dialog-body,
|
|
.dialog-note,
|
|
.error-panel {
|
|
margin-left: 0;
|
|
}
|
|
.dialog-actions {
|
|
justify-content: stretch;
|
|
}
|
|
.button {
|
|
flex: 1 1 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body data-theme="light">
|
|
<main class="prototype-shell">
|
|
<div class="prototype-toolbar">
|
|
<div>
|
|
<div class="prototype-label">Cindy · Startup prompt prototype</div>
|
|
</div>
|
|
<div class="toolbar-controls" aria-label="原型控制">
|
|
<select id="failure-kind" aria-label="失败类型">
|
|
<option value="network">网络连接失败</option>
|
|
<option value="config">配置暂不可用</option>
|
|
</select>
|
|
<select id="cache-state" aria-label="历史配置状态">
|
|
<option value="empty">新设备 · 无历史配置</option>
|
|
<option value="available">已有历史配置</option>
|
|
</select>
|
|
<button id="theme-toggle" class="theme-toggle" type="button">
|
|
切换 Dark
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<section class="app-stage" aria-label="Cindy 启动失败界面预览">
|
|
<div class="app-chrome" aria-hidden="true">
|
|
<aside class="sidebar">
|
|
<div class="brand">
|
|
<span class="brand-mark">C</span><span>Cindy</span>
|
|
</div>
|
|
<div class="nav-item active">新任务</div>
|
|
<div class="nav-item">最近任务</div>
|
|
<div class="nav-item">设置</div>
|
|
</aside>
|
|
<div class="workspace">
|
|
<div class="workspace-header">
|
|
<div class="workspace-title">准备开始</div>
|
|
<div class="workspace-meta">启动准备中</div>
|
|
</div>
|
|
<div class="empty-state">
|
|
<div>
|
|
<div class="empty-orb"></div>
|
|
<p>Cindy 正在准备工作区。启动后,你可以在这里开始新的任务。</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-scrim">
|
|
<section
|
|
class="dialog"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
aria-labelledby="dialog-title"
|
|
aria-describedby="dialog-body"
|
|
>
|
|
<div class="dialog-head">
|
|
<div class="status-icon" aria-hidden="true">!</div>
|
|
<h1 id="dialog-title" class="dialog-title">Cindy 暂时无法连接</h1>
|
|
</div>
|
|
<p id="dialog-body" class="dialog-body">
|
|
启动时未能连接到 Cindy
|
|
服务。请确认设备已联网,然后重新尝试启动。如果正在使用 Proxy
|
|
或公司网络,可以切换网络后再试。
|
|
</p>
|
|
<div class="error-panel" aria-label="错误信息">
|
|
<div class="error-label">错误信息</div>
|
|
<code id="error-value" class="error-value"
|
|
>ERR_CONNECTION_RESET</code
|
|
>
|
|
</div>
|
|
<p class="dialog-note">
|
|
这台设备没有可用的历史配置,需要恢复连接后才能继续启动。需要反馈时,可以复制诊断信息后直接粘贴给我们。
|
|
</p>
|
|
<div class="dialog-actions">
|
|
<button
|
|
class="button button-primary"
|
|
data-action="retry"
|
|
type="button"
|
|
>
|
|
重试启动 Cindy
|
|
</button>
|
|
<button
|
|
class="button button-secondary"
|
|
data-action="copy"
|
|
type="button"
|
|
>
|
|
复制诊断信息
|
|
</button>
|
|
<button
|
|
class="button button-secondary"
|
|
data-action="offline"
|
|
type="button"
|
|
hidden
|
|
>
|
|
用上次配置启动
|
|
</button>
|
|
<button
|
|
class="button button-quiet"
|
|
data-action="exit"
|
|
type="button"
|
|
>
|
|
退出 Cindy
|
|
</button>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
|
</section>
|
|
</main>
|
|
|
|
<script>
|
|
const copy = {
|
|
network: {
|
|
title: "Cindy 暂时无法连接",
|
|
body: "启动时未能连接到 Cindy 服务。请确认设备已联网,然后重新尝试启动。如果正在使用 Proxy 或公司网络,可以切换网络后再试。",
|
|
reason: "fetch-failed:ERR_CONNECTION_RESET",
|
|
},
|
|
config: {
|
|
title: "Cindy 暂时无法启动",
|
|
body: "Cindy 暂时无法完成启动。请稍后重新尝试;如果问题持续出现,请联系技术支持。",
|
|
reason: "invalid-json",
|
|
},
|
|
};
|
|
|
|
const body = document.body;
|
|
const kindSelect = document.querySelector("#failure-kind");
|
|
const cacheSelect = document.querySelector("#cache-state");
|
|
const themeToggle = document.querySelector("#theme-toggle");
|
|
const title = document.querySelector("#dialog-title");
|
|
const dialogBody = document.querySelector("#dialog-body");
|
|
const errorValue = document.querySelector("#error-value");
|
|
const note = document.querySelector(".dialog-note");
|
|
const offlineButton = document.querySelector('[data-action="offline"]');
|
|
const toast = document.querySelector("#toast");
|
|
|
|
function showToast(message) {
|
|
toast.textContent = message;
|
|
toast.classList.add("visible");
|
|
window.clearTimeout(showToast.timer);
|
|
showToast.timer = window.setTimeout(
|
|
() => toast.classList.remove("visible"),
|
|
2200,
|
|
);
|
|
}
|
|
|
|
function renderFailure(kind) {
|
|
const current = copy[kind];
|
|
const hasCachedConfiguration = cacheSelect.value === "available";
|
|
title.textContent = current.title;
|
|
dialogBody.textContent = current.body;
|
|
errorValue.textContent = current.reason.replace("fetch-failed:", "");
|
|
note.textContent =
|
|
kind === "network" && !hasCachedConfiguration
|
|
? "这台设备没有可用的历史配置,需要恢复连接后才能继续启动。需要反馈时,可以复制诊断信息后直接粘贴给我们。"
|
|
: "需要反馈时,可以复制诊断信息后直接粘贴给我们。";
|
|
offlineButton.hidden = kind !== "network" || !hasCachedConfiguration;
|
|
}
|
|
|
|
function buildDiagnostics(kind) {
|
|
const current = copy[kind];
|
|
return [
|
|
"Cindy startup diagnostics",
|
|
`kind=${kind}`,
|
|
`reason=${current.reason}`,
|
|
"source=https://hotfix.cindy.app/cindy/endpoint.json",
|
|
kind === "network"
|
|
? "diagnosis=proxy=DIRECT dns=ok tcp=ok tls=connection-reset"
|
|
: "diagnosis=n/a",
|
|
"logPath=/Users/example/Library/Logs/Cindy/endpoint-netlog/capture.json",
|
|
`savedConfiguration=${cacheSelect.value === "available" ? "available" : "none"}`,
|
|
].join("\n");
|
|
}
|
|
|
|
async function copyDiagnostics() {
|
|
const diagnostics = buildDiagnostics(kindSelect.value);
|
|
try {
|
|
await navigator.clipboard.writeText(diagnostics);
|
|
} catch {
|
|
const textarea = document.createElement("textarea");
|
|
textarea.value = diagnostics;
|
|
textarea.style.position = "fixed";
|
|
textarea.style.opacity = "0";
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
document.execCommand("copy");
|
|
textarea.remove();
|
|
}
|
|
showToast("诊断信息已复制,可以直接粘贴到反馈消息中");
|
|
}
|
|
|
|
kindSelect.addEventListener("change", (event) => {
|
|
renderFailure(event.target.value);
|
|
});
|
|
|
|
cacheSelect.addEventListener("change", () => {
|
|
renderFailure(kindSelect.value);
|
|
});
|
|
|
|
themeToggle.addEventListener("click", () => {
|
|
const isDark = body.dataset.theme === "dark";
|
|
body.dataset.theme = isDark ? "light" : "dark";
|
|
themeToggle.textContent = isDark ? "切换 Dark" : "切换 Light";
|
|
});
|
|
|
|
document.querySelectorAll("[data-action]").forEach((button) => {
|
|
button.addEventListener("click", () => {
|
|
const action = button.dataset.action;
|
|
if (action === "retry") showToast("正在重新尝试启动…");
|
|
if (action === "copy") void copyDiagnostics();
|
|
if (action === "offline") showToast("将使用上次配置启动");
|
|
if (action === "exit") showToast("原型中不会真正退出应用");
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|