Skip to content

Commit e6fc466

Browse files
authored
Windows desktop integration fixes. (#9628)
* Windows desktop integration fixes: icons, notification messages, paths, jump list Signed-off-by: Denis Gladkiy <[email protected]> * Fixed typos and formatting Signed-off-by: Denis Gladkiy <[email protected]> --------- Signed-off-by: Denis Gladkiy <[email protected]>
1 parent 3fe325b commit e6fc466

File tree

13 files changed

+192
-38
lines changed

13 files changed

+192
-38
lines changed

desktop-package/installer.nsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!macro customInit
2+
StrCpy $INSTDIR "$LOCALAPPDATA\Programs\HulyDesktop"
3+
!macroend

desktop-package/package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,26 @@
6464
],
6565
"artifactName": "Huly-windows-${version}.${ext}",
6666
"verifyUpdateCodeSignature": false,
67-
"icon": "./src/AppIcon.png",
67+
"icon": "./src/AppIcon.ico",
6868
"publish": {
6969
"provider": "generic",
7070
"url": "https://dist.huly.io",
7171
"channel": "latest"
72-
}
72+
},
73+
"extraResources": [
74+
{
75+
"from": "./dist/ui/public/icons/",
76+
"to": "./icons/",
77+
"filter": [
78+
"**/*.ico"
79+
]
80+
}
81+
]
82+
},
83+
"nsis": {
84+
"include": "installer.nsh",
85+
"installerIcon": "./src/AppIcon.ico",
86+
"uninstallerIcon": "./src/AppIcon.ico"
7387
},
7488
"linux": {
7589
"artifactName": "Huly-linux-${version}.${ext}",

desktop/public/AppIcon.ico

403 KB
Binary file not shown.

desktop/public/icons/InboxIcon.ico

31.3 KB
Binary file not shown.

desktop/public/icons/OfficeIcon.ico

31.3 KB
Binary file not shown.

desktop/public/icons/PlannerIcon.ico

31.3 KB
Binary file not shown.

desktop/public/icons/SettingsIcon.ico

31.3 KB
Binary file not shown.

desktop/src/main/customMenu.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515

1616
import { app, BrowserWindow } from 'electron'
17-
import { MenuBarAction, StandardMenuCommandLogout, StandardMenuCommandSelectWorkspace, StandardMenuCommandOpenSettings } from '../ui/types'
17+
import { MenuBarAction, CommandLogout, CommandSelectWorkspace, CommandOpenSettings } from '../ui/types'
1818

1919
export function dipatchMenuBarAction(mainWindow: BrowserWindow | undefined, action: MenuBarAction) {
2020
if (mainWindow == null) {
@@ -33,13 +33,13 @@ export function dipatchMenuBarAction(mainWindow: BrowserWindow | undefined, acti
3333

3434
switch (action) {
3535
case 'settings':
36-
mainWindow.webContents.send(StandardMenuCommandOpenSettings)
36+
mainWindow.webContents.send(CommandOpenSettings)
3737
break;
3838
case 'select-workspace':
39-
mainWindow.webContents.send(StandardMenuCommandSelectWorkspace)
39+
mainWindow.webContents.send(CommandSelectWorkspace)
4040
break;
4141
case 'logout':
42-
mainWindow.webContents.send(StandardMenuCommandLogout)
42+
mainWindow.webContents.send(CommandLogout)
4343
break;
4444
case 'exit':
4545
app.quit();

desktop/src/main/standardMenu.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
//
1515

1616
import { Menu, MenuItemConstructorOptions } from 'electron'
17-
import { StandardMenuCommand, StandardMenuCommandOpenSettings, StandardMenuCommandSelectWorkspace, StandardMenuCommandLogout, } from '../ui/types'
17+
import { Command, CommandOpenSettings, CommandSelectWorkspace, CommandLogout, } from '../ui/types'
1818

1919
const isMac = process.platform === 'darwin'
2020
const isLinux = process.platform === 'linux'
2121

22-
export const addMenus = (sendCommand: (cmd: StandardMenuCommand, ...args: any[]) => void): void => {
22+
export const addMenus = (sendCommand: (cmd: Command, ...args: any[]) => void): void => {
2323
const template: MenuItemConstructorOptions[] = [
2424
{
2525
label: 'File',
2626
submenu: [
2727
{
2828
label: 'Settings',
2929
accelerator: isLinux ? 'Ctrl+,' : 'Meta+,',
30-
click: () => { sendCommand(StandardMenuCommandOpenSettings) }
30+
click: () => { sendCommand(CommandOpenSettings) }
3131
},
3232
{
3333
label: 'Select workspace',
34-
click: () => { sendCommand(StandardMenuCommandSelectWorkspace) }
34+
click: () => { sendCommand(CommandSelectWorkspace) }
3535
},
3636
{
3737
label: 'Logout',
38-
click: () => { sendCommand(StandardMenuCommandLogout) }
38+
click: () => { sendCommand(CommandLogout) }
3939
},
4040
{ role: isMac ? 'close' : 'quit' }
4141
]

desktop/src/main/start.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ import { ProgressInfo, UpdateInfo } from 'electron-updater'
2222
import WinBadge from 'electron-windows-badge'
2323
import * as path from 'path'
2424

25-
import { Config, MenuBarAction, NotificationParams, StandardMenuCommandLogout, StandardMenuCommandSelectWorkspace, StandardMenuCommandOpenSettings } from '../ui/types'
25+
import { Config, MenuBarAction, NotificationParams } from '../ui/types'
2626
import { getOptions } from './args'
2727
import { addMenus } from './standardMenu'
2828
import { dipatchMenuBarAction } from './customMenu'
2929
import { addPermissionHandlers } from './permissions'
3030
import autoUpdater from './updater'
3131
import { generateId } from '@hcengineering/core'
3232
import { DownloadItem } from '@hcengineering/desktop-downloads'
33+
import { setupWindowsSpecific } from './windowsSpecificSetup'
34+
3335

3436
let mainWindow: BrowserWindow | undefined
3537
let winBadge: any
@@ -39,7 +41,7 @@ const isWindows = process.platform === 'win32'
3941
const isDev = process.env.NODE_ENV === 'development'
4042

4143
const sessionPartition = !isDev ? 'persist:huly' : 'persist:huly_dev'
42-
const iconKey = path.join(app.getAppPath(), 'dist', 'ui', 'public', 'AppIcon.png')
44+
const iconKey = path.join(app.getAppPath(), 'dist', 'ui', 'public', isWindows ? 'AppIcon.ico' : 'AppIcon.png')
4345
const preloadScriptPath = path.join(app.getAppPath(), 'dist', 'main', 'preload.js')
4446

4547
const defaultWidth = 1440
@@ -200,7 +202,7 @@ function handleAuthRedirects (window: BrowserWindow): void {
200202
}
201203

202204
function handleWillDownload (window: BrowserWindow): void {
203-
window.webContents.session.on('will-download', (event, item) => {
205+
window.webContents.session.on('will-download', (_event, item) => {
204206
const key = generateId()
205207

206208
const notifyDownloadUpdated = (): void => {
@@ -303,10 +305,14 @@ const createWindow = async (): Promise<void> => {
303305
}
304306
}
305307

306-
if (false == isWindows) {
307-
addMenus((cmd: string, ...args: any[]) => {
308-
mainWindow?.webContents.send(cmd, ...args)
309-
})
308+
function sendCommand(cmd: string, ...args: any[]): void {
309+
mainWindow?.webContents.send(cmd, ...args)
310+
}
311+
312+
if (isWindows) {
313+
setupWindowsSpecific(sendCommand)
314+
} else {
315+
addMenus(sendCommand)
310316
}
311317

312318
contextMenu({
@@ -315,7 +321,7 @@ contextMenu({
315321
showSelectAll: false
316322
})
317323

318-
ipcMain.on('set-badge', (event, badge: number) => {
324+
ipcMain.on('set-badge', (_event: any, badge: number) => {
319325
app.dock?.setBadge(badge > 0 ? `${badge}` : '')
320326
app.badgeCount = badge
321327

@@ -324,11 +330,11 @@ ipcMain.on('set-badge', (event, badge: number) => {
324330
}
325331
})
326332

327-
ipcMain.on('dock-bounce', (event) => {
333+
ipcMain.on('dock-bounce', (_event: any) => {
328334
app.dock?.bounce('informational')
329335
})
330336

331-
ipcMain.on('send-notification', (event, notificationParams: NotificationParams) => {
337+
ipcMain.on('send-notification', (_event: any, notificationParams: NotificationParams) => {
332338
if (Notification.isSupported()) {
333339
const notification = new Notification(notificationParams)
334340

@@ -341,13 +347,13 @@ ipcMain.on('send-notification', (event, notificationParams: NotificationParams)
341347
}
342348
})
343349

344-
ipcMain.on('set-title', (event, title) => {
350+
ipcMain.on('set-title', (event: any, title: string) => {
345351
const webContents = event.sender
346352
const window = BrowserWindow.fromWebContents(webContents)
347353
window?.setTitle(title)
348354
})
349355

350-
ipcMain.on('set-combined-config', (event, config: Config) => {
356+
ipcMain.on('set-combined-config', (_event: any, config: Config) => {
351357
log.info('Config set: ', config)
352358

353359
setupCookieHandler(config)
@@ -363,7 +369,7 @@ ipcMain.on('set-combined-config', (event, config: Config) => {
363369
void autoUpdater.checkForUpdatesAndNotify()
364370
})
365371

366-
ipcMain.handle('get-main-config', (event, path) => {
372+
ipcMain.handle('get-main-config', (_event: any, _path: any) => {
367373
const cfg = {
368374
CONFIG_URL: process.env.CONFIG_URL ?? '',
369375
FRONT_URL,
@@ -373,11 +379,11 @@ ipcMain.handle('get-main-config', (event, path) => {
373379
}
374380
return cfg
375381
})
376-
ipcMain.handle('get-host', (event, path) => {
382+
ipcMain.handle('get-host', (_event: any, _path: any) => {
377383
return new URL(FRONT_URL).host
378384
})
379385

380-
ipcMain.on('set-front-cookie', function (event, host: string, name: string, value: string) {
386+
ipcMain.on('set-front-cookie', function (event: any, host: string, name: string, value: string) {
381387
const webContents = event.sender
382388
const win = BrowserWindow.fromWebContents(webContents)
383389
const cv: CookiesSetDetails = {
@@ -428,7 +434,7 @@ if (!gotTheLock) {
428434
ipcMain.handle('get-screen-access', () => systemPreferences.getMediaAccessStatus('screen') === 'granted')
429435
ipcMain.handle('get-screen-sources', () => {
430436
return desktopCapturer.getSources({ types: ['window', 'screen'], fetchWindowIcons: true, thumbnailSize: { width: 225, height: 135 } }).then(async sources => {
431-
return sources.map(source => {
437+
return sources.map((source: any) => {
432438
return {
433439
...source,
434440
appIconURL: source.appIcon?.toDataURL(),
@@ -490,7 +496,7 @@ autoUpdater.on('update-available', (info: UpdateInfo) => {
490496
defaultId: 0,
491497
message: `A new version ${info.version} is available and it is required to continue. It will be downloaded and installed automatically.`
492498
})
493-
.then(({ response }) => {
499+
.then(({ response }: any) => {
494500
log.info(`Update dialog exit code: ${response}`) // eslint-disable-line no-console
495501

496502
if (response !== 0) {
@@ -513,7 +519,7 @@ function setDownloadProgress (percent: number): void {
513519
mainWindow.webContents.send('handle-update-download-progress', percent)
514520
}
515521

516-
autoUpdater.on('update-downloaded', (info) => {
522+
autoUpdater.on('update-downloaded', (_info: any) => {
517523
// We have listeners that prevents the app from being exited on mac
518524
app.removeAllListeners('window-all-closed')
519525
mainWindow?.removeAllListeners('close')

0 commit comments

Comments
 (0)