Skip to content

🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.

feat(icon): 换成毛绒机器人应用图标,按平台生成全套尺寸

dyk98064d1df1d4e3
diff --git a/anymodelbot_design/icon/1024x1024.png b/anymodelbot_design/icon/1024x1024.png
new file mode 100644
index 0000000..7ace9a7
Binary files /dev/null and b/anymodelbot_design/icon/1024x1024.png differ
diff --git a/assets/icon.icns b/assets/icon.icns
new file mode 100644
index 0000000..99b15b8
Binary files /dev/null and b/assets/icon.icns differ
diff --git a/assets/icon.ico b/assets/icon.ico
new file mode 100644
index 0000000..278ec2a
Binary files /dev/null and b/assets/icon.ico differ
diff --git a/assets/icon.png b/assets/icon.png
index b5321c9..15b9163 100644
Binary files a/assets/icon.png and b/assets/icon.png differ
diff --git a/assets/icons/128x128.png b/assets/icons/128x128.png
new file mode 100644
index 0000000..0a0bb6f
Binary files /dev/null and b/assets/icons/128x128.png differ
diff --git a/assets/icons/16x16.png b/assets/icons/16x16.png
new file mode 100644
index 0000000..87243cd
Binary files /dev/null and b/assets/icons/16x16.png differ
diff --git a/assets/icons/24x24.png b/assets/icons/24x24.png
new file mode 100644
index 0000000..2ee6953
Binary files /dev/null and b/assets/icons/24x24.png differ
diff --git a/assets/icons/256x256.png b/assets/icons/256x256.png
new file mode 100644
index 0000000..15b9163
Binary files /dev/null and b/assets/icons/256x256.png differ
diff --git a/assets/icons/32x32.png b/assets/icons/32x32.png
new file mode 100644
index 0000000..f46d7d6
Binary files /dev/null and b/assets/icons/32x32.png differ
diff --git a/assets/icons/48x48.png b/assets/icons/48x48.png
new file mode 100644
index 0000000..071ddd0
Binary files /dev/null and b/assets/icons/48x48.png differ
diff --git a/assets/icons/512x512.png b/assets/icons/512x512.png
new file mode 100644
index 0000000..9295758
Binary files /dev/null and b/assets/icons/512x512.png differ
diff --git a/assets/icons/64x64.png b/assets/icons/64x64.png
new file mode 100644
index 0000000..21be68a
Binary files /dev/null and b/assets/icons/64x64.png differ
diff --git a/assets/tray.png b/assets/tray.png
new file mode 100644
index 0000000..cb98ddb
Binary files /dev/null and b/assets/tray.png differ
diff --git a/assets/[email protected] b/assets/[email protected]
new file mode 100644
index 0000000..0f917a7
Binary files /dev/null and b/assets/[email protected] differ
diff --git a/electron/main.ts b/electron/main.ts
index 47be9bd..b4f3c44 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -27,10 +27,15 @@ let entryUrl = "";
let quitting = false;
let stopped = false;
-function iconPath(): string {
+// 图标由 scripts/build-app-icons.py 生成。Windows 窗口和托盘都用多尺寸 ico,系统按当前缩放挑对应的帧;
+// 其他系统窗口用 icon.png(macOS 忽略,Dock 用包里的 icns),托盘用 18px 的 tray.png,高分屏自动换 [email protected]
+function assetPath(name: string): string {
const root = findAppRoot(path.dirname(fileURLToPath(import.meta.url)));
- return path.join(root, "assets", "icon.png");
+ return path.join(root, "assets", name);
}
+const isWin = process.platform === "win32";
+const windowIconPath = () => assetPath(isWin ? "icon.ico" : "icon.png");
+const trayIconPath = () => assetPath(isWin ? "icon.ico" : "tray.png");
function showWindow(): void {
if (!win) return createWindow();
@@ -49,7 +54,7 @@ function createWindow(): void {
minWidth: 860,
minHeight: 520,
title: PRODUCT,
- icon: iconPath(),
+ icon: windowIconPath(),
show: !SMOKE,
autoHideMenuBar: true,
// macOS:无标题栏,红绿灯嵌进侧栏顶部(界面在 Electron + Mac 下给它留位);其他系统用系统标题栏。
@@ -84,8 +89,8 @@ function createWindow(): void {
}
function buildTray(): void {
- const img = nativeImage.createFromPath(iconPath()).resize({ width: 18, height: 18 });
- tray = new Tray(img);
+ // 不要 resize:会丢掉 ico 的多尺寸帧和 @2x 图,托盘在高分屏上发糊
+ tray = new Tray(nativeImage.createFromPath(trayIconPath()));
tray.setToolTip(PRODUCT);
const render = () =>
tray!.setContextMenu(
@@ -195,6 +200,8 @@ process.on("unhandledRejection", (e) => log.warn(`unhandled rejection: ${(e as E
if (!app.requestSingleInstanceLock()) {
app.quit();
} else {
+ // Windows 的系统通知(设置 › 常规 › 回复完成时通知)要求进程的 AppUserModelID 和安装器建的快捷方式一致(= build.appId)
+ if (process.platform === "win32") app.setAppUserModelId("dev.anymodel.bot");
app.on("second-instance", () => showWindow());
for (const sig of ["SIGINT", "SIGTERM"] as const) process.on(sig, () => app.quit());
app.on("window-all-closed", () => {
diff --git a/package.json b/package.json
index f7151ac..384f215 100644
--- a/package.json
+++ b/package.json
@@ -64,6 +64,8 @@
"dist/**",
"ui/**",
"assets/**",
+ "!assets/icon.icns",
+ "!assets/icons{,/**}",
"package.json",
"!**/*.map",
"LICENSE",
@@ -77,7 +79,7 @@
"asar": true,
"mac": {
"category": "public.app-category.productivity",
- "icon": "assets/icon.png",
+ "icon": "assets/icon.icns",
"target": [
{
"target": "dmg",
@@ -139,7 +141,7 @@
]
},
"win": {
- "icon": "assets/icon.png",
+ "icon": "assets/icon.ico",
"target": [
{
"target": "nsis",
@@ -185,7 +187,7 @@
"allowToChangeInstallationDirectory": true
},
"linux": {
- "icon": "assets/icon.png",
+ "icon": "assets/icons",
"category": "Utility",
"target": [
{
diff --git a/scripts/build-app-icons.py b/scripts/build-app-icons.py
new file mode 100644
index 0000000..33d836e
--- /dev/null
+++ b/scripts/build-app-icons.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python3
+"""
+从 anymodelbot_design/icon/1024x1024.png(满版正方形原图)生成应用在各平台、各尺寸用到的图标。
+
+ assets/icon.icns macOS 打包(electron-builder mac.icon):Apple 网格,1024 画布里 824 的圆角方块 + 轻投影,16–1024 全套
+ assets/icon.ico Windows 打包(win.icon、NSIS 安装包)+ 运行时窗口 / 托盘:16–256,<256 存 32 位 BMP,256 存 PNG
+ assets/icons/<N>x<N>.png Linux 打包(electron-builder linux.icon,AppImage / 桌面菜单):16–512
+ assets/icon.png 运行时窗口图标(Linux;macOS 忽略,Dock 用包里的 icns),256
+ assets/tray.png, tray@2x 托盘(macOS 菜单栏 / Linux),18 / 36,Electron 在高分屏自动换 @2x
+ ui/assets/favicon-*.png 管理界面的浏览器标签图标,32 / 64
+ ui/assets/apple-touch-icon 手机浏览器加到主屏幕,180,满版不透明(iOS 自己切圆角)
+
+只用 Pillow: python3 scripts/build-app-icons.py
+换图标时只替换原图(≥1024 的正方形),重跑脚本,提交生成的文件。
+"""
+import io
+import os
+import struct
+
+from PIL import Image, ImageChops, ImageDraw, ImageFilter
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+SRC = os.path.join(ROOT, "anymodelbot_design", "icon", "1024x1024.png")
+ASSETS = os.path.join(ROOT, "assets")
+UI_ASSETS = os.path.join(ROOT, "ui", "assets")
+
+LANCZOS = Image.Resampling.LANCZOS
+CORNER = 0.225 # 圆角半径 / 方块边长(Apple 824 的方块配 185.4 的圆角)
+
+
+def rounded_mask(n: int, ss: int = 8) -> Image.Image:
+ """n×n 的圆角方块蒙版,放大 ss 倍画再缩回来,边缘抗锯齿。"""
+ big = Image.new("L", (n * ss, n * ss), 0)
+ ImageDraw.Draw(big).rounded_rectangle((0, 0, n * ss - 1, n * ss - 1), radius=CORNER * n * ss, fill=255)
+ return big.resize((n, n), Image.Resampling.BOX)
+
+
+def render(src: Image.Image, size: int, margin: int, shape: bool = True, shadow: bool = False) -> Image.Image:
+ """在 size 画布中央放边长 size-2*margin 的图;shape=False 时保持满版直角(apple-touch-icon)。"""
+ n = size - 2 * margin
+ art = src.resize((n, n), LANCZOS)
+ if n <= 32: # 小尺寸毛绒纹理会糊成一片,轻微锐化让面罩和眼睛更清楚(只动颜色,不动透明度)
+ rgb = art.convert("RGB").filter(ImageFilter.UnsharpMask(radius=1, percent=50, threshold=2))
+ art = Image.merge("RGBA", (*rgb.split(), art.getchannel("A")))
+ if not shape:
+ return art.convert("RGB")
+ mask = rounded_mask(n)
+ art.putalpha(ImageChops.multiply(art.getchannel("A"), mask))
+ out = Image.new("RGBA", (size, size), (0, 0, 0, 0))
+ if shadow: # Apple 模板的投影:向下 ~1%、模糊 ~1%、30% 黑,原图左上角接近白色,靠它在浅色背景上看出轮廓
+ a = Image.new("L", (size, size), 0)
+ a.paste(mask, (margin, margin + round(size * 0.01)))
+ a = a.filter(ImageFilter.GaussianBlur(size * 0.01)).point(lambda v: v * 30 // 100)
+ sh = Image.new("RGBA", (size, size), (0, 0, 0, 0))
+ sh.putalpha(a)
+ out = Image.alpha_composite(out, sh)
+ out.alpha_composite(art, (margin, margin))
+ return out
+
+
+def app_icon(src: Image.Image, size: int) -> Image.Image:
+ """Windows / Linux / 浏览器:几乎满版的圆角方块,四周留约 1/32。"""
+ return render(src, size, round(size / 32))
+
+
+def mac_icon(src: Image.Image, size: int) -> Image.Image:
+ """macOS:Apple 网格(1024 里四周各留 100),64 及以上带投影。"""
+ return render(src, size, size * 100 // 1024, shadow=size >= 64)
+
+
+def png_bytes(im: Image.Image) -> bytes:
+ buf = io.BytesIO()
+ im.save(buf, "PNG", optimize=True)
+ return buf.getvalue()
+
+
+def save_png(im: Image.Image, path: str) -> None:
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ with open(path, "wb") as f:
+ f.write(png_bytes(im))
+
+
+def write_icns(src: Image.Image, path: str) -> None:
+ # 类型 → 像素尺寸;ic11–ic14 是 @2x(16@2x=32 …),和同像素的 1x 共用一张图
+ types = [(b"icp4", 16), (b"icp5", 32), (b"ic11", 32), (b"ic12", 64), (b"ic07", 128), (b"ic13", 256),
+ (b"ic08", 256), (b"ic14", 512), (b"ic09", 512), (b"ic10", 1024)]
+ data = {px: png_bytes(mac_icon(src, px)) for px in sorted({px for _, px in types})}
+ entries = [(t, data[px]) for t, px in types]
+ toc = b"TOC " + struct.pack(">I", 8 + 8 * len(entries)) + b"".join(t + struct.pack(">I", 8 + len(d)) for t, d in entries)
+ body = toc + b"".join(t + struct.pack(">I", 8 + len(d)) + d for t, d in entries)
+ with open(path, "wb") as f:
+ f.write(b"icns" + struct.pack(">I", 8 + len(body)) + body)
+
+
+def ico_bmp(im: Image.Image) -> bytes:
+ """ICO 里的 32 位 BMP 帧:BITMAPINFOHEADER(高度 ×2)+ 自下而上的 BGRA + 1 位 AND 蒙版(全透明处为 1)。"""
+ w, h = im.size
+ xor = im.transpose(Image.Transpose.FLIP_TOP_BOTTOM).tobytes("raw", "BGRA")
+ row = (w + 31) // 32 * 4
+ alpha = im.getchannel("A").transpose(Image.Transpose.FLIP_TOP_BOTTOM).tobytes()
+ mask = bytearray(row * h)
+ for y in range(h):
+ for x in range(w):
+ if alpha[y * w + x] == 0:
+ mask[y * row + x // 8] |= 0x80 >> (x % 8)
+ header = struct.pack("<IiiHHIIiiII", 40, w, h * 2, 1, 32, 0, len(xor) + len(mask), 0, 0, 0, 0)
+ return header + xor + bytes(mask)
+
+
+def write_ico(src: Image.Image, path: str) -> None:
+ sizes = [16, 20, 24, 32, 40, 48, 64, 96, 128, 256] # 100%–200% 缩放下任务栏、标题栏、资源管理器各视图用到的尺寸
+ frames = [(s, png_bytes(app_icon(src, s)) if s >= 256 else ico_bmp(app_icon(src, s))) for s in sizes]
+ offset = 6 + 16 * len(frames)
+ head = struct.pack("<HHH", 0, 1, len(frames))
+ for s, d in frames:
+ head += struct.pack("<BBBBHHII", s % 256, s % 256, 0, 0, 1, 32, len(d), offset)
+ offset += len(d)
+ with open(path, "wb") as f:
+ f.write(head + b"".join(d for _, d in frames))
+
+
+def main() -> None:
+ src = Image.open(SRC).convert("RGBA")
+ if src.width != src.height or src.width < 1024:
+ raise SystemExit(f"原图需要是 ≥1024 的正方形:{SRC} 是 {src.width}×{src.height}")
+ if src.width != 1024:
+ src = src.resize((1024, 1024), LANCZOS)
+
+ write_icns(src, os.path.join(ASSETS, "icon.icns"))
+ write_ico(src, os.path.join(ASSETS, "icon.ico"))
+ for s in [16, 24, 32, 48, 64, 128, 256, 512]:
+ save_png(app_icon(src, s), os.path.join(ASSETS, "icons", f"{s}x{s}.png"))
+ save_png(app_icon(src, 256), os.path.join(ASSETS, "icon.png"))
+ # 托盘:菜单栏 18pt 高,图形占 16pt(四周各留 1pt)
+ save_png(render(src, 18, 1), os.path.join(ASSETS, "tray.png"))
+ save_png(render(src, 36, 2), os.path.join(ASSETS, "[email protected]"))
+ save_png(app_icon(src, 32), os.path.join(UI_ASSETS, "favicon-32.png"))
+ save_png(app_icon(src, 64), os.path.join(UI_ASSETS, "favicon-64.png"))
+ save_png(render(src, 180, 0, shape=False), os.path.join(UI_ASSETS, "apple-touch-icon.png"))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/ui/assets/apple-touch-icon.png b/ui/assets/apple-touch-icon.png
new file mode 100644
index 0000000..bec341a
Binary files /dev/null and b/ui/assets/apple-touch-icon.png differ
diff --git a/ui/assets/favicon-32.png b/ui/assets/favicon-32.png
new file mode 100644
index 0000000..f46d7d6
Binary files /dev/null and b/ui/assets/favicon-32.png differ
diff --git a/ui/assets/favicon-64.png b/ui/assets/favicon-64.png
new file mode 100644
index 0000000..21be68a
Binary files /dev/null and b/ui/assets/favicon-64.png differ
diff --git a/ui/index.html b/ui/index.html
index d8f7874..ed036ec 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -4,7 +4,9 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AnyModelBot</title>
- <link rel="icon" href="data:," />
+ <link rel="icon" href="/amb/static/assets/favicon-32.png" sizes="32x32" type="image/png" />
+ <link rel="icon" href="/amb/static/assets/favicon-64.png" sizes="64x64" type="image/png" />
+ <link rel="apple-touch-icon" href="/amb/static/assets/apple-touch-icon.png" />
<script>
// 首帧前解析主题(data-theme 总是 light/dark,CSS 只定义一份深色变量)与平台
(function () {