Skip to content

Commit 4acf1b6

Browse files
committed
#RI-4567 - fix splash and tray
1 parent 5c8e34c commit 4acf1b6

File tree

8 files changed

+54
-38
lines changed

8 files changed

+54
-38
lines changed

configs/webpack.config.renderer.dev.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const skipDLLs =
1818
module.parent?.filename.includes('webpack.config.renderer.dev.dll') ||
1919
module.parent?.filename.includes('webpack.config.eslint');
2020

21+
const htmlPagesNames = ['splash.ejs', 'index.ejs']
2122
/**
2223
* Warn if the DLL is not built
2324
*/
@@ -233,19 +234,21 @@ const configuration: webpack.Configuration = {
233234

234235
new MonacoWebpackPlugin({ languages: ['json'], features: ['!rename'] }),
235236

236-
new HtmlWebpackPlugin({
237-
filename: path.join('index.html'),
238-
template: path.join(webpackPaths.desktopPath, 'index.ejs'),
239-
minify: {
240-
collapseWhitespace: true,
241-
removeAttributeQuotes: true,
242-
removeComments: true,
243-
},
244-
isBrowser: false,
245-
env: process.env.NODE_ENV,
246-
isDevelopment: process.env.NODE_ENV !== 'production',
247-
nodeModules: webpackPaths.appNodeModulesPath,
248-
}),
237+
...htmlPagesNames.map((htmlPageName) => (
238+
new HtmlWebpackPlugin({
239+
filename: path.join(`${htmlPageName.split('.')?.[0]}.html`),
240+
template: path.join(webpackPaths.desktopPath, htmlPageName),
241+
minify: {
242+
collapseWhitespace: true,
243+
removeAttributeQuotes: true,
244+
removeComments: true,
245+
},
246+
isBrowser: false,
247+
env: process.env.NODE_ENV,
248+
isDevelopment: process.env.NODE_ENV !== 'production',
249+
nodeModules: webpackPaths.appNodeModulesPath,
250+
})
251+
)),
249252

250253
new webpack.DefinePlugin({
251254
'process.env.NODE_ENV': JSON.stringify('development'),

configs/webpack.config.renderer.prod.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { version } from '../redisinsight/package.json';
1111

1212
DeleteSourceMaps();
1313

14+
const htmlPagesNames = ['splash.ejs', 'index.ejs']
15+
1416
const devtoolsConfig =
1517
process.env.DEBUG_PROD === 'true'
1618
? {
@@ -187,12 +189,14 @@ const configuration: webpack.Configuration = {
187189
filename: 'style.css',
188190
}),
189191

190-
new HtmlWebpackPlugin({
191-
filename: 'index.html',
192-
template: path.join(webpackPaths.desktopPath, 'index.ejs'),
193-
isBrowser: false,
194-
isDevelopment: false,
195-
}),
192+
...htmlPagesNames.map((htmlPageName) => (
193+
new HtmlWebpackPlugin({
194+
filename: path.join(`${htmlPageName.split('.')?.[0]}.html`),
195+
template: path.join(webpackPaths.desktopPath, htmlPageName),
196+
isBrowser: false,
197+
isDevelopment: false,
198+
})
199+
)),
196200

197201
new webpack.DefinePlugin({
198202
'process.type': '"renderer"',

redisinsight/desktop/splash.html renamed to redisinsight/desktop/splash.ejs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
}
2121
2222
.copyright {
23-
color: #B5B6C0
23+
color: #B5B6C0;
24+
font-size: 11px;
2425
}
2526
2627
.container {
@@ -79,11 +80,9 @@
7980
</div>
8081

8182
<script>
82-
const { ipcRenderer } = require('electron');
83-
8483
const bootstrap = async () => {
8584
86-
const appVersion = await ipcRenderer.invoke('getAppVersion') || ''
85+
const appVersion = await window.electron.ipcRenderer.invoke('getAppVersion') || ''
8786
const copyrightEl = document.getElementById('copyright') || null
8887
8988
if (copyrightEl) {

redisinsight/desktop/src/config/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { app } from 'electron'
2+
import path from 'path'
3+
import { getAssetPath } from 'desktopSrc/utils'
14
import pkg from '../../../package.json'
25
import configInit from '../../config.json'
36

@@ -9,4 +12,10 @@ config.description = pkg.description
912
config.version = pkg.version
1013
config.author = pkg.author
1114

15+
config.icon = getAssetPath('icon.png')
16+
17+
config.preloadPath = app.isPackaged
18+
? path.join(__dirname, 'preload.js')
19+
: path.join(__dirname, '../../dll/preload.js')
20+
1221
export default config

redisinsight/desktop/src/lib/tray-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BrowserWindow, Tray } from 'electron'
22
import { electronStore } from 'desktopSrc/services'
33
import { ElectronStorageItem } from 'uiSrc/electron/constants'
4+
// eslint-disable-next-line import/no-cycle
45
import { TrayBuilder } from './tray'
56

67
let tray: TrayBuilder

redisinsight/desktop/src/lib/tray.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ export class TrayBuilder {
99

1010
constructor() {
1111
// eslint-disable-next-line operator-linebreak
12-
const iconRelevantPath =
13-
process.platform === 'darwin' ? '../resources/icon-tray-white.png' : '../resources/icon-tray-colored.png'
14-
const iconPath = path.join(__dirname, iconRelevantPath)
15-
const icon = nativeImage.createFromPath(iconPath)
12+
const iconName = process.platform === 'darwin'
13+
? 'icon-tray-white.png'
14+
: 'icon-tray-colored.png'
15+
const iconPath = `${!app.isPackaged ? '../' : ''}../../../resources/`
16+
const iconFullPath = path.join(__dirname, iconPath, iconName)
17+
const icon = nativeImage.createFromPath(iconFullPath)
1618
const iconTray = icon.resize({ height: 16, width: 16 })
1719
iconTray.setTemplateImage(true)
1820

redisinsight/desktop/src/window/newWindow.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import contextMenu from 'electron-context-menu'
2-
import { BrowserWindow, app } from 'electron'
3-
import path from 'path'
2+
import { BrowserWindow } from 'electron'
43

54
import config from 'desktopSrc/config'
65
import { updateTray } from 'desktopSrc/lib'
76
import { initWindowHandlers } from 'desktopSrc/handlers'
8-
import { getAssetPath, resolveHtmlPath } from 'desktopSrc/utils'
9-
import { TITLE_SPLASH } from './splashWindow'
7+
import { resolveHtmlPath } from 'desktopSrc/utils'
108

119
export const windows = new Set<BrowserWindow>()
1210
export const getWindows = () => windows
@@ -16,7 +14,7 @@ export const createWindow = async (splash: BrowserWindow | null = null) => {
1614
let y
1715
const currentWindow = BrowserWindow.getFocusedWindow()
1816

19-
if (currentWindow && currentWindow?.getTitle() !== TITLE_SPLASH) {
17+
if (currentWindow && currentWindow?.getTitle() !== config.splashWindow.title) {
2018
const [currentWindowX, currentWindowY] = currentWindow.getPosition()
2119
x = currentWindowX + 24
2220
y = currentWindowY + 24
@@ -25,10 +23,9 @@ export const createWindow = async (splash: BrowserWindow | null = null) => {
2523
...config.mainWindow,
2624
x,
2725
y,
28-
icon: getAssetPath('icon.png'),
2926
webPreferences: {
3027
...config.mainWindow.webPreferences,
31-
preload: app.isPackaged ? path.join(__dirname, 'preload.js') : path.join(__dirname, '../../dll/preload.js')
28+
preload: config.preloadPath,
3229
}
3330
})
3431

redisinsight/desktop/src/window/splashWindow.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { BrowserWindow } from 'electron'
2-
import { getAssetPath, resolveHtmlPath } from 'desktopSrc/utils'
2+
import { resolveHtmlPath } from 'desktopSrc/utils'
33
import config from 'desktopSrc/config'
44

5-
export const TITLE_SPLASH = 'RedisInsight'
65
export const createSplashScreen = async () => {
76
const splash = new BrowserWindow({
87
...config.splashWindow,
9-
title: TITLE_SPLASH,
10-
icon: getAssetPath('icon.png')
8+
webPreferences: {
9+
...config.splashWindow.webPreferences,
10+
preload: config.preloadPath,
11+
}
1112
})
1213

1314
splash.loadURL(resolveHtmlPath('splash.html'))

0 commit comments

Comments
 (0)