|
272 | 272 | padding: 40px; |
273 | 273 | } |
274 | 274 |
|
| 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 | + |
275 | 300 | .upload-area { |
276 | 301 | background: white; |
277 | 302 | border: 2px dashed var(--primary-color); |
@@ -1206,6 +1231,7 @@ <h2 class="upload-title">上传小说文件</h2> |
1206 | 1231 | <div class="storage-text" id="storageText">存储: 0MB / 100MB</div> |
1207 | 1232 | </div> |
1208 | 1233 | <button class="btn btn-small" id="storageManageBtn">管理书籍</button> |
| 1234 | + <button class="btn btn-small" id="uploadNewBtn">上传新书</button> |
1209 | 1235 | </div> |
1210 | 1236 | </div> |
1211 | 1237 |
|
@@ -1349,16 +1375,31 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
1349 | 1375 | this.fontSizeDown = document.getElementById('fontSizeDown'); |
1350 | 1376 | this.fontSizeDisplay = document.getElementById('fontSizeDisplay'); |
1351 | 1377 |
|
| 1378 | + // 设置初始状态:隐藏不应该在没有小说时显示的元素 |
| 1379 | + this.setInitialState(); |
| 1380 | + |
1352 | 1381 | // 存储管理相关元素 |
1353 | 1382 | this.storageInfo = document.getElementById('storageInfo'); |
1354 | 1383 | this.storageFill = document.getElementById('storageFill'); |
1355 | 1384 | this.storageText = document.getElementById('storageText'); |
1356 | 1385 | this.storageManageBtn = document.getElementById('storageManageBtn'); |
| 1386 | + this.uploadNewBtn = document.getElementById('uploadNewBtn'); |
1357 | 1387 | this.storagePanel = document.getElementById('storagePanel'); |
1358 | 1388 | this.closePanelBtn = document.getElementById('closePanelBtn'); |
1359 | 1389 | this.booksList = document.getElementById('booksList'); |
1360 | 1390 | } |
1361 | 1391 |
|
| 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 | + |
1362 | 1403 | initEventListeners() { |
1363 | 1404 | // 上传相关事件 |
1364 | 1405 | this.uploadBtn.addEventListener('click', () => this.fileInput.click()); |
@@ -1406,6 +1447,7 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
1406 | 1447 |
|
1407 | 1448 | // 存储管理事件 |
1408 | 1449 | this.storageManageBtn.addEventListener('click', () => this.showStoragePanel()); |
| 1450 | + this.uploadNewBtn.addEventListener('click', () => this.returnToUpload()); |
1409 | 1451 | this.closePanelBtn.addEventListener('click', () => this.hideStoragePanel()); |
1410 | 1452 |
|
1411 | 1453 | // 触摸手势和翻页功能 |
@@ -1465,7 +1507,9 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
1465 | 1507 |
|
1466 | 1508 | // 显示阅读器 |
1467 | 1509 | this.uploadSection.style.display = 'none'; |
| 1510 | + this.uploadSection.classList.remove('upload-only'); |
1468 | 1511 | this.processing.style.display = 'none'; |
| 1512 | + this.readerContainer.style.display = 'block'; |
1469 | 1513 |
|
1470 | 1514 | // 显示固定导航条 |
1471 | 1515 | this.fixedNav.style.display = 'flex'; |
@@ -1663,6 +1707,7 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
1663 | 1707 |
|
1664 | 1708 | openSidebar() { |
1665 | 1709 | this.settings.sidebarOpen = true; |
| 1710 | + this.sidebar.style.display = 'block'; // 确保侧边栏可见 |
1666 | 1711 | this.sidebar.classList.add('open'); |
1667 | 1712 | this.overlay.classList.add('show'); |
1668 | 1713 | if (window.innerWidth > 768) { |
@@ -2166,6 +2211,28 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
2166 | 2211 | this.chapterList.style.display = 'block'; |
2167 | 2212 | } |
2168 | 2213 |
|
| 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 | + |
2169 | 2236 | // 渲染书籍列表 |
2170 | 2237 | renderBooksList() { |
2171 | 2238 | const books = this.getStoredBooks(); |
@@ -2236,10 +2303,15 @@ <h1 class="content-title" id="contentTitle">欢迎使用智能小说阅读器</h |
2236 | 2303 |
|
2237 | 2304 | // 显示阅读器 |
2238 | 2305 | this.uploadSection.style.display = 'none'; |
| 2306 | + this.uploadSection.classList.remove('upload-only'); |
| 2307 | + this.readerContainer.style.display = 'block'; |
2239 | 2308 |
|
2240 | 2309 | // 显示固定导航条 |
2241 | 2310 | this.fixedNav.style.display = 'flex'; |
2242 | 2311 |
|
| 2312 | + // 显示侧边栏 |
| 2313 | + this.sidebar.style.display = 'block'; |
| 2314 | + |
2243 | 2315 | // 隐藏存储面板 |
2244 | 2316 | this.hideStoragePanel(); |
2245 | 2317 |
|
|
0 commit comments