Compare commits

...

2 Commits

Author SHA1 Message Date
6c1b8e95c8 feat: 历史列表添加交错滑入动画
- renderHistory 改为索引循环,设置 CSS 变量 --i 实现交错延迟
- 最大交错层级限制为 10(400ms),避免过长等待
2026-03-02 05:23:47 +08:00
2c322f5ab1 style: 重新设计前端 UI 主题与视觉效果
- 色彩系统从冷黑灰调整为带靛蓝底色的暖深色主题
- 强调色从 #3b82f6 蓝色替换为 #6366f1 Indigo
- 麦克风按钮增大至 96px,添加渐变背景与录音波纹环动画
- 状态指示器改为 pill 胶囊形,连接态带发光效果
- 预览区录音时显示 indigo 边框光晕与顶部渐变
- Toast 添加毛玻璃背景与弹出位移动画
- 历史卡片添加 slide-up 滑入动效支持
- 新增 theme-color meta 匹配深色主题
2026-03-02 05:23:39 +08:00
3 changed files with 282 additions and 104 deletions

View File

@@ -201,9 +201,12 @@ function showToast(msg: string): void {
const toast = q("#toast"); const toast = q("#toast");
toast.textContent = msg; toast.textContent = msg;
toast.classList.add("show"); toast.classList.add("show");
const timer = (toast as HTMLElement & { _timer?: ReturnType<typeof setTimeout> })._timer; const timer = (
toast as HTMLElement & { _timer?: ReturnType<typeof setTimeout> }
)._timer;
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
(toast as HTMLElement & { _timer?: ReturnType<typeof setTimeout> })._timer = setTimeout(() => { (toast as HTMLElement & { _timer?: ReturnType<typeof setTimeout> })._timer =
setTimeout(() => {
toast.classList.remove("show"); toast.classList.remove("show");
}, 2000); }, 2000);
} }
@@ -331,8 +334,10 @@ function renderHistory(): void {
return; return;
} }
(historyEmpty as HTMLElement).style.display = "none"; (historyEmpty as HTMLElement).style.display = "none";
for (const item of items) { for (let i = 0; i < items.length; i++) {
const item = items[i];
const li = document.createElement("li"); const li = document.createElement("li");
li.style.setProperty("--i", String(Math.min(i, 10)));
li.innerHTML = li.innerHTML =
`<span class="hist-text">${escapeHtml(item.text)}</span>` + `<span class="hist-text">${escapeHtml(item.text)}</span>` +
`<span class="hist-time">${formatTime(item.ts)}</span>`; `<span class="hist-time">${formatTime(item.ts)}</span>`;

View File

@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="theme-color" content="#08080d">
<title>VoicePaste</title> <title>VoicePaste</title>
</head> </head>
<body> <body>
@@ -24,6 +25,7 @@
</section> </section>
<section id="mic-section"> <section id="mic-section">
<div class="mic-wrapper">
<button id="mic-btn" type="button" disabled> <button id="mic-btn" type="button" disabled>
<svg viewBox="0 0 24 24" width="48" height="48" fill="currentColor" aria-label="麦克风" role="img"> <svg viewBox="0 0 24 24" width="48" height="48" fill="currentColor" aria-label="麦克风" role="img">
<title>麦克风</title> <title>麦克风</title>
@@ -31,6 +33,13 @@
<path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/> <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>
</svg> </svg>
</button> </button>
<div class="mic-rings" aria-hidden="true">
<span class="ring"></span>
<span class="ring"></span>
<span class="ring"></span>
</div>
</div>
<p class="mic-hint">按住说话</p>
</section> </section>
<section id="history-section"> <section id="history-section">

View File

@@ -7,17 +7,25 @@
} }
:root { :root {
--bg: #0a0a0a; /* Warm dark palette — subtle indigo undertone */
--surface: #161616; --bg: #08080d;
--surface-hover: #1e1e1e; --surface: #111117;
--border: #2a2a2a; --surface-hover: #17171e;
--text: #e8e8e8; --surface-active: #1c1c25;
--text-dim: #888; --border: #1e1e2a;
--accent: #3b82f6; --border-active: #2c2c3e;
--accent-glow: rgba(59, 130, 246, 0.3); --text: #eaeaef;
--danger: #ef4444; --text-secondary: #9e9eb5;
--success: #22c55e; --text-dim: #5a5a6e;
--radius: 12px; --accent: #6366f1;
--accent-hover: #818cf8;
--accent-glow: rgba(99, 102, 241, 0.2);
--accent-glow-md: rgba(99, 102, 241, 0.35);
--accent-glow-lg: rgba(99, 102, 241, 0.08);
--danger: #f43f5e;
--success: #34d399;
--radius: 14px;
--radius-sm: 8px;
--safe-top: env(safe-area-inset-top, 0px); --safe-top: env(safe-area-inset-top, 0px);
--safe-bottom: env(safe-area-inset-bottom, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
} }
@@ -26,8 +34,8 @@ html,
body { body {
height: 100%; height: 100%;
font-family: font-family:
-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC",
sans-serif; "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
background: var(--bg); background: var(--bg);
color: var(--text); color: var(--text);
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
@@ -37,55 +45,90 @@ body {
overflow: hidden; overflow: hidden;
} }
/* Subtle ambient glow at top */
body::after {
content: "";
position: fixed;
top: -30%;
left: 50%;
transform: translateX(-50%);
width: 600px;
height: 600px;
background: radial-gradient(
circle,
rgba(99, 102, 241, 0.04) 0%,
transparent 70%
);
pointer-events: none;
z-index: 0;
}
#app { #app {
position: relative;
z-index: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
max-width: 480px; max-width: 480px;
margin: 0 auto; margin: 0 auto;
padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); padding: calc(16px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
} }
/* Header */ /* ─── Header ─── */
header { header {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 8px 0 16px; padding: 8px 0 20px;
flex-shrink: 0; flex-shrink: 0;
} }
header h1 { header h1 {
font-size: 20px; font-size: 22px;
font-weight: 600; font-weight: 700;
letter-spacing: -0.02em; letter-spacing: -0.03em;
} }
.status { .status {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 7px;
font-size: 13px; font-size: 12px;
font-weight: 500;
color: var(--text-dim); color: var(--text-dim);
padding: 5px 12px;
border-radius: 20px;
background: var(--surface);
border: 1px solid var(--border);
transition: all 0.25s ease;
} }
.status .dot { .status .dot {
width: 8px; width: 7px;
height: 8px; height: 7px;
border-radius: 50%; border-radius: 50%;
background: var(--text-dim); background: var(--text-dim);
transition: background 0.3s; transition: all 0.3s ease;
flex-shrink: 0;
}
.status.connected {
border-color: rgba(52, 211, 153, 0.15);
} }
.status.connected .dot { .status.connected .dot {
background: var(--success); background: var(--success);
box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
} }
.status.disconnected .dot { .status.disconnected .dot {
background: var(--danger); background: var(--danger);
box-shadow: 0 0 6px rgba(244, 63, 94, 0.4);
} }
.status.connecting .dot { .status.connecting .dot {
background: var(--accent); background: var(--accent);
animation: pulse 1.2s ease-in-out infinite; animation: pulse 1.4s ease-in-out infinite;
} }
@keyframes pulse { @keyframes pulse {
@@ -94,97 +137,175 @@ header h1 {
opacity: 1; opacity: 1;
} }
50% { 50% {
opacity: 0.4; opacity: 0.3;
} }
} }
/* Preview */ /* ─── Preview ─── */
#preview-section { #preview-section {
flex-shrink: 0; flex-shrink: 0;
padding-bottom: 16px; padding-bottom: 12px;
} }
.preview-box { .preview-box {
background: var(--surface); background: var(--surface);
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: var(--radius); border-radius: var(--radius);
padding: 16px; padding: 16px 18px;
min-height: 80px; min-height: 80px;
max-height: 160px; max-height: 160px;
overflow-y: auto; overflow-y: auto;
transition: border-color 0.3s; transition:
border-color 0.3s ease,
box-shadow 0.3s ease,
background 0.3s ease;
} }
.preview-box.active { .preview-box.active {
border-color: var(--accent); border-color: rgba(99, 102, 241, 0.4);
box-shadow: 0 0 0 1px var(--accent-glow); box-shadow:
0 0 0 1px var(--accent-glow),
0 4px 24px -4px rgba(99, 102, 241, 0.15);
background: linear-gradient(
180deg,
rgba(99, 102, 241, 0.03) 0%,
var(--surface) 100%
);
} }
#preview-text { #preview-text {
font-size: 16px; font-size: 16px;
line-height: 1.5; line-height: 1.6;
word-break: break-word; word-break: break-word;
} }
#preview-text.placeholder { #preview-text.placeholder {
color: var(--text-dim); color: var(--text-dim);
font-style: italic;
} }
/* Mic Button */ /* ─── Mic Button ─── */
#mic-section { #mic-section {
display: flex; display: flex;
justify-content: center; flex-direction: column;
padding: 24px 0; align-items: center;
padding: 20px 0 16px;
flex-shrink: 0; flex-shrink: 0;
gap: 14px;
}
.mic-wrapper {
position: relative;
display: flex;
align-items: center;
justify-content: center;
} }
#mic-btn { #mic-btn {
width: 88px; position: relative;
height: 88px; z-index: 1;
width: 96px;
height: 96px;
border-radius: 50%; border-radius: 50%;
border: 2px solid var(--border); border: 2px solid var(--border);
background: var(--surface); background: linear-gradient(145deg, var(--surface-hover), var(--surface));
color: var(--text-dim); color: var(--text-secondary);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
-webkit-user-select: none; -webkit-user-select: none;
touch-action: none; touch-action: none;
box-shadow:
0 2px 12px rgba(0, 0, 0, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#mic-btn svg {
transition: transform 0.2s ease;
} }
#mic-btn:disabled { #mic-btn:disabled {
opacity: 0.4; opacity: 0.3;
cursor: not-allowed; cursor: not-allowed;
} }
#mic-btn:not(:disabled):active, #mic-btn:not(:disabled):active,
#mic-btn.recording { #mic-btn.recording {
background: var(--accent); background: var(--accent);
border-color: var(--accent); border-color: var(--accent-hover);
color: #fff; color: #fff;
transform: scale(1.08); transform: scale(1.06);
box-shadow: 0 0 24px var(--accent-glow); box-shadow:
0 0 32px var(--accent-glow-md),
0 0 80px var(--accent-glow);
} }
#mic-btn.recording { #mic-btn.recording {
animation: mic-pulse 1s ease-in-out infinite; animation: mic-breathe 1.8s ease-in-out infinite;
} }
@keyframes mic-pulse { @keyframes mic-breathe {
0%, 0%,
100% { 100% {
box-shadow: 0 0 24px var(--accent-glow); box-shadow:
0 0 32px var(--accent-glow-md),
0 0 80px var(--accent-glow);
} }
50% { 50% {
box-shadow: box-shadow:
0 0 48px var(--accent-glow), 0 0 48px var(--accent-glow-md),
0 0 80px rgba(59, 130, 246, 0.15); 0 0 120px var(--accent-glow),
0 0 200px var(--accent-glow-lg);
} }
} }
/* History */
/* Wave rings — radiate outward when recording */
.mic-rings {
position: absolute;
inset: 0;
pointer-events: none;
}
.mic-rings .ring {
position: absolute;
inset: 0;
border-radius: 50%;
border: 1.5px solid var(--accent);
opacity: 0;
}
#mic-btn.recording + .mic-rings .ring {
animation: ring-expand 2.4s cubic-bezier(0.2, 0, 0.2, 1) infinite;
}
#mic-btn.recording + .mic-rings .ring:nth-child(2) {
animation-delay: 0.8s;
}
#mic-btn.recording + .mic-rings .ring:nth-child(3) {
animation-delay: 1.6s;
}
@keyframes ring-expand {
0% {
transform: scale(1);
opacity: 0.35;
}
100% {
transform: scale(2);
opacity: 0;
}
}
.mic-hint {
font-size: 13px;
color: var(--text-dim);
letter-spacing: 0.01em;
transition: color 0.3s ease;
}
/* ─── History ─── */
#history-section { #history-section {
flex: 1; flex: 1;
min-height: 0; min-height: 0;
@@ -192,102 +313,145 @@ header h1 {
flex-direction: column; flex-direction: column;
overflow: hidden; overflow: hidden;
} }
.history-header { .history-header {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding-bottom: 8px; padding-bottom: 10px;
flex-shrink: 0; flex-shrink: 0;
} }
.history-header h2 { .history-header h2 {
font-size: 15px; font-size: 13px;
font-weight: 600; font-weight: 600;
color: var(--text-dim); color: var(--text-dim);
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.04em; letter-spacing: 0.06em;
} }
.text-btn { .text-btn {
background: none; background: none;
border: none; border: none;
color: var(--accent); color: var(--text-dim);
font-size: 13px; font-size: 12px;
font-weight: 500;
cursor: pointer; cursor: pointer;
padding: 4px 8px; padding: 4px 10px;
border-radius: 6px; border-radius: var(--radius-sm);
transition: background 0.2s; transition: all 0.15s ease;
} }
.text-btn:active { .text-btn:active {
background: rgba(59, 130, 246, 0.1); color: var(--danger);
background: rgba(244, 63, 94, 0.08);
} }
#history-list { #history-list {
list-style: none; list-style: none;
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
#history-list li { #history-list li {
background: var(--surface); background: var(--surface);
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: var(--radius); border-radius: var(--radius);
padding: 12px 14px; padding: 14px 16px;
margin-bottom: 8px; margin-bottom: 8px;
font-size: 14px; font-size: 14px;
line-height: 1.4; line-height: 1.5;
cursor: pointer; cursor: pointer;
transition: background 0.15s; transition: all 0.15s ease;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
gap: 10px; gap: 12px;
animation: slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
animation-delay: calc(var(--i, 0) * 40ms);
} }
#history-list li:active { #history-list li:active {
background: var(--surface-hover); background: var(--surface-active);
border-color: var(--border-active);
transform: scale(0.985);
} }
#history-list li .hist-text { #history-list li .hist-text {
flex: 1; flex: 1;
word-break: break-word; word-break: break-word;
} }
#history-list li .hist-time { #history-list li .hist-time {
font-size: 11px; font-size: 11px;
color: var(--text-dim); color: var(--text-dim);
white-space: nowrap; white-space: nowrap;
flex-shrink: 0; flex-shrink: 0;
padding-top: 2px; padding-top: 2px;
font-variant-numeric: tabular-nums;
} }
@keyframes slide-up {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#history-empty { #history-empty {
text-align: center; text-align: center;
padding: 32px 0; padding: 40px 0;
} }
.placeholder { .placeholder {
color: var(--text-dim); color: var(--text-dim);
font-size: 14px; font-size: 14px;
} }
/* Scrollbar */
/* ─── Scrollbar ─── */
.preview-box::-webkit-scrollbar,
#history-list::-webkit-scrollbar { #history-list::-webkit-scrollbar {
width: 4px; width: 3px;
} }
.preview-box::-webkit-scrollbar-track,
#history-list::-webkit-scrollbar-track { #history-list::-webkit-scrollbar-track {
background: transparent; background: transparent;
} }
.preview-box::-webkit-scrollbar-thumb,
#history-list::-webkit-scrollbar-thumb { #history-list::-webkit-scrollbar-thumb {
background: var(--border); background: var(--border);
border-radius: 2px; border-radius: 3px;
} }
/* Toast */
/* ─── Toast ─── */
.toast { .toast {
position: fixed; position: fixed;
bottom: calc(100px + var(--safe-bottom, 0px)); bottom: calc(80px + var(--safe-bottom, 0px));
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%) translateY(8px);
background: #222; background: rgba(28, 28, 37, 0.85);
color: #eee; color: var(--text);
padding: 8px 18px; padding: 10px 22px;
border-radius: 20px; border-radius: 24px;
font-size: 14px; font-size: 13px;
font-weight: 500;
z-index: 999; z-index: 999;
opacity: 0; opacity: 0;
transition: opacity 0.3s; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
pointer-events: none; pointer-events: none;
border: 1px solid var(--border);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
} }
.toast.show { .toast.show {
opacity: 1; opacity: 1;
transform: translateX(-50%) translateY(0);
} }