Skip to content

Commit

Permalink
Add Windows Support
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyn0w committed Jun 30, 2024
1 parent 79a2195 commit 5bcbf89
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 26 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file modified context_menu_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 34 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const MODES = {
WINDOW: 'Window'
}

let WORDS_CHANGE_INTERVAL_IN_MS = 5000;
let WORDS_CHANGE_INTERVAL_IN_MS = 10000;

let mainWindow;
let tray;
Expand Down Expand Up @@ -97,26 +97,29 @@ function createTray() {
label: 'Language',
submenu: createLanguageSubmenu()
},
{
label: 'Mode',
submenu: [
{
label: 'Window',
type: 'radio',
checked: true,
click: () => {
switchMode('Window');
}
},
{
label: 'Menu Bar',
type: 'radio',
click: () => {
switchMode('Menu Bar');
...(process.platform === 'darwin' ? [
{
label: 'Mode',
submenu: [
{
label: 'Window',
type: 'radio',
checked: currentMode === MODES.WINDOW,
click: () => {
switchMode(MODES.WINDOW);
}
},
{
label: 'Menu Bar',
type: 'radio',
checked: currentMode === MODES.MENU_BAR,
click: () => {
switchMode(MODES.MENU_BAR);
}
}
}
]
},
]
}
] : []),
{
label: 'Changing speed',
submenu: createWordSpeedChangingSubMenu()
Expand Down Expand Up @@ -273,7 +276,15 @@ function displayPhrase(index) {
function displayPhraseInTray(index) {
try {
const phrase = phrases[index];
tray.setTitle(phrase);
if (process.platform === 'win32') {
const contextMenu = Menu.buildFromTemplate([
{ label: phrase, enabled: false },
{ label: 'Quit', click: () => app.quit() }
]);
tray.setContextMenu(contextMenu);
} else {
tray.setTitle(phrase);
}
} catch (error) {
showError('Failed to display phrase in tray.', error);
}
Expand Down Expand Up @@ -344,9 +355,8 @@ app.whenReady().then(() => {
app.dock.hide();
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
mainWindow.setAlwaysOnTop(true, 'screen-saver');
}
else{
win.setAlwaysOnTop(true, 'screen-saver');
} else {
mainWindow.setAlwaysOnTop(true, 'screen-saver');
}

app.on('activate', function () {
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"start": "NODE_ENV=development electron .",
"build": "sudo electron-builder"
"build": "sudo electron-builder",
"build:win": "sudo electron-builder --win"
},
"build": {
"appId": "com.elmanhuseynov.vocabularify",
Expand All @@ -29,7 +30,15 @@
}
],
"win": {
"target": "nsis",
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"icon": "build/icon.ico"
},
"mac": {
Expand Down

0 comments on commit 5bcbf89

Please sign in to comment.