This commit is contained in:
parent
f48a5a5613
commit
dc9307e3a3
343
main.js
343
main.js
|
|
@ -109,195 +109,190 @@ function createWindow() {
|
||||||
mainWindow = new AppWindow();
|
mainWindow = new AppWindow();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
|
const additionalData = { myKey: 'myValue' }
|
||||||
// 处理单实例
|
|
||||||
app.on('session-created', (session) => {
|
|
||||||
if (mainWindow) {
|
|
||||||
if (mainWindow.isMinimized()) mainWindow.restore();
|
|
||||||
mainWindow.focus();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 退出房间
|
// 退出房间
|
||||||
app.on('will-quit', async (event) => {
|
app.on('will-quit', async (event) => {
|
||||||
await mainWindow.webContents.send('quitAndInstall');
|
await mainWindow.webContents.send('quitAndInstall');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1];
|
const gotTheLock = app.requestSingleInstanceLock(additionalData)
|
||||||
if (env === 'development') {
|
if (gotTheLock) {
|
||||||
Object.defineProperty(app, 'isPackaged', {
|
env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1];
|
||||||
get() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
autoUpdater.updateConfigPath = path.join('latest.yml')
|
|
||||||
}
|
|
||||||
createWindow()
|
|
||||||
updateHandle() // 检查更新
|
|
||||||
createTray()
|
|
||||||
// 获取当前脚本所在目录的绝对路径
|
|
||||||
const currentDirectory = __dirname;
|
|
||||||
// 获取安装父目录
|
|
||||||
const parentDirectory = path.resolve(currentDirectory, '..');
|
|
||||||
const customFolderPath = path.join(parentDirectory, 'Downloads');
|
|
||||||
if (!fs.existsSync(customFolderPath)) {
|
|
||||||
// 如果不存在,则创建文件夹
|
|
||||||
fs.mkdirSync(customFolderPath);
|
|
||||||
}
|
|
||||||
// 监听f12打开控制台
|
|
||||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
|
||||||
if (env === 'development') {
|
if (env === 'development') {
|
||||||
if (input.key === 'F12') {
|
Object.defineProperty(app, 'isPackaged', {
|
||||||
mainWindow.webContents.openDevTools()
|
get() {
|
||||||
}
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
autoUpdater.updateConfigPath = path.join('latest.yml')
|
||||||
}
|
}
|
||||||
});
|
createWindow()
|
||||||
// 监听移动
|
updateHandle() // 检查更新
|
||||||
mainWindow.on('move', () => {
|
createTray()
|
||||||
// 如果是全屏自动恢复到上次窗口大小
|
// 获取当前脚本所在目录的绝对路径
|
||||||
if (isMaximized) {
|
const currentDirectory = __dirname;
|
||||||
mainWindow.setResizable(true)
|
// 获取安装父目录
|
||||||
mainWindow.unmaximize()
|
const parentDirectory = path.resolve(currentDirectory, '..');
|
||||||
isMaximized = false;
|
const customFolderPath = path.join(parentDirectory, 'Downloads');
|
||||||
|
if (!fs.existsSync(customFolderPath)) {
|
||||||
|
// 如果不存在,则创建文件夹
|
||||||
|
fs.mkdirSync(customFolderPath);
|
||||||
}
|
}
|
||||||
if (mainWindow.isMaximized()) {
|
// 监听f12打开控制台
|
||||||
isMaximized = true;
|
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||||
}
|
|
||||||
});
|
|
||||||
// 放大缩小退出窗口
|
|
||||||
ipcMain.handle('setViewStatus', async (event, status) => {
|
|
||||||
switch (status) {
|
|
||||||
case 'quit':
|
|
||||||
await mainWindow.webContents.send('onQuit');
|
|
||||||
break;
|
|
||||||
case 'maximize':
|
|
||||||
mainWindow.maximize()
|
|
||||||
mainWindow.setResizable(false)
|
|
||||||
break;
|
|
||||||
case 'unmaximize':
|
|
||||||
mainWindow.setResizable(true)
|
|
||||||
mainWindow.unmaximize()
|
|
||||||
break;
|
|
||||||
case 'minimize':
|
|
||||||
mainWindow.minimize()
|
|
||||||
break;
|
|
||||||
case 'hide':
|
|
||||||
mainWindow.hide()
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 导出是否全屏
|
|
||||||
ipcMain.handle('getIsMaximized', () => {
|
|
||||||
return mainWindow.isMaximized();
|
|
||||||
});
|
|
||||||
// 获取版本号
|
|
||||||
ipcMain.handle('getVersion', () => {
|
|
||||||
return app.getVersion();
|
|
||||||
});
|
|
||||||
// 获取共享屏幕列表
|
|
||||||
ipcMain.handle('getSources', async () => {
|
|
||||||
return await desktopCapturer.getSources({
|
|
||||||
types: ['screen']
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// 复制文字
|
|
||||||
ipcMain.handle('setWriteText', (event, text) => {
|
|
||||||
clipboard.writeText(text)
|
|
||||||
});
|
|
||||||
// 退出
|
|
||||||
ipcMain.handle('quit', async (event) => {
|
|
||||||
await mainWindow.webContents.send('quitAndInstall');
|
|
||||||
quit()
|
|
||||||
});
|
|
||||||
// 加入房间通知
|
|
||||||
ipcMain.handle('joinNotification', (event, user) => {
|
|
||||||
mainWindow.show()
|
|
||||||
mainWindow.focus();
|
|
||||||
});
|
|
||||||
// 通知下载包
|
|
||||||
ipcMain.handle('updateDownload', (event, data) => {
|
|
||||||
if (data === '0') { // 取消下载
|
|
||||||
cancleDownloadUpdate()
|
|
||||||
} else if (data === '1') { // 开始下载
|
|
||||||
downloadUpdate()
|
|
||||||
} else if (data === '2') { // 下载完成 点击安装
|
|
||||||
quitAndInstall()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 选择文件夹
|
|
||||||
ipcMain.handle('selectFilePath', async (event, data) => {
|
|
||||||
const result = await dialog.showOpenDialog({
|
|
||||||
properties: ['openDirectory']
|
|
||||||
});
|
|
||||||
if (result.canceled) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
switch (data.key) {
|
|
||||||
case 'shareFilesPath':
|
|
||||||
case 'recordingFilesPath':
|
|
||||||
mainWindow.webContents.send('onFilePath', result.filePaths[0] + '\\', data.key);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mainWindow.webContents.send('downFile', {
|
|
||||||
downFilePaths: result.filePaths[0] + '\\',
|
|
||||||
fileName: data.fileName,
|
|
||||||
filePath: data.filePath,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 设置桌面应用基础属性
|
|
||||||
ipcMain.handle('setMainWindowSize', (event, config) => {
|
|
||||||
// 设置最小窗口尺寸
|
|
||||||
mainWindow.setMinimumSize(config.width, config.height);
|
|
||||||
// 设置最大尺寸
|
|
||||||
const primaryDisplay = screen.getPrimaryDisplay()
|
|
||||||
const { width, height } = primaryDisplay.workAreaSize
|
|
||||||
if (config.key === 'login') {
|
|
||||||
mainWindow.setMaximumSize(config.width, config.height);
|
|
||||||
} else {
|
|
||||||
mainWindow.setMaximumSize(width, height);
|
|
||||||
}
|
|
||||||
// 设置窗口尺寸
|
|
||||||
mainWindow.setSize(config.width, config.height)
|
|
||||||
// 设置窗口位置使其居中于当前屏幕
|
|
||||||
const display = screen.getDisplayMatching({ ...mainWindow.getBounds() });
|
|
||||||
const x = Math.round((display.workArea.width - mainWindow.getSize()[0]) / 2);
|
|
||||||
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
|
|
||||||
mainWindow.setPosition(x, y);
|
|
||||||
});
|
|
||||||
// 打开新窗口
|
|
||||||
ipcMain.handle('oepnWindow', (event, data) => {
|
|
||||||
const newWindow = new BrowserWindow({
|
|
||||||
width: 1200,
|
|
||||||
height: 800,
|
|
||||||
minWidth: 1200,
|
|
||||||
minHeight: 800,
|
|
||||||
webPreferences: {
|
|
||||||
contextIsolation: false,
|
|
||||||
nodeIntegration: true,
|
|
||||||
enableRemoteModule: true,
|
|
||||||
nodeIntegrationInWorker: true,
|
|
||||||
allowMediaDevices: true,
|
|
||||||
preload: path.join(__dirname, 'preload.js')
|
|
||||||
},
|
|
||||||
frame: false,
|
|
||||||
backgroundColor: '#00000000',
|
|
||||||
transparent: true,
|
|
||||||
});
|
|
||||||
newWindow.loadURL(data.url);
|
|
||||||
newWindow.focus();
|
|
||||||
newWindow.webContents.on('before-input-event', (event, input) => {
|
|
||||||
if (env === 'development') {
|
if (env === 'development') {
|
||||||
if (input.key === 'F12') {
|
if (input.key === 'F12') {
|
||||||
newWindow.webContents.openDevTools()
|
mainWindow.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
// 监听移动
|
||||||
});
|
mainWindow.on('move', () => {
|
||||||
|
// 如果是全屏自动恢复到上次窗口大小
|
||||||
|
if (isMaximized) {
|
||||||
|
mainWindow.setResizable(true)
|
||||||
|
mainWindow.unmaximize()
|
||||||
|
isMaximized = false;
|
||||||
|
}
|
||||||
|
if (mainWindow.isMaximized()) {
|
||||||
|
isMaximized = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 放大缩小退出窗口
|
||||||
|
ipcMain.handle('setViewStatus', async (event, status) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'quit':
|
||||||
|
await mainWindow.webContents.send('onQuit');
|
||||||
|
break;
|
||||||
|
case 'maximize':
|
||||||
|
mainWindow.maximize()
|
||||||
|
mainWindow.setResizable(false)
|
||||||
|
break;
|
||||||
|
case 'unmaximize':
|
||||||
|
mainWindow.setResizable(true)
|
||||||
|
mainWindow.unmaximize()
|
||||||
|
break;
|
||||||
|
case 'minimize':
|
||||||
|
mainWindow.minimize()
|
||||||
|
break;
|
||||||
|
case 'hide':
|
||||||
|
mainWindow.hide()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 导出是否全屏
|
||||||
|
ipcMain.handle('getIsMaximized', () => {
|
||||||
|
return mainWindow.isMaximized();
|
||||||
|
});
|
||||||
|
// 获取版本号
|
||||||
|
ipcMain.handle('getVersion', () => {
|
||||||
|
return app.getVersion();
|
||||||
|
});
|
||||||
|
// 获取共享屏幕列表
|
||||||
|
ipcMain.handle('getSources', async () => {
|
||||||
|
return await desktopCapturer.getSources({
|
||||||
|
types: ['screen']
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// 复制文字
|
||||||
|
ipcMain.handle('setWriteText', (event, text) => {
|
||||||
|
clipboard.writeText(text)
|
||||||
|
});
|
||||||
|
// 退出
|
||||||
|
ipcMain.handle('quit', async (event) => {
|
||||||
|
await mainWindow.webContents.send('quitAndInstall');
|
||||||
|
quit()
|
||||||
|
});
|
||||||
|
// 加入房间通知
|
||||||
|
ipcMain.handle('joinNotification', (event, user) => {
|
||||||
|
mainWindow.show()
|
||||||
|
mainWindow.focus();
|
||||||
|
});
|
||||||
|
// 通知下载包
|
||||||
|
ipcMain.handle('updateDownload', (event, data) => {
|
||||||
|
if (data === '0') { // 取消下载
|
||||||
|
cancleDownloadUpdate()
|
||||||
|
} else if (data === '1') { // 开始下载
|
||||||
|
downloadUpdate()
|
||||||
|
} else if (data === '2') { // 下载完成 点击安装
|
||||||
|
quitAndInstall()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 选择文件夹
|
||||||
|
ipcMain.handle('selectFilePath', async (event, data) => {
|
||||||
|
const result = await dialog.showOpenDialog({
|
||||||
|
properties: ['openDirectory']
|
||||||
|
});
|
||||||
|
if (result.canceled) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
switch (data.key) {
|
||||||
|
case 'shareFilesPath':
|
||||||
|
case 'recordingFilesPath':
|
||||||
|
mainWindow.webContents.send('onFilePath', result.filePaths[0] + '\\', data.key);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mainWindow.webContents.send('downFile', {
|
||||||
|
downFilePaths: result.filePaths[0] + '\\',
|
||||||
|
fileName: data.fileName,
|
||||||
|
filePath: data.filePath,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 设置桌面应用基础属性
|
||||||
|
ipcMain.handle('setMainWindowSize', (event, config) => {
|
||||||
|
// 设置最小窗口尺寸
|
||||||
|
mainWindow.setMinimumSize(config.width, config.height);
|
||||||
|
// 设置最大尺寸
|
||||||
|
const primaryDisplay = screen.getPrimaryDisplay()
|
||||||
|
const { width, height } = primaryDisplay.workAreaSize
|
||||||
|
if (config.key === 'login') {
|
||||||
|
mainWindow.setMaximumSize(config.width, config.height);
|
||||||
|
} else {
|
||||||
|
mainWindow.setMaximumSize(width, height);
|
||||||
|
}
|
||||||
|
// 设置窗口尺寸
|
||||||
|
mainWindow.setSize(config.width, config.height)
|
||||||
|
// 设置窗口位置使其居中于当前屏幕
|
||||||
|
const display = screen.getDisplayMatching({ ...mainWindow.getBounds() });
|
||||||
|
const x = Math.round((display.workArea.width - mainWindow.getSize()[0]) / 2);
|
||||||
|
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
|
||||||
|
mainWindow.setPosition(x, y);
|
||||||
|
});
|
||||||
|
// 打开新窗口
|
||||||
|
ipcMain.handle('oepnWindow', (event, data) => {
|
||||||
|
const newWindow = new BrowserWindow({
|
||||||
|
width: 1200,
|
||||||
|
height: 800,
|
||||||
|
minWidth: 1200,
|
||||||
|
minHeight: 800,
|
||||||
|
webPreferences: {
|
||||||
|
contextIsolation: false,
|
||||||
|
nodeIntegration: true,
|
||||||
|
enableRemoteModule: true,
|
||||||
|
nodeIntegrationInWorker: true,
|
||||||
|
allowMediaDevices: true,
|
||||||
|
preload: path.join(__dirname, 'preload.js')
|
||||||
|
},
|
||||||
|
frame: false,
|
||||||
|
backgroundColor: '#00000000',
|
||||||
|
transparent: true,
|
||||||
|
});
|
||||||
|
newWindow.loadURL(data.url);
|
||||||
|
newWindow.focus();
|
||||||
|
newWindow.webContents.on('before-input-event', (event, input) => {
|
||||||
|
if (env === 'development') {
|
||||||
|
if (input.key === 'F12') {
|
||||||
|
newWindow.webContents.openDevTools()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
// 检测更新,在你想要检查更新的时候执行,renderer事件触发后的操作自行编写
|
// 检测更新,在你想要检查更新的时候执行,renderer事件触发后的操作自行编写
|
||||||
function updateHandle() {
|
function updateHandle() {
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
.isUpdateModal {
|
.isUpdateModal {
|
||||||
height: 500px;
|
|
||||||
background-color: rgb(21, 25, 29);
|
background-color: rgb(21, 25, 29);
|
||||||
background-size: 100% auto;
|
background-size: 100% auto;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
padding: 140px 30px 0;
|
padding: 130px 30px 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
.remarks {
|
.remarks {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: #C8C8C8;
|
color: #C8C8C8;
|
||||||
height: 70%;
|
min-height: 240px;
|
||||||
|
max-height: 240px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
.button2 {
|
.button2 {
|
||||||
margin-top: 10px;
|
padding: 10px 0;
|
||||||
color: #555454;
|
color: #555454;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ $pagination-hover-background-color: #5575F2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-modal-body {
|
.ant-modal-body {
|
||||||
max-height: 80vh;
|
max-height: 90vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue