- 移除自签证书回退逻辑,简化为仅使用 AnyIP 证书 - 删除 internal/tls/generate.go(不再需要) - 重构 main.go:提取初始化逻辑,main() 从 156 行降至 13 行 - 重构 internal/ws/handler.go:提取消息处理,handleConn() 从 131 行降至 25 行 - 重构 internal/config/load.go:使用 map 驱动消除重复代码 - 优化前端 startRecording():使用标准 AbortController API - 优化前端 showToast():预定义 DOM 元素,代码减少 50% 代码行数减少 90 行,复杂度显著降低,所有构建通过
294 lines
5.0 KiB
CSS
294 lines
5.0 KiB
CSS
*,
|
|
*::before,
|
|
*::after {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
:root {
|
|
--bg: #0a0a0a;
|
|
--surface: #161616;
|
|
--surface-hover: #1e1e1e;
|
|
--border: #2a2a2a;
|
|
--text: #e8e8e8;
|
|
--text-dim: #888;
|
|
--accent: #3b82f6;
|
|
--accent-glow: rgba(59, 130, 246, 0.3);
|
|
--danger: #ef4444;
|
|
--success: #22c55e;
|
|
--radius: 12px;
|
|
--safe-top: env(safe-area-inset-top, 0px);
|
|
--safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
}
|
|
|
|
html,
|
|
body {
|
|
height: 100%;
|
|
font-family:
|
|
-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
|
|
sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
-webkit-font-smoothing: antialiased;
|
|
-webkit-tap-highlight-color: transparent;
|
|
-webkit-touch-callout: none;
|
|
user-select: none;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#app {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
max-width: 480px;
|
|
margin: 0 auto;
|
|
padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
|
|
}
|
|
|
|
/* Header */
|
|
header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 8px 0 16px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
header h1 {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
.status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 13px;
|
|
color: var(--text-dim);
|
|
}
|
|
|
|
.status .dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--text-dim);
|
|
transition: background 0.3s;
|
|
}
|
|
|
|
.status.connected .dot {
|
|
background: var(--success);
|
|
}
|
|
.status.disconnected .dot {
|
|
background: var(--danger);
|
|
}
|
|
.status.connecting .dot {
|
|
background: var(--accent);
|
|
animation: pulse 1.2s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0%,
|
|
100% {
|
|
opacity: 1;
|
|
}
|
|
50% {
|
|
opacity: 0.4;
|
|
}
|
|
}
|
|
|
|
/* Preview */
|
|
#preview-section {
|
|
flex-shrink: 0;
|
|
padding-bottom: 16px;
|
|
}
|
|
|
|
.preview-box {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 16px;
|
|
min-height: 80px;
|
|
max-height: 160px;
|
|
overflow-y: auto;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.preview-box.active {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 1px var(--accent-glow);
|
|
}
|
|
|
|
#preview-text {
|
|
font-size: 16px;
|
|
line-height: 1.5;
|
|
word-break: break-word;
|
|
}
|
|
|
|
#preview-text.placeholder {
|
|
color: var(--text-dim);
|
|
font-style: italic;
|
|
}
|
|
|
|
/* Mic Button */
|
|
#mic-section {
|
|
display: flex;
|
|
justify-content: center;
|
|
padding: 24px 0;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
#mic-btn {
|
|
width: 88px;
|
|
height: 88px;
|
|
border-radius: 50%;
|
|
border: 2px solid var(--border);
|
|
background: var(--surface);
|
|
color: var(--text-dim);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
-webkit-user-select: none;
|
|
touch-action: none;
|
|
}
|
|
|
|
#mic-btn:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
#mic-btn:not(:disabled):active,
|
|
#mic-btn.recording {
|
|
background: var(--accent);
|
|
border-color: var(--accent);
|
|
color: #fff;
|
|
transform: scale(1.08);
|
|
box-shadow: 0 0 24px var(--accent-glow);
|
|
}
|
|
|
|
#mic-btn.recording {
|
|
animation: mic-pulse 1s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes mic-pulse {
|
|
0%,
|
|
100% {
|
|
box-shadow: 0 0 24px var(--accent-glow);
|
|
}
|
|
50% {
|
|
box-shadow:
|
|
0 0 48px var(--accent-glow),
|
|
0 0 80px rgba(59, 130, 246, 0.15);
|
|
}
|
|
}
|
|
/* History */
|
|
#history-section {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
.history-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding-bottom: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
.history-header h2 {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: var(--text-dim);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.04em;
|
|
}
|
|
.text-btn {
|
|
background: none;
|
|
border: none;
|
|
color: var(--accent);
|
|
font-size: 13px;
|
|
cursor: pointer;
|
|
padding: 4px 8px;
|
|
border-radius: 6px;
|
|
transition: background 0.2s;
|
|
}
|
|
.text-btn:active {
|
|
background: rgba(59, 130, 246, 0.1);
|
|
}
|
|
#history-list {
|
|
list-style: none;
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
}
|
|
#history-list li {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 12px 14px;
|
|
margin-bottom: 8px;
|
|
font-size: 14px;
|
|
line-height: 1.4;
|
|
cursor: pointer;
|
|
transition: background 0.15s;
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
}
|
|
#history-list li:active {
|
|
background: var(--surface-hover);
|
|
}
|
|
#history-list li .hist-text {
|
|
flex: 1;
|
|
word-break: break-word;
|
|
}
|
|
#history-list li .hist-time {
|
|
font-size: 11px;
|
|
color: var(--text-dim);
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
padding-top: 2px;
|
|
}
|
|
#history-empty {
|
|
text-align: center;
|
|
padding: 32px 0;
|
|
}
|
|
.placeholder {
|
|
color: var(--text-dim);
|
|
font-size: 14px;
|
|
}
|
|
/* Scrollbar */
|
|
#history-list::-webkit-scrollbar {
|
|
width: 4px;
|
|
}
|
|
#history-list::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
#history-list::-webkit-scrollbar-thumb {
|
|
background: var(--border);
|
|
border-radius: 2px;
|
|
}
|
|
/* Toast */
|
|
.toast {
|
|
position: fixed;
|
|
bottom: calc(100px + var(--safe-bottom, 0px));
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: #222;
|
|
color: #eee;
|
|
padding: 8px 18px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
z-index: 999;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
pointer-events: none;
|
|
}
|
|
.toast.show {
|
|
opacity: 1;
|
|
}
|