Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Repository Guidelines

## Project Structure & Module Organization

- `src/app/`: application entry points, global styles, metadata, and icons.
- `src/components/`: feature components such as the sidebar, chat area, dialogs, and input.
- `src/components/ui/`: reusable shadcn/Radix UI primitives.
- `src/lib/`: book parsing, EPUB parsing, IndexedDB storage, and shared utilities.
- `src/types/`: shared TypeScript interfaces.
- `public/`: static assets, including ChatGPT-style icons under `public/icons/`.

Do not commit `.next/` or `node_modules/`.

## Build, Test, and Development Commands

- `npm install`: install dependencies from `package-lock.json`.
- `npm run dev`: start the local development server at `http://localhost:3000`.
- `npm run lint`: run ESLint with Next.js Core Web Vitals and TypeScript rules.
- `npm run build`: create a production build and run TypeScript validation.
- `npm run start`: serve an existing production build.

Before opening a pull request, run both `npm run lint` and `npm run build`.

## Coding Style & Naming Conventions

Use strict TypeScript and React functional components. Follow the existing two-space indentation and nearby quote style. Component names use PascalCase, functions and state use camelCase, and component filenames use kebab-case, for example `message-bubble.tsx`.

Use the `@/` path alias for imports from `src/`. Prefer existing UI primitives and Tailwind utility classes over new one-off CSS. Keep browser-only APIs inside client components or dynamically imported helpers.

## Parsing & Persistence

TXT parsing uses the `ChapterPattern` modes in `src/lib/book-parser.ts`. List-like text such as `1、条目` must not match strict Chinese mode. Update the settings dialog and README when adding a pattern.

IndexedDB stores books, messages, and raw TXT sources separately. Keep raw sources out of `Book` so progress saves stay lightweight. Increment `DB_VERSION` when changing stores.

## Testing Guidelines

No automated test framework is currently configured. Treat lint and production builds as required checks. Manually verify TXT/EPUB import, chapter navigation, pattern re-parsing, persistence after reload, and the settings dialog at short viewport heights.

When adding tests, place focused `*.test.ts` or `*.test.tsx` files beside the module they cover. Parser changes should include representative chapter-title fixtures and malformed-input cases.

## Commit & Pull Request Guidelines

Recent commits use concise, imperative summaries; newer commits use a Chinese category prefix such as `【界面优化】` or `【文档更新】`. Keep each commit focused.

Pull requests should explain user-visible behavior, list verification commands, and include before/after screenshots for UI changes. Mention storage migrations, dependency additions, and any EPUB compatibility limitations. Link related issues when available.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

- **完美伪装** - 界面 1:1 还原 ChatGPT,白色主题,专业感十足
- **智能分章** - 自动识别「第X章」「Chapter X」等章节标题
- **分章规则** - 可为 TXT 书籍选择章节标题格式,避免正文列表被误判
- **流式输出** - 模拟 AI 打字效果,逐字显示小说内容
- **进度保存** - 使用 IndexedDB 存储,支持超大文件,刷新不丢失
- **拖拽上传** - 直接拖入 txt 文件即可开始阅读
- **拖拽上传** - 直接拖入 txt / epub 文件即可开始阅读
- **多编码支持** - 自动识别 UTF-8 / GBK 编码
- **自定义设置** - 可调节段落数、打字速度、字体大小
- **立即回答** - 输出中途可跳过动画,立即显示完整内容
Expand Down Expand Up @@ -44,13 +45,14 @@ npm run dev

## 📖 使用方法

1. **上传小说** - 将 `.txt` 文件直接拖入页面
1. **上传小说** - 将 `.txt` 或 `.epub` 文件直接拖入页面
2. **开始阅读** - 在输入框输入任意内容(或直接回车),按回车发送
3. **继续阅读** - 每次发送消息,流式输出设定的段落数(默认 3 段,可在设置中调整)
4. **跳过动画** - 输出过程中点击「立即回答」可跳过打字动画
5. **切换章节** - 点击左侧章节列表可跳转
6. **调整设置** - 点击右上角齿轮图标,调整段落数、打字速度、字体大小
7. **收起侧栏** - 点击收起按钮让界面更像 ChatGPT
8. **调整分章** - 点击侧栏「应用」,选择当前 TXT 使用的章节标题格式

## 🎭 摸鱼技巧

Expand All @@ -71,12 +73,23 @@ npm run dev

## 📝 支持的章节格式

### 文件格式

- `.txt`:支持 UTF-8 / GBK 文本小说
- `.epub`:支持标准 EPUB 电子书,会按 EPUB 目录和阅读顺序解析章节

### 文本章节标题

自动识别以下章节标题格式:

- `第一章`、`第1章`、`第一百二十三章`
- `第一节`、`第一回`、`第一卷`
- `Chapter 1`、`CHAPTER 1`
- `第一节`、`第一回`、`第一卷`、`第一部`、`第一集`、`第一篇`、`第一话`
- `Chapter 1`、`CHAPTER 1`、`Chap. 1`
- `卷一`、`卷1`
- `1.变成蘑菇的公爵千金`、`2、蘑菇园来了个外乡菇`
- `3:新的旅程`、`4)意外来客`、`5 标题`

在侧栏点击「应用」可多选启用的规则。正文包含 `1、条目` 等列举内容时,可只保留「标准中文章节」,仅按 `第XXX章 标题` 等格式划分。

## ⚠️ 免责声明

Expand Down
2 changes: 1 addition & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
devIndicators: false,
};

export default nextConfig;
Loading