Skip to content

Commit

Permalink
style: optimize directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
xueelf committed Nov 10, 2023
1 parent d793dbe commit b201b64
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
34 changes: 2 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,12 @@ import windowsClose from '@/icons/windows/close.svg';
import windowsMinimize from '@/icons/windows/minimize.svg';
import windowsStretch from '@/icons/windows/stretch.svg';

type Hook<T = void> = T extends unknown[] ? (callback: (...args: T) => void) => void : (callback: () => void) => void;

interface Docsify {}

interface DocsifyHook {
/** 初始化完成后调用,只调用一次,没有参数。 */
init: Hook;
/** 每次开始解析 Markdown 内容时调用。 */
beforeEach: Hook<[string]>;
/** 解析成 html 后调用。 */
afterEach: Hook<[string, (html: string) => void]>;
/** 每次路由切换时数据全部加载完成后调用,没有参数。 */
doneEach: Hook;
/** 初始化并第一次加载完成数据后调用,只触发一次,没有参数。 */
mounted: Hook;
/** 初始化并第一次加载完成数据后调用,没有参数。 */
ready: Hook;
}

interface User {
export interface User {
avatar?: string;
nickname: string;
}

interface DocsifyChatSetting {
export interface DocsifyChatSetting {
[key: string]: unknown;
animation: number;
myself: string | null;
Expand All @@ -42,17 +23,6 @@ interface DocsifyChatSetting {
version: string;
}

declare global {
interface Window {
$docsify?: {
[k: string]: unknown;
chat?: Partial<DocsifyChatSetting>;
plugins?: Function[];
};
Docsify: Docsify;
}
}

enum ClassName {
ChatImage = 'chat-image',
ChatMessage = 'chat-message',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"strict": true,
"skipLibCheck": true
},
"include": ["src", "package.json"]
"include": ["src", "types", "package.json"]
}
31 changes: 31 additions & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { DocsifyChatSetting } from '@/index.js';

declare global {
type Hook<T = void> = T extends unknown[] ? (callback: (...args: T) => void) => void : (callback: () => void) => void;

interface Docsify {}

interface DocsifyHook {
/** 初始化完成后调用,只调用一次,没有参数。 */
init: Hook;
/** 每次开始解析 Markdown 内容时调用。 */
beforeEach: Hook<[string]>;
/** 解析成 html 后调用。 */
afterEach: Hook<[string, (html: string) => void]>;
/** 每次路由切换时数据全部加载完成后调用,没有参数。 */
doneEach: Hook;
/** 初始化并第一次加载完成数据后调用,只触发一次,没有参数。 */
mounted: Hook;
/** 初始化并第一次加载完成数据后调用,没有参数。 */
ready: Hook;
}

interface Window {
$docsify?: {
[k: string]: unknown;
chat?: Partial<DocsifyChatSetting>;
plugins?: Function[];
};
Docsify: Docsify;
}
}
File renamed without changes.

0 comments on commit b201b64

Please sign in to comment.