mirror of
https://github.com/naiyQAQ/fanqie-assistant.git
synced 2026-10-21 10:24:47 +00:00
feat: 明确 hook callback 的函数签名
This commit is contained in:
1 parent
6294b47c32
commit
03475e1880
3 files changed
+5
-3
No files matched your search
+1
-1
@@ -20,7 +20,7 @@ export interface HookConfig {
|
||||
query: URLSearchParams,
|
||||
hash: string
|
||||
) => boolean;
|
||||
handler: Function;
|
||||
handler: (previous?: string) => Promise<void>;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -282,11 +282,11 @@ async function insertContent() {
|
||||
}
|
||||
|
||||
// let currentBook: Book | null = null
|
||||
async function onUrlChange(_previous: string): Promise<void> {
|
||||
async function onUrlChange(_previous?: string): Promise<void> {
|
||||
// TODO: 记录并上报阅读历史和记录
|
||||
await insertContent()
|
||||
}
|
||||
async function onHashChange(_previous: string): Promise<void> {
|
||||
async function onHashChange(_previous?: string): Promise<void> {
|
||||
// TODO: 支持从hash里解析并跳转到指定行
|
||||
}
|
||||
async function onLoad(): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user