49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
// // 在 preload 脚本中。
|
|
const { ipcRenderer } = require('electron')
|
|
window.electron = {
|
|
// 设置窗口大小
|
|
setMainWindowSize: (config) => {
|
|
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
|
},
|
|
// 设置窗口状态
|
|
setViewStatus: (status) => {
|
|
ipcRenderer.invoke('setViewStatus', status)
|
|
},
|
|
// 获取当前是否全屏
|
|
getIsMaximized: () => {
|
|
return ipcRenderer.invoke('getIsMaximized')
|
|
},
|
|
// 获取共享屏幕列表
|
|
getSources: () => {
|
|
return ipcRenderer.invoke('getSources')
|
|
},
|
|
// 复制文字
|
|
setWriteText: (text) => {
|
|
return ipcRenderer.invoke('setWriteText', text)
|
|
},
|
|
// 加入房间通知
|
|
joinNotification: (user) => {
|
|
ipcRenderer.invoke('joinNotification', user)
|
|
},
|
|
// 监听退出
|
|
onQuit: (callback) => {
|
|
ipcRenderer.on('quit', callback)
|
|
},
|
|
// 监听更新
|
|
onUpdate: (callback) => {
|
|
ipcRenderer.on('update', callback)
|
|
},
|
|
// 通知下载最新的包
|
|
onDownload: (type) => {
|
|
ipcRenderer.invoke('updateDownload', type)
|
|
},
|
|
// 选择文件夹
|
|
selectFilePath: () => {
|
|
ipcRenderer.invoke('selectFilePath')
|
|
},
|
|
// 发送文件夹路径
|
|
onFilePath: (callback) => {
|
|
ipcRenderer.on('onFilePath', callback)
|
|
},
|
|
}
|