Prettier support
This commit is contained in:
@@ -5,7 +5,7 @@ const {
|
||||
ipcMain,
|
||||
Menu,
|
||||
nativeImage,
|
||||
Tray
|
||||
Tray,
|
||||
} = require('electron');
|
||||
const AutoLaunch = require('auto-launch');
|
||||
const Constants = require('../src/constants');
|
||||
@@ -44,12 +44,12 @@ const UpgradeIPC = require('../src/renderer/ipc/UpgradeIPC');
|
||||
const platform = os.platform();
|
||||
|
||||
const dimensions = {
|
||||
height: (platform === 'win32') ? 326 : (platform === 'darwin') ? 322 : 300,
|
||||
width: (platform === 'win32') ? 468 : 628,
|
||||
height: platform === 'win32' ? 326 : platform === 'darwin' ? 322 : 300,
|
||||
width: platform === 'win32' ? 468 : 628,
|
||||
};
|
||||
|
||||
let isShutdown = false;
|
||||
let isQuiting = false;
|
||||
let isQuitting = false;
|
||||
let isInstalling = false;
|
||||
let launchHidden = false;
|
||||
let cleanupReleases = false;
|
||||
@@ -88,7 +88,7 @@ const createWindow = () => {
|
||||
if (platform === 'linux') {
|
||||
extra = {
|
||||
icon: path.join(__dirname, '../build/', 'logo.png'),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Create the browser window.
|
||||
@@ -102,27 +102,29 @@ const createWindow = () => {
|
||||
...extra,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
webSecurity: !process.env.ELECTRON_START_URL
|
||||
}
|
||||
webSecurity: !process.env.ELECTRON_START_URL,
|
||||
},
|
||||
});
|
||||
if (platform === 'linux') {
|
||||
mainWindow.setMenuBarVisibility(false);
|
||||
} else {
|
||||
mainWindow.removeMenu();
|
||||
}
|
||||
if ((platform === 'darwin') && launchHidden) {
|
||||
if (platform === 'darwin' && launchHidden) {
|
||||
app.dock.hide();
|
||||
}
|
||||
|
||||
// and load the index.html of the app.
|
||||
const startUrl = process.env.ELECTRON_START_URL || url.format({
|
||||
pathname: path.join(__dirname, '../build/index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
});
|
||||
const startUrl =
|
||||
process.env.ELECTRON_START_URL ||
|
||||
url.format({
|
||||
pathname: path.join(__dirname, '../build/index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true,
|
||||
});
|
||||
|
||||
mainWindow.on('close', function (event) {
|
||||
if (!isQuiting) {
|
||||
if (!isQuitting) {
|
||||
event.preventDefault();
|
||||
if (mainWindow.isVisible()) {
|
||||
setWindowVisibility(false);
|
||||
@@ -140,9 +142,14 @@ const createWindow = () => {
|
||||
MountsIPC.unmountAllDrives();
|
||||
});
|
||||
|
||||
const appPath = (platform === 'win32') ? path.resolve(path.join(app.getAppPath(), '..\\..\\repertory-ui.exe')) :
|
||||
(platform === 'darwin') ? path.resolve(path.join(path.dirname(app.getAppPath()), '../MacOS/repertory-ui')) :
|
||||
process.env.APPIMAGE;
|
||||
const appPath =
|
||||
platform === 'win32'
|
||||
? path.resolve(path.join(app.getAppPath(), '..\\..\\repertory-ui.exe'))
|
||||
: platform === 'darwin'
|
||||
? path.resolve(
|
||||
path.join(path.dirname(app.getAppPath()), '../MacOS/repertory-ui')
|
||||
)
|
||||
: process.env.APPIMAGE;
|
||||
|
||||
const autoLauncher = new AutoLaunch({
|
||||
name: 'Repertory UI',
|
||||
@@ -151,51 +158,59 @@ const createWindow = () => {
|
||||
|
||||
trayContextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Visible', type: 'checkbox', click(item) {
|
||||
label: 'Visible',
|
||||
type: 'checkbox',
|
||||
click(item) {
|
||||
setWindowVisibility(item.checked);
|
||||
},
|
||||
checked: !launchHidden,
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Auto-start', type: 'checkbox', click(item) {
|
||||
label: 'Auto-start',
|
||||
type: 'checkbox',
|
||||
click(item) {
|
||||
if (item.checked) {
|
||||
autoLauncher.enable();
|
||||
} else {
|
||||
autoLauncher.disable();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Launch Hidden', type: 'checkbox', click(item) {
|
||||
label: 'Launch Hidden',
|
||||
type: 'checkbox',
|
||||
click(item) {
|
||||
launchHidden = !!item.checked;
|
||||
saveUiSettings();
|
||||
},
|
||||
checked: launchHidden,
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Delete Old Releases', type: 'checkbox', click(item) {
|
||||
label: 'Delete Old Releases',
|
||||
type: 'checkbox',
|
||||
click(item) {
|
||||
cleanupReleases = !!item.checked;
|
||||
saveUiSettings();
|
||||
},
|
||||
checked: cleanupReleases,
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Exit and Unmount', click() {
|
||||
label: 'Exit and Unmount',
|
||||
click() {
|
||||
closeApplication();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const image = nativeImage.createFromPath(path.join(__dirname, (platform === 'darwin') ? '../build/logo_mac.png' : '../build/logo.png'));
|
||||
const image = nativeImage.createFromPath(
|
||||
path.join(
|
||||
__dirname,
|
||||
platform === 'darwin' ? '../build/logo_mac.png' : '../build/logo.png'
|
||||
)
|
||||
);
|
||||
mainWindowTray = new Tray(image);
|
||||
|
||||
autoLauncher
|
||||
@@ -203,7 +218,7 @@ const createWindow = () => {
|
||||
.then((enabled) => {
|
||||
trayContextMenu.items[2].checked = enabled;
|
||||
mainWindowTray.setToolTip('Repertory UI');
|
||||
mainWindowTray.setContextMenu(trayContextMenu)
|
||||
mainWindowTray.setContextMenu(trayContextMenu);
|
||||
})
|
||||
.catch(() => {
|
||||
closeApplication();
|
||||
@@ -217,7 +232,10 @@ const getMainWindow = () => {
|
||||
};
|
||||
|
||||
const loadUiSettings = () => {
|
||||
const settingFile = path.join(helpers.resolvePath(Constants.DATA_LOCATIONS[platform]), 'ui.json');
|
||||
const settingFile = path.join(
|
||||
helpers.resolvePath(Constants.DATA_LOCATIONS[platform]),
|
||||
'ui.json'
|
||||
);
|
||||
try {
|
||||
if (fs.statSync(settingFile).isFile()) {
|
||||
const settings = JSON.parse(fs.readFileSync(settingFile, 'utf8'));
|
||||
@@ -225,37 +243,51 @@ const loadUiSettings = () => {
|
||||
cleanupReleases = !!settings.cleanup_releases;
|
||||
PlatformIPC.setPlatformOverride(settings.platform_override);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
const saveUiSettings = () => {
|
||||
const settingFile = path.join(helpers.getDataDirectory(), 'ui.json');
|
||||
try {
|
||||
fs.writeFileSync(settingFile, JSON.stringify({
|
||||
cleanup_releases: cleanupReleases,
|
||||
launch_hidden: launchHidden,
|
||||
platform_override: PlatformIPC.getPlatformOverride(),
|
||||
}), 'utf-8');
|
||||
} catch (e) {
|
||||
}
|
||||
fs.writeFileSync(
|
||||
settingFile,
|
||||
JSON.stringify({
|
||||
cleanup_releases: cleanupReleases,
|
||||
launch_hidden: launchHidden,
|
||||
platform_override: PlatformIPC.getPlatformOverride(),
|
||||
}),
|
||||
'utf-8'
|
||||
);
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
const setIsInstalling = installing => {
|
||||
const setIsInstalling = (installing) => {
|
||||
isInstalling = installing;
|
||||
};
|
||||
|
||||
const setTrayImage = driveInUse => {
|
||||
const setTrayImage = (driveInUse) => {
|
||||
let image;
|
||||
if (driveInUse) {
|
||||
image = nativeImage.createFromPath(path.join(__dirname, platform === 'darwin' ? '../build/logo_both_mac.png' : '../build/logo_both.png'));
|
||||
image = nativeImage.createFromPath(
|
||||
path.join(
|
||||
__dirname,
|
||||
platform === 'darwin'
|
||||
? '../build/logo_both_mac.png'
|
||||
: '../build/logo_both.png'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
image = nativeImage.createFromPath(path.join(__dirname, platform === 'darwin' ? '../build/logo_mac.png' : '../build/logo.png'));
|
||||
image = nativeImage.createFromPath(
|
||||
path.join(
|
||||
__dirname,
|
||||
platform === 'darwin' ? '../build/logo_mac.png' : '../build/logo.png'
|
||||
)
|
||||
);
|
||||
}
|
||||
mainWindowTray.setImage(image);
|
||||
};
|
||||
|
||||
const setWindowVisibility = show => {
|
||||
const setWindowVisibility = (show) => {
|
||||
if (show) {
|
||||
mainWindow.show();
|
||||
if (platform === 'darwin') {
|
||||
@@ -277,7 +309,7 @@ const setWindowVisibility = show => {
|
||||
|
||||
if (trayContextMenu && mainWindowTray) {
|
||||
trayContextMenu.items[0].checked = show;
|
||||
mainWindowTray.setContextMenu(trayContextMenu)
|
||||
mainWindowTray.setContextMenu(trayContextMenu);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -288,13 +320,13 @@ const standardIPCReply = (event, channel, data, error) => {
|
||||
...data,
|
||||
Error: error instanceof Error ? error.toString() : error,
|
||||
Success: !error,
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
app.on('before-quit', function () {
|
||||
isQuiting = true;
|
||||
isQuitting = true;
|
||||
});
|
||||
|
||||
let instanceLock = app.requestSingleInstanceLock();
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<meta charset="utf-8"/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
<meta name="theme-color" content="#000000"/>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is added to the
|
||||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:400,700" rel="stylesheet">
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Nunito:400,700"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
@@ -24,9 +30,7 @@
|
||||
<title>Repertory UI</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<noscript> You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
|
||||
Reference in New Issue
Block a user