forked from bs-community/blessing-skin-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
76 lines (67 loc) · 1.55 KB
/
types.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { EventEmitter } from 'events'
class Toast {
success(message: string): void {
message
}
info(message: string): void {
message
}
warning(message: string): void {
message
}
error(message: string): void {
message
}
}
export let base_url = '/'
export let locale = 'en'
export let site_name = 'Blessing Skin'
export let version: string
export let route: string
export function t(key: string, params?: object): string {
const data = params ? `(${JSON.stringify(params)})` : ''
return key + data
}
export const fetch = {
async get<T = any>(url: string, params?: Record<string, any>): Promise<T> {
url
params
return {} as T
},
async post<T = any>(url: string, data?: any): Promise<T> {
url
data
return {} as T
},
async put<T = any>(url: string, data?: any): Promise<T> {
url
data
return {} as T
},
async del<T = any>(url: string, data?: any): Promise<T> {
url
data
return {} as T
},
}
const emitter = new EventEmitter()
export const event = {
on(eventName: string | symbol, listener: (...args: any[]) => any): () => void {
emitter.on(eventName, listener)
return () => {
emitter.off(eventName, listener)
}
},
emit(eventName: string | symbol, payload?: object): void {
emitter.emit(eventName, payload)
},
}
export const notify = {
showModal(options?: object): Promise<{ value: string }> {
return Promise.resolve({ value: JSON.stringify(options) })
},
toast: new Toast(),
}
declare global {
let trans: (key: string, params?: object) => string
}