Skip to content

Commit 883b6d1

Browse files
committed
🔧 build: 修复部分构建图标显示错误
1 parent ee9bbf0 commit 883b6d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+126
-115
lines changed

.env.example

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ RENDERER_VITE_SITE_ANTHOR = "無名"
2121
RENDERER_VITE_SITE_KEYWORDS = "SPlayer,云音乐,播放器,在线音乐,在线播放器,音乐播放器"
2222
RENDERER_VITE_SITE_DES = "一个简约的在线音乐播放器,具有音乐搜索、播放、每日推荐、私人FM、歌词显示、歌曲评论、网易云登录与云盘等功能"
2323
RENDERER_VITE_SITE_URL = "imsyy.top"
24-
RENDERER_VITE_SITE_LOGO = "/images/logo/favicon.svg"
25-
RENDERER_VITE_SITE_APPLE_LOGO = "/images/logo/favicon-apple.png"
2624

2725
# Cookie
2826
## 咪咕音乐 Cookie

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<div align="center">
2+
<img alt="logo" height="80" src="./public/images/icons/favicon.png" />
3+
<h2>SPlayer</h2>
4+
<p>一个简约的音乐播放器</p>
5+
<img alt="main" src="./screenshots/main.png" />
6+
</div>
7+
<br />
8+
9+
## 说明
10+
111
> [!IMPORTANT]
212
>
313
> ## 严肃警告
@@ -8,16 +18,6 @@
818
> - 若发现未遵守 **AGPL-3.0** 许可协议的行为,**本项目将永久停更**
919
> - 感谢您的尊重与理解
1020
11-
<div align="center">
12-
<img alt="logo" height="80" src="./public/images/logo/favicon.png" />
13-
<h2>SPlayer</h2>
14-
<p>一个简约的音乐播放器</p>
15-
<img alt="main" src="./screenshots/main.png" />
16-
</div>
17-
<br />
18-
19-
## 说明
20-
2121
- 本项目采用 [Vue 3](https://cn.vuejs.org/) 全家桶和 [Naïve UI](https://www.naiveui.com/) 组件库及 [Electron](https://www.electronjs.org/zh/docs/latest/) 开发
2222
- 支持网页端与客户端,由于设备有限,目前仅适配 `Win`,其他平台可自行构建
2323
- ~~仅对移动端做了基础适配,**不保证功能全部可用**~~

electron-builder.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ asarUnpack:
1919
# Windows 平台配置
2020
win:
2121
# 可执行文件名
22-
executableName: splayer
22+
executableName: SPlayer
2323
# 应用程序的图标文件路径
24-
icon: public/images/logo/favicon_256.png
24+
icon: public/images/icons/favicon-512x512.png
2525
# 构建类型
2626
target: nsis
2727
# 管理员权限
@@ -42,12 +42,16 @@ nsis:
4242
allowElevation: true
4343
# 是否允许用户更改安装目录
4444
allowToChangeInstallationDirectory: true
45+
# 安装包图标
46+
installerIcon: public/images/icons/favicon.ico
47+
# 卸载命令图标
48+
uninstallerIcon: public/images/icons/favicon.ico
4549
# macOS 平台配置
4650
mac:
4751
# 可执行文件名
48-
executableName: splayer
52+
executableName: SPlayer
4953
# 应用程序的图标文件路径
50-
icon: public/images/logo/favicon_512.png
54+
icon: public/images/icons/favicon-512x512.png
5155
# 权限继承的文件路径
5256
entitlementsInherit: build/entitlements.mac.plist
5357
# 扩展信息,如权限描述
@@ -67,9 +71,9 @@ dmg:
6771
# Linux 平台配置
6872
linux:
6973
# 可执行文件名
70-
executableName: splayer
74+
executableName: SPlayer
7175
# 应用程序的图标文件路径
72-
icon: public/images/logo/favicon_256.png
76+
icon: public/images/icons/favicon-512x512.png
7377
# 构建类型
7478
target:
7579
- AppImage

electron.vite.config.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,22 @@ export default defineConfig(({ mode }) => {
106106
background_color: "#efefef",
107107
icons: [
108108
{
109-
src: "/images/logo/favicon.png",
110-
sizes: "200x200",
109+
src: "/images/icons/favicon-32x32.png",
110+
sizes: "32x32",
111111
type: "image/png",
112112
},
113113
{
114-
src: "/images/logo/favicon_512.png",
114+
src: "/images/icons/favicon-96x96.png",
115+
sizes: "96x96",
116+
type: "image/png",
117+
},
118+
{
119+
src: "/images/icons/favicon-256x256.png",
120+
sizes: "256x256",
121+
type: "image/png",
122+
},
123+
{
124+
src: "/images/icons/favicon-512x512.png",
115125
sizes: "512x512",
116126
type: "image/png",
117127
},
@@ -147,12 +157,6 @@ export default defineConfig(({ mode }) => {
147157
},
148158
},
149159
sourcemap: false,
150-
win: {
151-
icon: resolve(__dirname, "/public/images/logo/favicon.png"),
152-
},
153-
linux: {
154-
icon: resolve(__dirname, "/public/images/logo/favicon.png"),
155-
},
156160
},
157161
},
158162
};

electron/main/index.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { join } from "path";
2-
import { app, protocol, shell, BrowserWindow, globalShortcut } from "electron";
2+
import { app, protocol, shell, BrowserWindow, globalShortcut, nativeImage } from "electron";
33
import { platform, optimizer, is } from "@electron-toolkit/utils";
44
import { startNcmServer } from "@main/startNcmServer";
55
import { startMainServer } from "@main/startMainServer";
66
import { configureAutoUpdater } from "@main/utils/checkUpdates";
7-
import createSystemInfo from "@main/utils/createSystemInfo";
7+
import createSystemTray from "@main/utils/createSystemTray";
88
import createGlobalShortcut from "@main/utils/createGlobalShortcut";
99
import mainIpcMain from "@main/mainIpcMain";
1010
import Store from "electron-store";
@@ -15,7 +15,7 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
1515

1616
// 配置 log
1717
log.transports.file.resolvePathFn = () =>
18-
join(app.getPath("documents"), "/SPlayer/splayer-log.txt");
18+
join(app.getPath("documents"), "/SPlayer/SPlayer-log.txt");
1919
// 设置日志文件的最大大小为 2 MB
2020
log.transports.file.maxSize = 2 * 1024 * 1024;
2121
// 绑定 console 事件
@@ -93,7 +93,7 @@ class MainProcess {
9393
}
9494

9595
// 注册应用协议
96-
app.setAsDefaultProtocolClient("splayer");
96+
app.setAsDefaultProtocolClient("SPlayer");
9797
// 应用程序准备好之前注册
9898
protocol.registerSchemesAsPrivileged([
9999
{ scheme: "app", privileges: { secure: true, standard: true } },
@@ -107,6 +107,7 @@ class MainProcess {
107107
createWindow() {
108108
// 创建浏览器窗口
109109
this.mainWindow = new BrowserWindow({
110+
title: app.getName() || "SPlayer",
110111
width: this.store.get("windowSize.width") || 1280, // 窗口宽度
111112
height: this.store.get("windowSize.height") || 740, // 窗口高度
112113
minHeight: 700, // 最小高度
@@ -117,7 +118,7 @@ class MainProcess {
117118
titleBarStyle: "customButtonsOnHover", // Macos 隐藏菜单栏
118119
autoHideMenuBar: true, // 失去焦点后自动隐藏菜单栏
119120
// 图标配置
120-
icon: join(__dirname, "../../public/images/logo/favicon.png"),
121+
icon: nativeImage.createFromPath(join(__dirname, "../../public/images/icons/favicon.png")),
121122
// 预加载
122123
webPreferences: {
123124
// devTools: is.dev, //是否开启 DevTools
@@ -133,8 +134,6 @@ class MainProcess {
133134
this.mainWindow.show();
134135
// mainWindow.maximize();
135136
this.store.set("windowSize", this.mainWindow.getBounds());
136-
// 创建系统信息
137-
createSystemInfo(this.mainWindow);
138137
});
139138

140139
// 主窗口事件
@@ -166,6 +165,8 @@ class MainProcess {
166165
configureAutoUpdater();
167166
// 引入主 Ipc
168167
mainIpcMain(this.mainWindow);
168+
// 系统托盘
169+
createSystemTray(this.mainWindow);
169170
// 注册快捷键
170171
createGlobalShortcut(this.mainWindow);
171172
});
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
1-
import { join } from "path";
2-
import { platform } from "@electron-toolkit/utils";
31
import { Tray, Menu, app, ipcMain, nativeImage, nativeTheme } from "electron";
2+
import { join } from "path";
43

5-
// 当前播放歌曲数据
4+
// 当前歌曲数据
65
let playSongName = "当前暂无播放歌曲";
76
let playSongState = false;
87

98
/**
10-
* 创建系统自定义信息
9+
* 创建系统托盘
1110
* @param {BrowserWindow} win - 程序窗口
1211
*/
13-
const createSystemInfo = (win) => {
14-
// 弹出列表
15-
app.setUserTasks([]);
12+
const createSystemTray = (win) => {
1613
// 系统托盘
17-
const mainTray = new Tray(join(__dirname, "../../public/images/logo/favicon.png"));
18-
// 默认托盘菜单
19-
Menu.setApplicationMenu(Menu.buildFromTemplate(createTrayMenu(win)));
20-
// 给托盘图标设置气球提示
14+
const mainTray = new Tray(
15+
nativeImage
16+
.createFromPath(
17+
join(
18+
__dirname,
19+
process.platform === "win32"
20+
? "../../public/images/icons/favicon.ico"
21+
: "../../public/images/icons/favicon-32x32.png",
22+
),
23+
)
24+
.resize({
25+
height: 32,
26+
width: 32,
27+
}),
28+
);
29+
// 应用内菜单
30+
Menu.setApplicationMenu(createTrayMenu(win));
31+
// 默认名称
32+
win.setTitle(app.getName());
33+
mainTray.setTitle(app.getName());
2134
mainTray.setToolTip(app.getName());
22-
// 自定义任务栏缩略图
23-
createThumbar(win);
24-
// 歌曲数据改变时
35+
// 左键事件
36+
mainTray.on("click", () => win.show());
37+
// 托盘菜单
38+
mainTray.setContextMenu(createTrayMenu(win));
39+
// 系统主题改变
40+
nativeTheme.on("updated", () => {
41+
mainTray.setContextMenu(createTrayMenu(win));
42+
});
43+
// 播放歌曲改变
2544
ipcMain.on("songNameChange", (_, val) => {
2645
playSongName = val;
27-
// 托盘图标标题
28-
mainTray.setToolTip(val);
29-
// 更改应用标题
3046
win.setTitle(val);
47+
mainTray.setTitle(val);
48+
mainTray.setToolTip(val);
49+
mainTray.setContextMenu(createTrayMenu(win));
3150
});
51+
// 播放状态改变
3252
ipcMain.on("songStateChange", (_, val) => {
3353
playSongState = val;
34-
createThumbar(win);
35-
});
36-
// 监听系统主题改变
37-
nativeTheme.on("updated", () => {
38-
createThumbar(win);
39-
});
40-
// 左键事件
41-
mainTray.on("click", () => {
42-
// 显示窗口
43-
win.show();
44-
});
45-
// 右键事件
46-
mainTray.on("right-click", () => {
47-
mainTray.popUpContextMenu(Menu.buildFromTemplate(createTrayMenu(win)));
54+
mainTray.setContextMenu(createTrayMenu(win));
4855
});
49-
// linux 右键菜单
50-
if (platform.isLinux) {
51-
mainTray.setContextMenu(Menu.buildFromTemplate(createTrayMenu(win)));
52-
}
5356
};
5457

5558
// 生成图标
@@ -60,16 +63,16 @@ const createIcon = (name) => {
6063
return nativeImage
6164
.createFromPath(
6265
isDarkMode
63-
? join(__dirname, `../../public/images/icon/${name}-dark.png`)
64-
: join(__dirname, `../../public/images/icon/${name}-light.png`),
66+
? join(__dirname, `../../public/images/icons/${name}-dark.png`)
67+
: join(__dirname, `../../public/images/icons/${name}-light.png`),
6568
)
6669
.resize({ width: 16, height: 16 });
6770
};
6871

6972
// 生成右键菜单
7073
const createTrayMenu = (win) => {
7174
// 返回菜单
72-
return [
75+
return Menu.buildFromTemplate([
7376
{
7477
label: playSongName,
7578
icon: createIcon("open"),
@@ -128,35 +131,7 @@ const createTrayMenu = (win) => {
128131
app.quit();
129132
},
130133
},
131-
];
132-
};
133-
134-
// 自定义任务栏缩略图 - Win
135-
const createThumbar = (win) => {
136-
win.setThumbarButtons([]);
137-
win.setThumbarButtons([
138-
{
139-
tooltip: "上一曲",
140-
icon: createIcon("prev"),
141-
click: () => {
142-
win.webContents.send("playNextOrPrev", "prev");
143-
},
144-
},
145-
{
146-
tooltip: playSongState ? "暂停" : "播放",
147-
icon: createIcon(playSongState ? "pause" : "play"),
148-
click() {
149-
win.webContents.send("playOrPause");
150-
},
151-
},
152-
{
153-
tooltip: "下一曲",
154-
icon: createIcon("next"),
155-
click: () => {
156-
win.webContents.send("playNextOrPrev", "next");
157-
},
158-
},
159134
]);
160135
};
161136

162-
export default createSystemInfo;
137+
export default createSystemTray;

index.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33

44
<head>
55
<meta charset="UTF-8" />
6-
<link rel="icon" href="%RENDERER_VITE_SITE_LOGO%" />
7-
<link rel="apple-touch-icon" href="%RENDERER_VITE_SITE_APPLE_LOGO%" />
8-
<link rel="bookmark" href="%RENDERER_VITE_SITE_APPLE_LOGO%" />
9-
<link rel="apple-touch-icon-precomposed" sizes="200x200" href="%RENDERER_VITE_SITE_APPLE_LOGO%" />
6+
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
7+
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
8+
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
109
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1110
<title>%RENDERER_VITE_SITE_TITLE%</title>
1211
<meta name="apple-mobile-web-app-title" content="%RENDERER_VITE_SITE_TITLE%" />
1312
<meta name="author" content="%RENDERER_VITE_SITE_ANTHOR%" />
1413
<meta name="keywords" content="%RENDERER_VITE_SITE_KEYWORDS%" />
1514
<meta name="description" content="%RENDERER_VITE_SITE_DES%" />
15+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
16+
<meta name="msapplication-TileColor" content="#da532c">
1617
<meta name="theme-color" content="#ffffff" />
1718
</head>
1819

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"format": "prettier --write .",
1616
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix",
1717
"start": "electron-vite preview",
18-
"dev": "chcp 65001 && electron-vite dev --watch",
18+
"dev": "electron-vite dev --watch",
1919
"build": "electron-vite build",
2020
"postinstall": "electron-builder install-app-deps",
2121
"build:win": "npm run build && electron-builder --win --config",
11.7 KB
Loading
43.3 KB
Loading
5.85 KB
Loading

public/images/icons/favicon-16x16.png

1.02 KB
Loading
11.7 KB
Loading
File renamed without changes.

public/images/icons/favicon-32x32.png

1.85 KB
Loading
43.3 KB
Loading

public/images/icons/favicon-96x96.png

5.12 KB
Loading

public/images/icons/favicon.ico

14.7 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
6.28 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+25
Loading
File renamed without changes.
File renamed without changes.

public/images/logo/favicon-apple.png

-8.68 KB
Binary file not shown.

public/images/logo/favicon_512.png

-55.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)