Skip to content

Commit 35d053b

Browse files
author
Taois
committed
feat: 上传小说区域居中
1 parent 42d2018 commit 35d053b

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

apps/book-reader/index.html

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,31 @@
272272
padding: 40px;
273273
}
274274

275+
/* 当只有上传区域显示时的全局居中样式 */
276+
.upload-section.upload-only {
277+
position: fixed !important;
278+
top: 0 !important;
279+
left: 0 !important;
280+
right: 0 !important;
281+
bottom: 0 !important;
282+
width: 100vw !important;
283+
height: 100vh !important;
284+
z-index: 1000 !important;
285+
background: var(--background-color) !important;
286+
margin: 0 !important;
287+
padding: 0 !important;
288+
flex: none !important;
289+
display: flex !important;
290+
align-items: center !important;
291+
justify-content: center !important;
292+
box-sizing: border-box !important;
293+
}
294+
295+
/* 确保upload-only状态下的upload-area也居中 */
296+
.upload-section.upload-only .upload-area {
297+
margin: auto !important;
298+
}
299+
275300
.upload-area {
276301
background: white;
277302
border: 2px dashed var(--primary-color);
@@ -1206,6 +1231,7 @@ <h2 class="upload-title">上传小说文件</h2>
12061231
<div class="storage-text" id="storageText">存储: 0MB / 100MB</div>
12071232
</div>
12081233
<button class="btn btn-small" id="storageManageBtn">管理书籍</button>
1234+
<button class="btn btn-small" id="uploadNewBtn">上传新书</button>
12091235
</div>
12101236
</div>
12111237

@@ -1349,16 +1375,31 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
13491375
this.fontSizeDown = document.getElementById('fontSizeDown');
13501376
this.fontSizeDisplay = document.getElementById('fontSizeDisplay');
13511377

1378+
// 设置初始状态:隐藏不应该在没有小说时显示的元素
1379+
this.setInitialState();
1380+
13521381
// 存储管理相关元素
13531382
this.storageInfo = document.getElementById('storageInfo');
13541383
this.storageFill = document.getElementById('storageFill');
13551384
this.storageText = document.getElementById('storageText');
13561385
this.storageManageBtn = document.getElementById('storageManageBtn');
1386+
this.uploadNewBtn = document.getElementById('uploadNewBtn');
13571387
this.storagePanel = document.getElementById('storagePanel');
13581388
this.closePanelBtn = document.getElementById('closePanelBtn');
13591389
this.booksList = document.getElementById('booksList');
13601390
}
13611391

1392+
setInitialState() {
1393+
// 在没有小说内容时,隐藏不应该显示的元素
1394+
this.sidebar.style.display = 'none';
1395+
this.readerContainer.style.display = 'none';
1396+
this.fixedNav.style.display = 'none';
1397+
1398+
// 确保上传区域是显示的并添加全局居中样式
1399+
this.uploadSection.style.display = 'block';
1400+
this.uploadSection.classList.add('upload-only');
1401+
}
1402+
13621403
initEventListeners() {
13631404
// 上传相关事件
13641405
this.uploadBtn.addEventListener('click', () => this.fileInput.click());
@@ -1406,6 +1447,7 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
14061447

14071448
// 存储管理事件
14081449
this.storageManageBtn.addEventListener('click', () => this.showStoragePanel());
1450+
this.uploadNewBtn.addEventListener('click', () => this.returnToUpload());
14091451
this.closePanelBtn.addEventListener('click', () => this.hideStoragePanel());
14101452

14111453
// 触摸手势和翻页功能
@@ -1465,7 +1507,9 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
14651507

14661508
// 显示阅读器
14671509
this.uploadSection.style.display = 'none';
1510+
this.uploadSection.classList.remove('upload-only');
14681511
this.processing.style.display = 'none';
1512+
this.readerContainer.style.display = 'block';
14691513

14701514
// 显示固定导航条
14711515
this.fixedNav.style.display = 'flex';
@@ -1663,6 +1707,7 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
16631707

16641708
openSidebar() {
16651709
this.settings.sidebarOpen = true;
1710+
this.sidebar.style.display = 'block'; // 确保侧边栏可见
16661711
this.sidebar.classList.add('open');
16671712
this.overlay.classList.add('show');
16681713
if (window.innerWidth > 768) {
@@ -2166,6 +2211,28 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
21662211
this.chapterList.style.display = 'block';
21672212
}
21682213

2214+
// 返回上传界面
2215+
returnToUpload() {
2216+
// 清除当前书籍数据
2217+
this.currentBook = null;
2218+
this.currentChapter = 0;
2219+
this.chapters = [];
2220+
2221+
// 重置界面到初始状态
2222+
this.setInitialState();
2223+
2224+
// 清空内容
2225+
this.bookTitle.textContent = '小说标题';
2226+
this.bookStats.textContent = '共0章,约0千字';
2227+
this.chapterList.innerHTML = '';
2228+
this.readerContent.innerHTML = '';
2229+
this.contentTitle.textContent = '';
2230+
this.contentText.textContent = '';
2231+
2232+
// 关闭侧边栏
2233+
this.closeSidebar();
2234+
}
2235+
21692236
// 渲染书籍列表
21702237
renderBooksList() {
21712238
const books = this.getStoredBooks();
@@ -2236,10 +2303,15 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h
22362303

22372304
// 显示阅读器
22382305
this.uploadSection.style.display = 'none';
2306+
this.uploadSection.classList.remove('upload-only');
2307+
this.readerContainer.style.display = 'block';
22392308

22402309
// 显示固定导航条
22412310
this.fixedNav.style.display = 'flex';
22422311

2312+
// 显示侧边栏
2313+
this.sidebar.style.display = 'block';
2314+
22432315
// 隐藏存储面板
22442316
this.hideStoragePanel();
22452317

0 commit comments

Comments
 (0)