You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
65 lines
2.0 KiB
#!/usr/bin/env bash
|
|
# 装 dsh-launcher.app 到 /Applications/,并强制刷新 macOS 图标。
|
|
#
|
|
# 背景: macOS LaunchServices 会把 com.wails.dsh-launcher 的图标缓存成
|
|
# 当前 app 文件的快照。每次 wails build 之后 .app 内容重建,缓存可能不刷新,
|
|
# 导致 Dock 显示默认 .app 占位图而不是真实 icns。
|
|
#
|
|
# 解决: 把 .app 复制到一个稳定路径(/Applications/),重建时先 rm 再 cp,
|
|
# lsregister -f 强制重新注册。
|
|
#
|
|
# 用法: ./scripts/install-app.sh
|
|
|
|
set -euo pipefail
|
|
|
|
APP_NAME="dsh-launcher.app"
|
|
SRC="build/bin/${APP_NAME}"
|
|
DEST="/Applications/${APP_NAME}"
|
|
|
|
if [[ ! -d "${SRC}" ]]; then
|
|
echo "✗ ${SRC} not found, run 'wails build' first"
|
|
exit 1
|
|
fi
|
|
|
|
# 1. 验证 icns 文件是新图
|
|
if [[ ! -f "${SRC}/Contents/Resources/iconfile.icns" ]]; then
|
|
echo "✗ iconfile.icns missing — icon wasn't packaged"
|
|
exit 1
|
|
fi
|
|
ICON_SIZE=$(stat -f%z "${SRC}/Contents/Resources/iconfile.icns")
|
|
if [[ ${ICON_SIZE} -lt 100000 ]]; then
|
|
echo "⚠ iconfile.icns suspiciously small (${ICON_SIZE} bytes)"
|
|
fi
|
|
echo "✓ iconfile.icns: ${ICON_SIZE} bytes"
|
|
|
|
# 2. 删除旧版(让 lsregister 看到全新路径)
|
|
if [[ -d "${DEST}" ]]; then
|
|
rm -rf "${DEST}"
|
|
fi
|
|
|
|
# 3. 复制到 /Applications
|
|
cp -R "${SRC}" "${DEST}"
|
|
echo "✓ copied to ${DEST}"
|
|
|
|
# 4. 强制重新注册到 LaunchServices
|
|
LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
|
|
"${LSREGISTER}" -f "${DEST}"
|
|
|
|
# 5. touch 一下让文件 mtime 更新
|
|
/usr/bin/touch -c "${DEST}/Contents/Info.plist"
|
|
/usr/bin/touch -c "${DEST}/Contents/Resources/iconfile.icns"
|
|
|
|
# 6. 清 Dock iconcache
|
|
DOCK_CACHE=$(find /var/folders -name "com.apple.dock.iconcache" 2>/dev/null | head -1)
|
|
if [[ -n "${DOCK_CACHE}" ]]; then
|
|
rm -f "${DOCK_CACHE}"
|
|
echo "✓ cleared dock iconcache"
|
|
fi
|
|
|
|
# 7. 重启 Dock 强制重读
|
|
killall Dock 2>/dev/null || true
|
|
sleep 1
|
|
|
|
echo ""
|
|
echo "✓ ${APP_NAME} installed at ${DEST}"
|
|
echo " open it via Finder / Spotlight / Dock (re-add to Dock if needed)" |