Files
voicepaste/web/index.html
imbytecat b87fead2fd refactor: 优化代码质量,遵循 KISS 原则
- 移除自签证书回退逻辑,简化为仅使用 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 行,复杂度显著降低,所有构建通过
2026-03-02 00:25:14 +08:00

50 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<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-status-bar-style" content="black-translucent">
<title>VoicePaste</title>
</head>
<body>
<div id="app">
<header>
<h1>VoicePaste</h1>
<div id="status" class="status disconnected">
<span class="dot"></span>
<span id="status-text">连接中…</span>
</div>
</header>
<section id="preview-section">
<div id="preview" class="preview-box">
<p id="preview-text" class="placeholder">按住说话…</p>
</div>
</section>
<section id="mic-section">
<button id="mic-btn" type="button" disabled>
<svg viewBox="0 0 24 24" width="48" height="48" fill="currentColor" aria-label="麦克风" role="img">
<title>麦克风</title>
<path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>
<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>
</button>
</section>
<section id="history-section">
<div class="history-header">
<h2>历史记录</h2>
<button id="clear-history" type="button" class="text-btn">清空</button>
</div>
<ul id="history-list"></ul>
<p id="history-empty" class="placeholder">暂无记录</p>
</section>
</div>
<div id="toast" class="toast"></div>
<script type="module" src="app.ts"></script>
</body>
</html>