mirror of
https://github.com/bs-community/blessing-skin-plugins.git
synced 2025-01-08 11:37:27 +08:00
type preparation
This commit is contained in:
parent
7bca674bcd
commit
7aee47ae0e
44
globals.d.ts
vendored
Normal file
44
globals.d.ts
vendored
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user