refactor: Streamline EPUB handling with new split modes and improved error management
Build and Push Reader Image / docker (push) Successful in 1m32s

- Removed legacy AI Tool references and unnecessary fields from the README and various components.
- Introduced new EPUB split modes (toc, regex, tag) to enhance flexibility in chapter extraction.
- Updated import and chapter management components to utilize the new EPUB split functionality.
- Improved error handling in the login API route for better user feedback.
- Cleaned up unused files and optimized the overall code structure for maintainability.
This commit is contained in:
2026-05-19 00:15:19 +07:00
parent 3036854cf2
commit 878018ca11
12 changed files with 370 additions and 1327 deletions
+5 -1
View File
@@ -68,6 +68,9 @@ async function initializeGoogleIdentity(clientId: string): Promise<void> {
if (googleInitializedClientId === clientId) return
const hostname = typeof window !== "undefined" ? window.location.hostname : ""
const isLocalHost = hostname === "localhost" || hostname === "127.0.0.1"
// Re-initialize with new clientId (or first time)
googleApi.initialize({
client_id: clientId,
@@ -86,7 +89,8 @@ async function initializeGoogleIdentity(clientId: string): Promise<void> {
},
auto_select: false,
cancel_on_tap_outside: true,
use_fedcm_for_prompt: true,
// FedCM on localhost often yields tokens backend cannot verify; production keeps FedCM.
use_fedcm_for_prompt: !isLocalHost,
})
googleInitializedClientId = clientId
+31
View File
@@ -0,0 +1,31 @@
export type EpubSplitMode = "toc" | "regex" | "tag"
export const EPUB_HTML_TAG_PRESETS = [
{ id: "a", name: "Thẻ <a> (anchor / mục lục liên kết)", tag: "a" },
{ id: "h2", name: "Thẻ <h2>", tag: "h2" },
{ id: "h1", name: "Thẻ <h1>", tag: "h1" },
{ id: "h3", name: "Thẻ <h3>", tag: "h3" },
{ id: "p", name: "Thẻ <p>", tag: "p" },
] as const
export const DEFAULT_EPUB_CHAPTER_TAG = "a"
export function splitModeLabel(mode: string | undefined): string {
if (mode === "regex") return "Regex"
if (mode === "tag") return "Thẻ HTML"
return "TOC"
}
export function appendEpubSplitFormFields(
form: FormData,
splitMode: EpubSplitMode,
options?: { chapterRegex?: string; chapterTag?: string },
) {
form.append("splitMode", splitMode)
if (splitMode === "regex" && options?.chapterRegex) {
form.append("chapterRegex", options.chapterRegex)
}
if (splitMode === "tag") {
form.append("chapterTag", (options?.chapterTag || DEFAULT_EPUB_CHAPTER_TAG).trim() || DEFAULT_EPUB_CHAPTER_TAG)
}
}
-25
View File
@@ -1,25 +0,0 @@
export const MOD_AI_PREFILL_STORAGE_KEY = "mod:ai-tool:novel-prefill"
export const MOD_AI_MODEL_STORAGE_KEY = "mod:ai-tool:model"
export const MOD_AI_WEB_DEFAULT_MODEL = "gpt-4o-mini-search-preview"
export const MOD_AI_WEB_MODEL_OPTIONS = [
{
value: "gpt-4o-mini-search-preview",
label: "gpt-4o-mini-search-preview (nhanh)",
},
{
value: "gpt-4o-search-preview",
label: "gpt-4o-search-preview (chat luong cao)",
},
] as const
export type AINovelPrefillPayload = {
title?: string
originalTitle?: string
authorName?: string
originalAuthorName?: string
description?: string
coverUrl?: string
status?: "Đang ra" | "Hoàn thành" | "Tạm ngưng"
genresSuggested?: string[]
}