Upload files to "/"
This commit is contained in:
parent
aac3b23810
commit
ef09edb0cf
22
.eslintrc.js
Normal file
22
.eslintrc.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 13,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"__dirname": true,
|
||||||
|
"converse": true,
|
||||||
|
"exports": true,
|
||||||
|
"module": true,
|
||||||
|
"process": true,
|
||||||
|
"require": true,
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"prefer-const": "error",
|
||||||
|
}
|
||||||
|
};
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.DS_*
|
||||||
|
dist/
|
||||||
|
.idea/
|
23
index.html
Normal file
23
index.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>RS Desktop</title>
|
||||||
|
<!-- <link rel="stylesheet" type="text/css" media="screen" href="node_modules/converse.js/dist/converse.min.css"> -->
|
||||||
|
<!-- Custom css for the win!! -->
|
||||||
|
<link rel="stylesheet" type="text/css" media="screen" href="resources/css/customcss/converse.min.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="resources/css/app.css">
|
||||||
|
</head>
|
||||||
|
<base href="./index.html">
|
||||||
|
<body class="converse-fullscreen">
|
||||||
|
<div class="main-window">
|
||||||
|
<div class="page-default">
|
||||||
|
<div id="conversejs-bg"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Place libsignal at libs dir as it's not distributed with converse.js anymore -->
|
||||||
|
<script src="./3rdparty/libsignal-protocol.cjs"></script>
|
||||||
|
<script src="./node_modules/converse.js/dist/converse.min.js"></script>
|
||||||
|
<script type="module" src="./setup.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
161
main.js
Normal file
161
main.js
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
import { app, BrowserWindow, ipcMain, shell, powerMonitor } from 'electron';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import keytar from 'keytar';
|
||||||
|
|
||||||
|
import trayService from './modules/tray-service.js';
|
||||||
|
import menuService from './modules/menu-service.js';
|
||||||
|
import settingsService from './modules/settings-service.js';
|
||||||
|
import setFindBar from "find-bar" // search bar
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
export let mainWindow;
|
||||||
|
let zoom = 1;
|
||||||
|
|
||||||
|
const isMac = process.platform === 'darwin';
|
||||||
|
const isWin = process.platform === 'win32';
|
||||||
|
|
||||||
|
function initApp() {
|
||||||
|
if (!app.requestSingleInstanceLock()) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
createWindow();
|
||||||
|
|
||||||
|
if (isWin) {
|
||||||
|
app.setAppUserModelId("com.rscommunity.rs-desktop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
const getSavedWindowBounds = () => {
|
||||||
|
const winBounds = settingsService.get('winBounds') || { width: 800, height: 600, x: undefined, y: undefined }; winBounds.width = Math.max(winBounds.width, 200);
|
||||||
|
winBounds.height = Math.max(winBounds.height, 200);
|
||||||
|
return winBounds;
|
||||||
|
};
|
||||||
|
|
||||||
|
const mainWindowOptions = {
|
||||||
|
zoomToPageWidth: true,
|
||||||
|
show: false,
|
||||||
|
autoHideMenuBar: settingsService.get('hideMenubar') || false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
preload: path.join(__dirname, 'preload.cjs'), // this is a commonjs file, because electron doesnt support natively loading esm in preload files, which is retarded, but i cant change that.. so we will just cope :p
|
||||||
|
},
|
||||||
|
icon: path.join(__dirname, 'resources', 'images', 'logo-48x48.png'),
|
||||||
|
...getSavedWindowBounds(),
|
||||||
|
};
|
||||||
|
|
||||||
|
mainWindow = new BrowserWindow(mainWindowOptions);
|
||||||
|
|
||||||
|
trayService.initTray(mainWindow);
|
||||||
|
menuService.createMenu(mainWindow);
|
||||||
|
|
||||||
|
mainWindow.on('close', (e) => {
|
||||||
|
settingsService.set('isMaximized', mainWindow.isMaximized());
|
||||||
|
if (mainWindow.isFullScreen()) {
|
||||||
|
mainWindow.setFullScreen(false);
|
||||||
|
}
|
||||||
|
if (!app.isQuitting && settingsService.get('minimizeOnClose')) {
|
||||||
|
e.preventDefault();
|
||||||
|
mainWindow.hide();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.on('resized', () => {
|
||||||
|
settingsService.set('winBounds', mainWindow.getBounds());
|
||||||
|
});
|
||||||
|
mainWindow.on('moved', () => {
|
||||||
|
settingsService.set('winBounds', mainWindow.getBounds());
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isMac) {
|
||||||
|
powerMonitor.on('shutdown', () => {
|
||||||
|
app.isQuitting = true;
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.on('app-quit', () => {
|
||||||
|
app.isQuitting = true;
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('increaseZoom', () => { // custom zoom for the client
|
||||||
|
if (zoom >= 2) return;
|
||||||
|
zoom += 0.1;
|
||||||
|
mainWindow.webContents.setZoomFactor(zoom);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('decreaseZoom', () => {
|
||||||
|
if (zoom <= 0.5) return;
|
||||||
|
zoom -= 0.1;
|
||||||
|
mainWindow.webContents.setZoomFactor(zoom);
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.setZoomFactor(1);
|
||||||
|
|
||||||
|
mainWindow.on('closed', () => {
|
||||||
|
mainWindow = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
|
shell.openExternal(details.url).catch(console.log);
|
||||||
|
return { action: 'deny' };
|
||||||
|
});
|
||||||
|
|
||||||
|
settingsService.webContents = mainWindow.webContents;
|
||||||
|
|
||||||
|
ipcMain.handle('settings', (e, method, ...args) => {
|
||||||
|
return settingsService[method].apply(settingsService, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('trayService', (e, method, ...args) => {
|
||||||
|
return trayService[method].apply(trayService, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('keytar', (e, method, ...args) => {
|
||||||
|
return keytar[method].apply(keytar, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.on('ready-to-show', () => {
|
||||||
|
if (settingsService.get('isMaximized')) {
|
||||||
|
mainWindow.maximize();
|
||||||
|
} else {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.loadFile('index.html').catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
app.isQuitting = true;
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
app.on('ready', initApp);
|
||||||
|
|
||||||
|
app.on('browser-window-created', (_, win) => {
|
||||||
|
setFindBar(win); // search bar
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
if (mainWindow === null) {
|
||||||
|
createWindow();
|
||||||
|
} else {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('second-instance', () => {
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
|
Loading…
x
Reference in New Issue
Block a user