fix: 打包应用图标补齐常规尺寸,解决菜单栏图标不显示问题

之前只装了 hicolor/1024x1024 一个尺寸,UKUI 等桌面菜单按 48x48 等
常规尺寸查找图标时找不到,直接回退成缺省图标而不会从 1024 缩放。
现在按 16/24/32/48/64/128/256/512/1024 全部装进 hicolor 主题,并
额外在 /usr/share/pixmaps 放一份 48x48,兼容不认图标主题的老式菜单。

resources/icons/ 下是从 resources/icon.png 用 sips 预生成的各尺寸
PNG,随图标一起更新即可,不需要在打包时现场依赖 ImageMagick。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ssurui 2026-08-22 12:16:13 +08:00
parent 598922dd16
commit 1cb953eeb3
9 changed files with 13 additions and 2 deletions

BIN
resources/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
resources/icons/16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
resources/icons/24x24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
resources/icons/256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
resources/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
resources/icons/48x48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
resources/icons/512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

BIN
resources/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -62,14 +62,25 @@ mkdir -p "$STAGING/DEBIAN" \
"$STAGING/opt/$PRODUCT_NAME" \ "$STAGING/opt/$PRODUCT_NAME" \
"$STAGING/usr/bin" \ "$STAGING/usr/bin" \
"$STAGING/usr/share/applications" \ "$STAGING/usr/share/applications" \
"$STAGING/usr/share/icons/hicolor/1024x1024/apps" "$STAGING/usr/share/pixmaps"
cp -a "$APP_DIR/." "$STAGING/opt/$PRODUCT_NAME/" cp -a "$APP_DIR/." "$STAGING/opt/$PRODUCT_NAME/"
# chrome-sandbox 必须是 setuid root,否则 Electron 沙箱初始化失败, # chrome-sandbox 必须是 setuid root,否则 Electron 沙箱初始化失败,
# 启动即崩溃报 "Failed sending zygote boot message: 断开的管道" # 启动即崩溃报 "Failed sending zygote boot message: 断开的管道"
chmod 4755 "$STAGING/opt/$PRODUCT_NAME/chrome-sandbox" chmod 4755 "$STAGING/opt/$PRODUCT_NAME/chrome-sandbox"
cp resources/icon.png "$STAGING/usr/share/icons/hicolor/1024x1024/apps/$PKG_NAME.png" # 只装 1024x1024 会导致部分桌面菜单(如 UKUI)在按常规尺寸(48x48 等)查找图标时
# 找不到、直接回退成缺省图标,而不是从 1024 缩放——所以要把常规尺寸全部装齐
for size in 16 24 32 48 64 128 256 512 1024; do
mkdir -p "$STAGING/usr/share/icons/hicolor/${size}x${size}/apps"
if [ "$size" = "1024" ]; then
cp resources/icon.png "$STAGING/usr/share/icons/hicolor/1024x1024/apps/$PKG_NAME.png"
else
cp "resources/icons/${size}x${size}.png" "$STAGING/usr/share/icons/hicolor/${size}x${size}/apps/$PKG_NAME.png"
fi
done
# 兼容不认 icon 主题、直接读 pixmaps 的老式菜单实现
cp resources/icons/48x48.png "$STAGING/usr/share/pixmaps/$PKG_NAME.png"
cat > "$STAGING/usr/share/applications/$PKG_NAME.desktop" <<EOF cat > "$STAGING/usr/share/applications/$PKG_NAME.desktop" <<EOF
[Desktop Entry] [Desktop Entry]