type preparation

This commit is contained in:
Pig Fang 2023-02-04 18:38:09 +08:00
parent 7bca674bcd
commit 7aee47ae0e
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2

44
globals.d.ts vendored Normal file
View File

@ -0,0 +1,44 @@
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
}
// `var` is required here,
// otherwise the `blessing` property won't appear in `globalThis` type
declare var blessing: BlessingGlobals
interface Window {
blessing: BlessingGlobals
}