206 lines
6.2 KiB
JavaScript
206 lines
6.2 KiB
JavaScript
// // 在 preload 脚本中。
|
|
const { ipcRenderer } = require('electron')
|
|
window.electron = {
|
|
// socket
|
|
startSignalr: (user) => {
|
|
ipcRenderer.invoke('startSignalr', user)
|
|
},
|
|
offSignalr: () => {
|
|
ipcRenderer.invoke('offSignalr')
|
|
},
|
|
onStop: () => {
|
|
ipcRenderer.invoke('onStop')
|
|
},
|
|
onInvoke: (str, data) => {
|
|
ipcRenderer.invoke('onInvoke', str, data)
|
|
},
|
|
changeLocalStorage: (callback) => {
|
|
ipcRenderer.on('changeLocalStorage', callback)
|
|
},
|
|
onOtherSignalr: (callback) => {
|
|
ipcRenderer.invoke('onOtherSignalr')
|
|
ipcRenderer.removeAllListeners('onOtherSignalr')
|
|
ipcRenderer.on('onOtherSignalr', callback)
|
|
},
|
|
onSignalr: (callback) => {
|
|
ipcRenderer.invoke('onSignalr')
|
|
ipcRenderer.removeAllListeners('onSignalr')
|
|
ipcRenderer.on('onSignalr', callback)
|
|
},
|
|
// 设置窗口大小
|
|
setMainWindowSize: (config) => {
|
|
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
|
},
|
|
// 获取窗口大小
|
|
getWindowSize: (config) => {
|
|
return ipcRenderer.invoke('getWindowSize')
|
|
},
|
|
// 设置窗口状态
|
|
setViewStatus: (status) => {
|
|
ipcRenderer.invoke('setViewStatus', status)
|
|
},
|
|
// 获取当前是否全屏
|
|
getIsMaximized: () => {
|
|
return ipcRenderer.invoke('getIsMaximized')
|
|
},
|
|
// 获取app路径
|
|
getAppPath: () => {
|
|
return ipcRenderer.invoke('getAppPath')
|
|
},
|
|
// 获取版本号
|
|
getVersion: () => {
|
|
return ipcRenderer.invoke('getVersion')
|
|
},
|
|
// 获取环境
|
|
getEnv: () => {
|
|
return ipcRenderer.invoke('getEnv')
|
|
},
|
|
// 获取窗口是否显示
|
|
isVisible: () => {
|
|
return ipcRenderer.invoke('isVisible')
|
|
},
|
|
// 获取共享屏幕列表
|
|
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)
|
|
},
|
|
// 点击任务栏图标是否打开窗口
|
|
isOpenWindows: (callback) => {
|
|
ipcRenderer.on('isOpenWindows', callback)
|
|
},
|
|
// 首次加载
|
|
startLoad: () => {
|
|
ipcRenderer.invoke('startLoad')
|
|
},
|
|
// 更新
|
|
updateHandle: () => {
|
|
ipcRenderer.invoke('updateHandle')
|
|
},
|
|
// 通知下载最新的包
|
|
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: (str) => {
|
|
switch (str) {
|
|
case 'show':
|
|
ipcRenderer.invoke('setChildWindowShow', {
|
|
key: 'shareScreenWindow',
|
|
})
|
|
ipcRenderer.invoke('setChildWindowShow', {
|
|
key: 'chatSmallWindow',
|
|
})
|
|
break;
|
|
case 'hide':
|
|
ipcRenderer.invoke('createChildWindow', {
|
|
url: location.origin + `/#/noticeWindow`,
|
|
width: 388,
|
|
height: 180,
|
|
key: 'noticeWindow',
|
|
})
|
|
ipcRenderer.invoke('createChildWindow', {
|
|
url: location.origin + `/#/shareScreenWindow`,
|
|
width: 400,
|
|
height: 80,
|
|
key: 'shareScreenWindow',
|
|
})
|
|
ipcRenderer.invoke('createChildWindow', {
|
|
url: location.origin + `/#/chatSmallWindow`,
|
|
width: 200,
|
|
height: 150,
|
|
key: 'chatSmallWindow',
|
|
})
|
|
ipcRenderer.invoke('createChildWindow', {
|
|
url: location.origin + `/#/chatBigWindow`,
|
|
width: 540,
|
|
height: 640,
|
|
key: 'chatBigWindow',
|
|
})
|
|
ipcRenderer.invoke('createChildWindow', {
|
|
url: location.origin + `/#/userListWindow`,
|
|
width: 440,
|
|
height: 540,
|
|
key: 'userListWindow',
|
|
})
|
|
break;
|
|
case 'stop':
|
|
ipcRenderer.invoke('setChildWindowShow', {
|
|
key: 'shareScreenWindow',
|
|
bool: true
|
|
})
|
|
ipcRenderer.invoke('setChildWindowShow', {
|
|
key: 'chatSmallWindow',
|
|
bool: true
|
|
})
|
|
break;
|
|
}
|
|
},
|
|
// 关闭子窗口
|
|
closeChildWindow: (key) => {
|
|
ipcRenderer.invoke('closeChildWindow', key)
|
|
},
|
|
// 设置子窗口
|
|
setChildWindow: (config) => {
|
|
ipcRenderer.invoke('setChildWindow', config)
|
|
},
|
|
// 隐藏主窗口
|
|
setChildWindowShow: (config) => {
|
|
ipcRenderer.invoke('setChildWindowShow', config)
|
|
},
|
|
// 定位主窗口
|
|
setPosition: (data) => {
|
|
ipcRenderer.invoke('setPosition', data)
|
|
},
|
|
// 窗口通信传参
|
|
windowHandleMessage: (data) => {
|
|
ipcRenderer.invoke('windowHandleMessage', data)
|
|
},
|
|
// 窗口通信回调
|
|
windowHandleMessageCallBack: (callback) => {
|
|
ipcRenderer.on('windowHandleMessageCallBack', callback)
|
|
},
|
|
}
|