Skip to content

Commit 486ccdf

Browse files
committed
change icon
1 parent 73832d3 commit 486ccdf

13 files changed

Lines changed: 5937 additions & 7 deletions

File tree

assets/icon.icns

321 KB
Binary file not shown.

assets/icon.ico

100755100644
-189 KB
Binary file not shown.

assets/icon.png

26.7 KB
Loading

assets/player.icns

770 KB
Binary file not shown.

assets/player.ico

2.01 KB
Binary file not shown.

electron/main.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { join, dirname } from 'path';
22
import { Readable } from 'stream';
33
import { createGunzip } from 'zlib';
44
import { fileURLToPath } from 'node:url';
5-
import { createReadStream, createWriteStream, unlink } from 'fs';
5+
import { createReadStream, createWriteStream, existsSync, unlink } from 'fs';
66

7-
import { app, ipcMain } from 'electron';
7+
import { app, ipcMain, nativeImage } from 'electron';
88
import { BrowserWindow } from 'electron';
99

1010
export const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -14,7 +14,44 @@ let window: any;
1414

1515
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
1616

17+
const resolveAppIconPath = () => {
18+
const devIconPath = join(process.cwd(), 'public', 'icon.png');
19+
const bundledIconPath = join(app.getAppPath(), 'dist', 'icon.png');
20+
21+
if (existsSync(devIconPath)) {
22+
return devIconPath;
23+
}
24+
25+
if (existsSync(bundledIconPath)) {
26+
return bundledIconPath;
27+
}
28+
29+
return undefined;
30+
};
31+
32+
const applyAppIcon = () => {
33+
const iconPath = resolveAppIconPath();
34+
35+
if (!iconPath) {
36+
return undefined;
37+
}
38+
39+
const icon = nativeImage.createFromPath(iconPath);
40+
41+
if (icon.isEmpty()) {
42+
return undefined;
43+
}
44+
45+
if (process.platform === 'darwin') {
46+
app.dock.setIcon(icon);
47+
}
48+
49+
return icon;
50+
};
51+
1752
const createWindow = () => {
53+
const appIcon = applyAppIcon();
54+
1855
window = new BrowserWindow({
1956
width: 1300,
2057
height: 800,
@@ -32,7 +69,8 @@ const createWindow = () => {
3269
// 网页的 JavaScript 代码与 Electron 提供的 API(如 require)共享同一个上下文
3370
contextIsolation: true
3471
},
35-
title: 'JumpServer Video Player'
72+
title: 'Video Player',
73+
icon: appIcon
3674
});
3775

3876
const serveUrl = process.env.VITE_DEV_SERVER_URL;
@@ -124,7 +162,7 @@ app.whenReady().then(() => {
124162
});
125163

126164
ipcMain.handle('set-title', _event => {
127-
window.setTitle('JumpServer Video Player');
165+
window.setTitle('Video Player');
128166
});
129167
});
130168

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
5+
<link rel="icon" type="image/png" href="/icon.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title></title>
88
</head>

0 commit comments

Comments
 (0)