Skip to content

Commit c3e23ca

Browse files
committed
v0.1.0 Electron重构
1 parent 3902b01 commit c3e23ca

18 files changed

+5045
-619
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.js text eol=lf
3+
*.json text eol=lf

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 忽略依赖
2+
node_modules/
3+
4+
# 忽略打包生成的文件
5+
dist/
6+
build/
7+
8+
# 忽略日志文件
9+
*.log
10+
11+
# 忽略操作系统相关文件
12+
.DS_Store
13+
Thumbs.db
14+
15+
# 忽略环境变量配置
16+
.env

Music-APIs.json

Lines changed: 0 additions & 304 deletions
This file was deleted.

icons/NB Music.png

164 KB
Loading

icons/converter.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from PIL import Image
2+
import os
3+
4+
def create_icons(png_path, output_dir):
5+
# 检查输入的 PNG 文件是否存在
6+
if not os.path.isfile(png_path):
7+
raise FileNotFoundError("输入的 PNG 文件不存在!")
8+
9+
# 确保输出目录存在
10+
os.makedirs(output_dir, exist_ok=True)
11+
12+
# 加载 PNG 图片
13+
img = Image.open(png_path)
14+
img = img.convert("RGBA") # 确保有 alpha 通道
15+
16+
# 生成 Windows 的 .ico 文件
17+
ico_path = os.path.join(output_dir, "icon.ico")
18+
img.save(ico_path, format="ICO", sizes=[(256, 256), (128, 128), (64, 64), (32, 32), (16, 16)])
19+
print(f"生成 Windows 图标: {ico_path}")
20+
21+
# 生成 macOS 的 .icns 文件
22+
icns_path = os.path.join(output_dir, "icon.icns")
23+
img.save(icns_path, format="ICNS")
24+
print(f"生成 macOS 图标: {icns_path}")
25+
26+
# 生成 Linux 的多尺寸 PNG 图标
27+
sizes = [512, 256, 128, 64, 32, 16]
28+
for size in sizes:
29+
resized_img = img.resize((size, size), Image.Resampling.LANCZOS) # 使用 LANCZOS 代替 ANTIALIAS
30+
png_path = os.path.join(output_dir, f"icon_{size}x{size}.png")
31+
resized_img.save(png_path, format="PNG")
32+
print(f"生成 {size}x{size} PNG 图标: {png_path}")
33+
34+
if __name__ == "__main__":
35+
input_png = "NB Music.png" # 替换为你的 PNG 文件路径
36+
output_directory = "./" # 替换为你想保存图标的输出目录
37+
38+
try:
39+
create_icons(input_png, output_directory)
40+
except Exception as e:
41+
print(f"发生错误: {e}")

icons/icon.icns

569 KB
Binary file not shown.

icons/icon.ico

59.2 KB
Binary file not shown.

icons/icon.png

164 KB
Loading

0 commit comments

Comments
 (0)