-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreload.js
60 lines (50 loc) · 2.12 KB
/
preload.js
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
const { contextBridge, ipcRenderer } = require('electron')
// Testing function
contextBridge.exposeInMainWorld('versions', {
node: ()=> process.versions.node,
chrome: ()=> process.versions.chrome,
test: ()=> ipcRenderer.invoke('test'),
fileTree: ()=> ipcRenderer.invoke('fileTree'),
electron: ()=> process.versions.electron,
})
// FileSystem
contextBridge.exposeInMainWorld('fs', {
main: (v)=> ipcRenderer.invoke('fs-main',v),
type: (v)=> ipcRenderer.invoke('fs-type',v),
path: ()=> ipcRenderer.invoke('fs-path'),
getDir: ()=> ipcRenderer.invoke('fs-getDir'),
createMeta: ()=> ipcRenderer.invoke('fs-createMeta'),
openfile: (v)=> ipcRenderer.invoke('fs-openfile',v)
})
// ChildWindow
contextBridge.exposeInMainWorld('cw', {
setting: () => ipcRenderer.invoke('cw-setting'),
codelab: () => ipcRenderer.invoke('cw-codelab'),
stylelab: () => ipcRenderer.invoke('cw-stylelab')
})
// TagSystem
contextBridge.exposeInMainWorld('tag', {
main: (i,v,p) => ipcRenderer.invoke('tag-main',i,v,p),
info: (v,p) => ipcRenderer.invoke('tag-info',v,p),
remove: (i,v,id,p) => ipcRenderer.invoke('tag-remove',i,v,id,p),
query: (v,t,p,b) => ipcRenderer.invoke('tag-query',v,t,p,b),
match: (v) => ipcRenderer.invoke('tag-match',v),
monitor: (v) => ipcRenderer.invoke('tag-monitor',v),
error: (v) => ipcRenderer.invoke('tag-error',v),
delDB: () => ipcRenderer.invoke('ts-delDB')
})
// MonitorSystem
contextBridge.exposeInMainWorld('mnt', {
main: () => ipcRenderer.invoke('mnt-main'),
load: (i) => ipcRenderer.invoke('mnt-load',i),
query: (i,j,b) => ipcRenderer.invoke('mnt-query',i,j,b),
get: (i) => ipcRenderer.invoke('mnt-get',i),
remove: (i,j,b) => ipcRenderer.invoke('mnt-remove',i,j,b),
delete: (i) => ipcRenderer.invoke('mnt-delete',i),
deleteM: (i,j) => ipcRenderer.invoke('mnt-delete-member',i,j),
create: () => ipcRenderer.invoke('mnt-create'),
rename: (i,j) => ipcRenderer.invoke('mnt-rename',i,j),
update: (i,j,b) => ipcRenderer.invoke('mnt-update',i,j,b),
error: (i) => ipcRenderer.invoke('mnt-error',i),
build: () => ipcRenderer.invoke('mnt-build')
})