diff --git a/src/config.ts b/src/config.ts index c02c4fc..6d2601f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -20,7 +20,7 @@ export interface HookConfig { query: URLSearchParams, hash: string ) => boolean; - handler: Function; + handler: (previous?: string) => Promise; } /* diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 9eaddd6..b94ecb8 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -2,11 +2,13 @@ import type { HookConfig, HookEvent } from "../config"; import readerHook from "./readerHook"; import fetchHook from "./fetchHook"; import userHook from "./userHook"; +import bookshelfHook from "./bookshelfHook"; const hooks: HookConfig[] = [ ...readerHook, ...fetchHook, ...userHook, + ...bookshelfHook, ]; async function onEvent(event: HookEvent, previous?: string) { diff --git a/src/hooks/readerHook.ts b/src/hooks/readerHook.ts index 7bdc8a8..12d5fd8 100644 --- a/src/hooks/readerHook.ts +++ b/src/hooks/readerHook.ts @@ -282,11 +282,11 @@ async function insertContent() { } // let currentBook: Book | null = null -async function onUrlChange(_previous: string): Promise { +async function onUrlChange(_previous?: string): Promise { // TODO: 记录并上报阅读历史和记录 await insertContent() } -async function onHashChange(_previous: string): Promise { +async function onHashChange(_previous?: string): Promise { // TODO: 支持从hash里解析并跳转到指定行 } async function onLoad(): Promise {