ADD file via upload

main
pm9etfw54 2 months ago
parent 1c67ba2881
commit 8771cbf44a

@ -0,0 +1,39 @@
//预加载脚本
//绑定在主进程,跑在渲染进程
//只能获取部分Node的API
console.log('preload') //在日志里打印preload
const {contextBridge,ipcRenderer} = require('electron');
//引入electron且调用contextBridge桥梁模块
//ipcRenderer为调用通信模块(渲染进程)
contextBridge.exposeInMainWorld('myAPI',{
saveFile:(data)=>{
ipcRenderer.send('file-save',data) //发送参数 send<->on
},
readFile(){
return ipcRenderer.invoke('file-read') //读取并发送参数 invoke<->handle
},
closeWindow() {
ipcRenderer.send('close-main-window');
},
fullScreen() {
ipcRenderer.send('toggle-full-screen');
},
openTodolist() {
ipcRenderer.send('open-todolist')
},
minimizeWin() {
ipcRenderer.send('minimize-window')
},
newDiary() {
ipcRenderer.send('new-diary')
},
openClass() {
ipcRenderer.send('open-class-img')
}
})
//定义一个key并且调用node的version版本api
//saveFile为写入文件
//reaFile为写入文件
Loading…
Cancel
Save