Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhora o funcionamento no Windows e ajeita algumas coisas #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Binary file added assets/iconWhiteTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/iconWhiteTemplate@1,25x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/iconWhiteTemplate@1,5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 26 additions & 26 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ const Sentry = require('@sentry/electron');

Sentry.init({ dsn: 'https://[email protected]/1506479' });

const schema = {
projects: {
type: 'string',
},
};
const isWindows = process.platform.includes('win');

const store = new Store({ schema });
const store = new Store();

app.dock.hide();
if(app.dock){
app.dock.hide()
}

let tray = null;
let trayPosition = {};

function render(tray) {
function render() {
const storedProjects = store.get('projects');
const projects = storedProjects ? JSON.parse(storedProjects) : [];
const projects = storedProjects || [];

const items = projects.map(project => ({
label: project.name,
Expand All @@ -34,18 +35,19 @@ function render(tray) {
PATH: process.env.PATH,
},
stdio: 'inherit',
shell: isWindows
});
},
},
{
label: 'Remover',
click: () => {
store.set(
'projects',
JSON.stringify(projects.filter(item => item.path !== project.path)),
);
store.set('projects', projects.filter(item => item.path !== project.path));

render();

if(trayPosition)
tray.popUpContextMenu(null, trayPosition);
},
},
],
Expand All @@ -62,16 +64,10 @@ function render(tray) {
const [path] = result;
const name = basename(path);

store.set(
'projects',
JSON.stringify([
...projects,
{
path,
name,
},
]),
);
store.set('projects', [...projects, {
path,
name,
}]);

render();
},
Expand All @@ -92,10 +88,14 @@ function render(tray) {
]);

tray.setContextMenu(contextMenu);
tray.on('click', (event, boundaries, position) => {
tray.popUpContextMenu();
trayPosition = position;
});
}

app.on('ready', () => {
const tray = new Tray(resolve(__dirname, 'assets', 'iconTemplate.png'));
tray = new Tray(resolve(__dirname, 'assets', `icon${isWindows ? 'White' : ''}Template.png`));

render(tray);
});
render();
});