forked from bs-community/blessing-skin-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.d.ts
48 lines (40 loc) · 1.05 KB
/
globals.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
interface BlessingGlobals {
base_url: string
site_name: string
locale: string
version: string
route: string
t(key: string, params?: object): string
fetch: {
get<T = any>(url: string, params?: Record<string, unknown>): Promise<T>
post<T = any>(url: string, data?: any): Promise<T>
put<T = any>(url: string, data?: any): Promise<T>
del<T = any>(url: string, data?: any): Promise<T>
}
event: {
on(
eventName: string | symbol,
listener: (...args: any[]) => any,
): () => void
emit(eventName: string | symbol, payload?: object): void
}
notify: {
showModal(options?: object): Promise<{ value: string }>
toast: Toast
}
}
declare class Toast {
success(message: string): void
info(message: string): void
warning(message: string): void
error(message: string): void
}
export {}
declare global {
// `var` is required here,
// otherwise the `blessing` property won't appear in `globalThis` type
declare var blessing: BlessingGlobals
interface Window {
blessing: BlessingGlobals
}
}