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,
|
query: URLSearchParams,
|
||||||
hash: string
|
hash: string
|
||||||
) => boolean;
|
) => boolean;
|
||||||
handler: Function;
|
handler: (previous?: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import type { HookConfig, HookEvent } from "../config";
|
|||||||
import readerHook from "./readerHook";
|
import readerHook from "./readerHook";
|
||||||
import fetchHook from "./fetchHook";
|
import fetchHook from "./fetchHook";
|
||||||
import userHook from "./userHook";
|
import userHook from "./userHook";
|
||||||
|
import bookshelfHook from "./bookshelfHook";
|
||||||
|
|
||||||
const hooks: HookConfig[] = [
|
const hooks: HookConfig[] = [
|
||||||
...readerHook,
|
...readerHook,
|
||||||
...fetchHook,
|
...fetchHook,
|
||||||
...userHook,
|
...userHook,
|
||||||
|
...bookshelfHook,
|
||||||
];
|
];
|
||||||
|
|
||||||
async function onEvent(event: HookEvent, previous?: string) {
|
async function onEvent(event: HookEvent, previous?: string) {
|
||||||
|
|||||||
@@ -282,11 +282,11 @@ async function insertContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// let currentBook: Book | null = null
|
// let currentBook: Book | null = null
|
||||||
async function onUrlChange(_previous: string): Promise<void> {
|
async function onUrlChange(_previous?: string): Promise<void> {
|
||||||
// TODO: 记录并上报阅读历史和记录
|
// TODO: 记录并上报阅读历史和记录
|
||||||
await insertContent()
|
await insertContent()
|
||||||
}
|
}
|
||||||
async function onHashChange(_previous: string): Promise<void> {
|
async function onHashChange(_previous?: string): Promise<void> {
|
||||||
// TODO: 支持从hash里解析并跳转到指定行
|
// TODO: 支持从hash里解析并跳转到指定行
|
||||||
}
|
}
|
||||||
async function onLoad(): Promise<void> {
|
async function onLoad(): Promise<void> {
|
||||||
|
|||||||
Reference in new issue
Block a user