97 lines
2.6 KiB
JavaScript
97 lines
2.6 KiB
JavaScript
// // 在 preload 脚本中。
|
|
const { ipcRenderer } = require('electron')
|
|
window.electron = {
|
|
// 设置窗口大小
|
|
setMainWindowSize: (config) => {
|
|
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
|
},
|
|
// 获取窗口大小
|
|
getWindowSize: (config) => {
|
|
return ipcRenderer.invoke('getWindowSize')
|
|
},
|
|
// 设置窗口状态
|
|
setViewStatus: (status) => {
|
|
ipcRenderer.invoke('setViewStatus', status)
|
|
},
|
|
// 获取当前是否全屏
|
|
getIsMaximized: () => {
|
|
return ipcRenderer.invoke('getIsMaximized')
|
|
},
|
|
// 获取版本号
|
|
getVersion: () => {
|
|
return ipcRenderer.invoke('getVersion')
|
|
},
|
|
// 获取共享屏幕列表
|
|
getSources: () => {
|
|
return ipcRenderer.invoke('getSources')
|
|
},
|
|
// 复制文字
|
|
setWriteText: (text) => {
|
|
return ipcRenderer.invoke('setWriteText', text)
|
|
},
|
|
// 加入房间通知
|
|
joinNotification: (user) => {
|
|
ipcRenderer.invoke('joinNotification', user)
|
|
},
|
|
// 监听退出
|
|
onQuit: (callback) => {
|
|
ipcRenderer.on('onQuit', callback)
|
|
},
|
|
// 退出房间
|
|
quit: (bool) => {
|
|
return ipcRenderer.invoke('quit', bool)
|
|
},
|
|
// 监听更新
|
|
onUpdate: (callback) => {
|
|
ipcRenderer.on('update', callback)
|
|
},
|
|
// 执行退出房间
|
|
quitAndInstall: (callback) => {
|
|
ipcRenderer.on('quitAndInstall', callback)
|
|
},
|
|
// 通知下载最新的包
|
|
onDownload: (type) => {
|
|
ipcRenderer.invoke('updateDownload', type)
|
|
},
|
|
// 选择文件夹
|
|
selectFilePath: (data) => {
|
|
ipcRenderer.invoke('selectFilePath', data)
|
|
},
|
|
// 发送文件夹路径
|
|
onFilePath: (callback) => {
|
|
ipcRenderer.on('onFilePath', callback)
|
|
},
|
|
// 下载文件
|
|
downFile: (callback) => {
|
|
ipcRenderer.on('downFile', callback)
|
|
},
|
|
// 读取注册表
|
|
getRegistry: () => {
|
|
return ipcRenderer.invoke('getRegistry')
|
|
},
|
|
// 写入注册表
|
|
setRegistry: (uuid) => {
|
|
ipcRenderer.invoke('setRegistry', uuid)
|
|
},
|
|
// 创建子窗口
|
|
createChildWindow: (config) => {
|
|
ipcRenderer.invoke('createChildWindow', config)
|
|
},
|
|
// 关闭子窗口
|
|
closeChildWindow: (key) => {
|
|
ipcRenderer.invoke('closeChildWindow', key)
|
|
},
|
|
// 设置子窗口
|
|
setChildWindow: (config) => {
|
|
ipcRenderer.invoke('setChildWindow', config)
|
|
},
|
|
// 隐藏主窗口
|
|
mainWindowHide: () => {
|
|
ipcRenderer.invoke('mainWindowHide')
|
|
},
|
|
// 居中主窗口
|
|
mainWindowCenter: () => {
|
|
ipcRenderer.invoke('mainWindowCenter')
|
|
},
|
|
}
|