From 117fbe5ac4f8ce04d02ef72779128d46a657966e Mon Sep 17 00:00:00 2001 From: Yuhang Wu Date: Thu, 20 Aug 2026 16:09:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=B9=A6?= =?UTF-8?q?=E7=B1=8D=E5=88=97=E8=A1=A8=E4=B8=8E=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增BookCover通用封面组件,统一处理封面展示与缺省样式 2. 调整类型定义:修复字段命名、补充可选类型适配空值场景 3. 替换首页旧的封面实现,复用新组件并移除冗余代码 4. 新增书籍详情页面,完善书籍信息展示与章节列表分页功能 5. 更新全局组件注册,补充新增组件与naive-ui组件类型声明 6. 调整首页工具栏按钮,替换阅读按钮为导入按钮 --- src-tauri/src/models.rs | 2 +- src/components/BookCover.vue | 114 ++++++++++++++ src/types/components.d.ts | 9 +- src/types/global.ts | 8 +- src/views/BookDetail.vue | 286 ++++++++++++++++++++++++++++++++++- src/views/Home.vue | 112 +------------- 6 files changed, 417 insertions(+), 114 deletions(-) create mode 100644 src/components/BookCover.vue diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index 5997a66..fadef45 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -60,7 +60,7 @@ pub struct Books { pub create_time: chrono::NaiveDateTime, pub last_read_chapter_id: i64, pub last_read_position: i32, - pub last_read_time: chrono::NaiveDateTime, + pub last_read_time: Option, } #[derive(Debug, FromRow, Serialize, Deserialize, Clone)] diff --git a/src/components/BookCover.vue b/src/components/BookCover.vue new file mode 100644 index 0000000..0bd6439 --- /dev/null +++ b/src/components/BookCover.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/src/types/components.d.ts b/src/types/components.d.ts index 20115ab..fac502b 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -11,24 +11,31 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + BookCover: typeof import('./../components/BookCover.vue')['default'] NAnchor: typeof import('naive-ui')['NAnchor'] NAnchorLink: typeof import('naive-ui')['NAnchorLink'] NButton: typeof import('naive-ui')['NButton'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] + NDescriptions: typeof import('naive-ui')['NDescriptions'] + NDescriptionsItem: typeof import('naive-ui')['NDescriptionsItem'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] + NDivider: typeof import('naive-ui')['NDivider'] NEmpty: typeof import('naive-ui')['NEmpty'] NIcon: typeof import('naive-ui')['NIcon'] NInput: typeof import('naive-ui')['NInput'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutContent: typeof import('naive-ui')['NLayoutContent'] NLayoutHeader: typeof import('naive-ui')['NLayoutHeader'] - NLayoutSider: typeof import('naive-ui')['NLayoutSider'] + NList: typeof import('naive-ui')['NList'] + NListItem: typeof import('naive-ui')['NListItem'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] + NPagination: typeof import('naive-ui')['NPagination'] NRadioButton: typeof import('naive-ui')['NRadioButton'] NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSpace: typeof import('naive-ui')['NSpace'] + NSpin: typeof import('naive-ui')['NSpin'] NSwitch: typeof import('naive-ui')['NSwitch'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/types/global.ts b/src/types/global.ts index fb4ce36..07c7f20 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -9,7 +9,7 @@ interface PageResult { total: number list: T[] page: number - size: number + page_size: number } interface Books { @@ -17,13 +17,13 @@ interface Books { title: string author: string cover: string - instruction: string + introduction: string file_path: string total_chapters: number total_chars: number create_time: string - last_read_time: string - last_read_chapter: number + last_read_time: string | null + last_read_chapter_id: number last_read_position: number } diff --git a/src/views/BookDetail.vue b/src/views/BookDetail.vue index 8e8347f..0089897 100644 --- a/src/views/BookDetail.vue +++ b/src/views/BookDetail.vue @@ -1,13 +1,291 @@ - \ No newline at end of file +.detail-header { + flex-shrink: 0; + display: flex; + flex-direction: column; + gap: 12px; +} + +.header-toolbar { + display: flex; + align-items: center; +} + +.book-summary { + display: flex; + gap: 20px; +} + +.summary-cover { + width: 120px; + aspect-ratio: 2 / 3; + flex-shrink: 0; + border-radius: var(--radius-sm); + overflow: hidden; + box-shadow: var(--shadow-card); +} + +.summary-meta { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 12px; +} + +.summary-title { + margin: 0; + font-size: 20px; + font-weight: 700; + color: var(--color-text-primary); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.detail-divider { + margin: 16px 0; +} + +.chapter-section { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; +} + +.chapter-header { + flex-shrink: 0; + display: flex; + align-items: baseline; + justify-content: space-between; + margin-bottom: 8px; +} + +.chapter-name { + font-size: 15px; + font-weight: 600; + color: var(--color-text-primary); +} + +.chapter-count { + font-size: 12px; + color: var(--color-text-secondary); +} + +.chapter-scrollbar { + flex: 1; + min-height: 0; +} + +.chapter-item { + display: flex; + align-items: center; + gap: 12px; + width: 100%; +} + +.chapter-index { + flex-shrink: 0; + min-width: 40px; + color: var(--color-text-secondary); + font-size: 13px; +} + +.chapter-title { + flex: 1; + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: var(--color-text-primary); + font-size: 14px; +} + +.chapter-chars { + flex-shrink: 0; + color: var(--color-text-secondary); + font-size: 12px; +} + +.chapter-empty { + padding: 40px 0; +} + +.pagination-wrap { + flex-shrink: 0; + display: flex; + justify-content: center; + padding-top: 12px; +} + diff --git a/src/views/Home.vue b/src/views/Home.vue index 88d0dc6..cb451e2 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -10,8 +10,8 @@ - @@ -35,23 +35,8 @@ class="book-card" @click="goDetail(book)" > -
- -
- -
- {{ book.title }} - {{ book.author || "佚名" }} -
-
+
+
@@ -67,10 +52,10 @@