feat: add TXT reader demo with mock data (bookshelf, reader, progress restore)
This commit is contained in:
+171
@@ -0,0 +1,171 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>TXT 阅读器 Demo</title>
|
||||
<style>
|
||||
:root {
|
||||
--c-bg: #f5f4f0;
|
||||
--c-surface: #ffffff;
|
||||
--c-text: #2b2b2b;
|
||||
--c-text-secondary: #8a8a8a;
|
||||
--c-primary: #2f6f4f;
|
||||
--c-primary-soft: #e4efe9;
|
||||
--c-border: #e4e2dc;
|
||||
--c-danger: #b4453c;
|
||||
--reader-font-size: 18px;
|
||||
--reader-line-height: 1.9;
|
||||
}
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
background: var(--c-bg);
|
||||
color: var(--c-text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
button { font: inherit; cursor: pointer; border: none; background: none; }
|
||||
.hidden { display: none !important; }
|
||||
|
||||
/* ---------- 书架 ---------- */
|
||||
.shelf-header {
|
||||
max-width: 720px; margin: 0 auto; padding: 40px 20px 16px;
|
||||
display: flex; align-items: baseline; justify-content: space-between;
|
||||
}
|
||||
.shelf-header h1 { font-size: 22px; }
|
||||
.shelf-header .demo-tag { font-size: 12px; color: var(--c-text-secondary); }
|
||||
.shelf {
|
||||
max-width: 720px; margin: 0 auto; padding: 8px 20px 60px;
|
||||
}
|
||||
.import-btn {
|
||||
display: flex; align-items: center; justify-content: center; gap: 8px;
|
||||
width: 100%; padding: 16px;
|
||||
border: 1.5px dashed var(--c-border); border-radius: 12px;
|
||||
color: var(--c-text-secondary); background: var(--c-surface);
|
||||
transition: border-color .15s, color .15s;
|
||||
}
|
||||
.import-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
|
||||
.book-list { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
|
||||
.book-card {
|
||||
display: flex; align-items: center; gap: 16px;
|
||||
padding: 18px 20px; border-radius: 12px;
|
||||
background: var(--c-surface); border: 1px solid var(--c-border);
|
||||
cursor: pointer; transition: box-shadow .15s;
|
||||
}
|
||||
.book-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }
|
||||
.book-cover {
|
||||
width: 52px; height: 72px; border-radius: 6px; flex-shrink: 0;
|
||||
background: linear-gradient(160deg, var(--c-primary-soft), #cfe0d6);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
color: var(--c-primary); font-size: 20px; font-weight: 600;
|
||||
}
|
||||
.book-info { flex: 1; min-width: 0; }
|
||||
.book-title { font-size: 17px; font-weight: 600; }
|
||||
.book-meta { font-size: 13px; color: var(--c-text-secondary); margin-top: 6px; }
|
||||
.progress-bar {
|
||||
margin-top: 10px; height: 4px; border-radius: 2px;
|
||||
background: var(--c-border); overflow: hidden;
|
||||
}
|
||||
.progress-bar > div { height: 100%; background: var(--c-primary); border-radius: 2px; }
|
||||
.book-progress-num { font-size: 14px; color: var(--c-primary); width: 48px; text-align: right; }
|
||||
.book-delete {
|
||||
padding: 6px 10px; border-radius: 8px; font-size: 13px;
|
||||
color: var(--c-text-secondary);
|
||||
}
|
||||
.book-delete:hover { color: var(--c-danger); background: #faf0ef; }
|
||||
.shelf-empty { text-align: center; color: var(--c-text-secondary); padding: 60px 0; }
|
||||
|
||||
/* ---------- 阅读页 ---------- */
|
||||
.reader { display: flex; flex-direction: column; height: 100vh; background: var(--c-bg); }
|
||||
.reader-header {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 12px 20px; background: var(--c-surface);
|
||||
border-bottom: 1px solid var(--c-border);
|
||||
position: sticky; top: 0; z-index: 10;
|
||||
}
|
||||
.reader-header .back { padding: 6px 12px; border-radius: 8px; color: var(--c-text-secondary); }
|
||||
.reader-header .back:hover { background: var(--c-bg); color: var(--c-text); }
|
||||
.reader-title { flex: 1; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.reader-progress-label { font-size: 13px; color: var(--c-text-secondary); flex-shrink: 0; }
|
||||
.settings-toggle { padding: 6px 12px; border-radius: 8px; color: var(--c-text-secondary); font-size: 15px; }
|
||||
.settings-toggle:hover, .settings-toggle.active { background: var(--c-primary-soft); color: var(--c-primary); }
|
||||
.settings-panel {
|
||||
display: flex; gap: 32px; align-items: center; justify-content: center;
|
||||
padding: 12px 20px; background: var(--c-surface);
|
||||
border-bottom: 1px solid var(--c-border);
|
||||
}
|
||||
.setting-group { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--c-text-secondary); }
|
||||
.setting-group button {
|
||||
width: 30px; height: 30px; border-radius: 8px; background: var(--c-bg); color: var(--c-text);
|
||||
}
|
||||
.setting-group .value { min-width: 44px; text-align: center; color: var(--c-text); }
|
||||
.reader-body { flex: 1; overflow-y: auto; }
|
||||
.reader-content {
|
||||
max-width: 680px; margin: 0 auto; padding: 32px 24px 40vh;
|
||||
font-size: var(--reader-font-size);
|
||||
line-height: var(--reader-line-height);
|
||||
}
|
||||
.reader-content p { margin-bottom: 1em; text-align: justify; }
|
||||
.reader-content h2 {
|
||||
font-size: 1.15em; margin: 2em 0 1em; color: var(--c-primary);
|
||||
text-align: center; font-weight: 600;
|
||||
}
|
||||
.toast {
|
||||
position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
|
||||
background: rgba(43,43,43,.9); color: #fff; padding: 10px 20px;
|
||||
border-radius: 20px; font-size: 14px; z-index: 99;
|
||||
animation: toast-in .2s ease;
|
||||
}
|
||||
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 书架视图 -->
|
||||
<div id="shelf-view">
|
||||
<div class="shelf-header">
|
||||
<h1>书架</h1>
|
||||
<span class="demo-tag">Demo · 数据为模拟数据</span>
|
||||
</div>
|
||||
<div class="shelf">
|
||||
<button class="import-btn" id="import-btn">
|
||||
<span style="font-size:20px">+</span> 导入 TXT 文件
|
||||
</button>
|
||||
<input type="file" id="file-input" accept=".txt" multiple hidden />
|
||||
<div class="book-list" id="book-list"></div>
|
||||
<div class="shelf-empty hidden" id="shelf-empty">书架空空的,导入一本 TXT 开始阅读吧</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 阅读视图 -->
|
||||
<div id="reader-view" class="reader hidden">
|
||||
<div class="reader-header">
|
||||
<button class="back" id="back-btn">‹ 书架</button>
|
||||
<div class="reader-title" id="reader-title"></div>
|
||||
<span class="reader-progress-label" id="reader-progress">0%</span>
|
||||
<button class="settings-toggle" id="settings-btn" title="阅读设置">Aa</button>
|
||||
</div>
|
||||
<div class="settings-panel hidden" id="settings-panel">
|
||||
<div class="setting-group">
|
||||
字号
|
||||
<button id="font-minus">−</button>
|
||||
<span class="value" id="font-value">18</span>
|
||||
<button id="font-plus">+</button>
|
||||
</div>
|
||||
<div class="setting-group">
|
||||
行距
|
||||
<button id="lh-minus">−</button>
|
||||
<span class="value" id="lh-value">1.9</span>
|
||||
<button id="lh-plus">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reader-body" id="reader-body">
|
||||
<div class="reader-content" id="reader-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="core.js"></script>
|
||||
<script src="mock-data.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user