1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | declare module 'vconsole' {
|
7 |
|
8 | export interface VConsoleConfig {
|
9 | defaultPlugins?: string[]
|
10 | onReady?: () => void
|
11 | onClearLog?: () => void
|
12 | maxLogNumber?: number
|
13 | disableLogScrolling?: boolean
|
14 | theme?: 'light' | 'dark'
|
15 | }
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 | export class VConsoleInstance {
|
22 | constructor (config?: VConsoleConfig)
|
23 |
|
24 | // properties
|
25 | readonly version: string
|
26 | option: VConsoleConfig
|
27 | readonly activedTab: string
|
28 | readonly tabList: string[]
|
29 | readonly $dom: HTMLDivElement
|
30 |
|
31 | // methods
|
32 | setOption (config: VConsoleConfig): void;
|
33 | setOption <TKey extends keyof VConsoleConfig>(key: TKey, value: VConsoleConfig[TKey]): void
|
34 | destroy (): void
|
35 | addPlugin (plugin: VConsolePluginInstance): boolean
|
36 | removePlugin (pluginId: string): boolean
|
37 | showTab (pluginId: string): void
|
38 | show (): void
|
39 | hide (): void
|
40 | showSwitch (): void
|
41 | hideSwitch (): void
|
42 | }
|
43 |
|
44 | /**
|
45 | * VConsole Plugin Event List
|
46 | * @see https://github.com/Tencent/vConsole/blob/dev/doc/plugin_event_list.md
|
47 | */
|
48 | export interface VConsolePluginEventMap {
|
49 | init (): void
|
50 |
|
51 | renderTab (
|
52 | callback: <AnyElement extends { appendTo: () => void }>(html: string | HTMLElement | AnyElement) => void
|
53 | ): void
|
54 |
|
55 | addTopBar (
|
56 | callback: (
|
57 | btnList: {
|
58 | name: string
|
59 | data?: { [key: string]: string | number }
|
60 | className?: string
|
61 | onClick (e: MouseEvent | TouchEvent): void | boolean
|
62 | }[]
|
63 | ) => void
|
64 | ): void
|
65 |
|
66 | addTool (
|
67 | callback: (
|
68 | toolList: {
|
69 | name: string
|
70 | global?: boolean
|
71 | onClick (e: MouseEvent | TouchEvent): void | boolean
|
72 | }[]
|
73 | ) => void
|
74 | ): void
|
75 |
|
76 | ready (): void
|
77 |
|
78 | remove (): void
|
79 |
|
80 | show (): void
|
81 |
|
82 | hide (): void
|
83 |
|
84 | showConsole (): void
|
85 |
|
86 | hideConsole (): void
|
87 |
|
88 | updateOption (): void
|
89 | }
|
90 |
|
91 | |
92 |
|
93 |
|
94 |
|
95 | export class VConsolePluginInstance {
|
96 | constructor (id: string, name?: string)
|
97 |
|
98 | // properties
|
99 | id: string
|
100 | name: string
|
101 | vConsole: VConsoleInstance
|
102 |
|
103 | // methods
|
104 | on<EventName extends keyof VConsolePluginEventMap> (
|
105 | eventName: EventName,
|
106 | callback: VConsolePluginEventMap[EventName]
|
107 | ): VConsolePluginInstance
|
108 | trigger<T = any> (eventName: keyof VConsolePluginEventMap, data: T): VConsolePluginInstance
|
109 | }
|
110 |
|
111 | export class VConsole extends VConsoleInstance {
|
112 | static VConsolePlugin: VConsolePluginInstance
|
113 | }
|
114 |
|
115 | export default VConsole
|
116 | }
|