diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 661452ba..c6b68d1b 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -3,7 +3,8 @@ "name": "EdgeEver", "slug": "edgeever", "scheme": "edgeever", - "version": "0.4.6", + "version": "0.4.7", + "icon": "./assets/icon.png", "orientation": "portrait", "userInterfaceStyle": "light", "newArchEnabled": true, @@ -13,9 +14,10 @@ }, "android": { "package": "org.edgeever.mobile", - "versionCode": 12, + "versionCode": 13, "adaptiveIcon": { - "backgroundColor": "#f8fafc" + "backgroundColor": "#d1fae5", + "foregroundImage": "./assets/adaptive-icon-foreground.png" } }, "plugins": [ diff --git a/apps/mobile/assets/adaptive-icon-foreground.png b/apps/mobile/assets/adaptive-icon-foreground.png new file mode 100644 index 00000000..8ec4721f Binary files /dev/null and b/apps/mobile/assets/adaptive-icon-foreground.png differ diff --git a/apps/mobile/assets/adaptive-icon-foreground.svg b/apps/mobile/assets/adaptive-icon-foreground.svg new file mode 100644 index 00000000..b5f65732 --- /dev/null +++ b/apps/mobile/assets/adaptive-icon-foreground.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/mobile/assets/icon.png b/apps/mobile/assets/icon.png new file mode 100644 index 00000000..0df61e2b Binary files /dev/null and b/apps/mobile/assets/icon.png differ diff --git a/apps/mobile/package.json b/apps/mobile/package.json index ba682f76..1347fb66 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -1,6 +1,6 @@ { "name": "@edgeever/mobile", - "version": "0.4.6", + "version": "0.4.7", "private": true, "type": "module", "main": "expo-router/entry", diff --git a/package.json b/package.json index c61d12a0..28e1ff6d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dev:api:remote": "bun scripts/run-wrangler.mjs dev --remote --port 8787", "dev:web": "vite --config apps/web/vite.config.ts --host 127.0.0.1 --port 5173", "dev:mobile": "bun --cwd apps/mobile expo start", + "prepare:mobile:icons": "bun scripts/prepare-mobile-icons.mjs", "build:android:fast": "bash scripts/build-android-local.sh fast", "build:android:play": "bash scripts/build-android-local.sh play", "build:android:play:local": "bun --env-file=${EDGE_EVER_ANDROID_ENV_FILE:-$HOME/.config/edgeever/android/signing.env} run build:android:play", diff --git a/scripts/build-android-local.sh b/scripts/build-android-local.sh index 0836aff2..e9f726e5 100755 --- a/scripts/build-android-local.sh +++ b/scripts/build-android-local.sh @@ -38,8 +38,15 @@ fi cd "$PROJECT_ROOT" bun install --frozen-lockfile +bun run prepare:mobile:icons -PREBUILD_FINGERPRINT="$({ shasum apps/mobile/app.json bun.lock; } | shasum | awk '{print $1}')" +PREBUILD_FINGERPRINT="$({ + shasum \ + apps/mobile/app.json \ + apps/mobile/assets/adaptive-icon-foreground.svg \ + apps/web/public/pwa-512x512.png \ + bun.lock +} | shasum | awk '{print $1}')" PREBUILD_STAMP="$ANDROID_DIR/.edgeever-prebuild-fingerprint" PREVIOUS_FINGERPRINT="$(test -f "$PREBUILD_STAMP" && cat "$PREBUILD_STAMP" || true)" diff --git a/scripts/prepare-mobile-icons.mjs b/scripts/prepare-mobile-icons.mjs new file mode 100644 index 00000000..54ad0934 --- /dev/null +++ b/scripts/prepare-mobile-icons.mjs @@ -0,0 +1,20 @@ +import { copyFile, mkdir } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import sharp from "sharp"; + +const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const mobileAssetsDir = path.join(projectRoot, "apps/mobile/assets"); +const sharedIconPath = path.join(projectRoot, "apps/web/public/pwa-512x512.png"); +const mobileIconPath = path.join(mobileAssetsDir, "icon.png"); +const adaptiveIconSourcePath = path.join(mobileAssetsDir, "adaptive-icon-foreground.svg"); +const adaptiveIconPath = path.join(mobileAssetsDir, "adaptive-icon-foreground.png"); + +await mkdir(mobileAssetsDir, { recursive: true }); +await copyFile(sharedIconPath, mobileIconPath); +await sharp(adaptiveIconSourcePath, { density: 384 }) + .resize(1024, 1024) + .png() + .toFile(adaptiveIconPath); + +console.log("已同步 Android 图标资源");