fix(android): release 包用回 HG 图标(gen/ 不入库导致)
根因:src-tauri/gen/ 在 .gitignore 里,CI 每次干净 checkout 后都会 `tauri android init`,而 init 只写模板自带的默认图标(青黄「8」), 不读 src-tauri/icons/android/;本地因为早先手动拷过一次 res/ 才看着正常。 实测干净 init 后 mipmap-xxxhdpi/ic_launcher_foreground.png 是 40510B 的 Tauri logo,且没有 mipmap-anydpi-v26/ 与 values/ic_launcher_background.xml。 - 新增 scripts/sync-android-icons.mjs:icons/android → gen/android res - 挂进 tauri.conf.json 的 beforeBuildCommand(pnpm build && node ...), CI 的 `tauri android build` 与本地构建都会自动同步 - package.json 加 android:icons 手动入口
This commit is contained in:
+2
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "huangguo-client",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -11,6 +11,7 @@
|
||||
"app:dev": "tauri dev",
|
||||
"app:build": "tauri build",
|
||||
"android:init": "tauri android init",
|
||||
"android:icons": "node scripts/sync-android-icons.mjs",
|
||||
"android:dev": "tauri android dev",
|
||||
"android:build": "tauri android build"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 把仓库里跟踪的安卓图标同步进生成的 Android 工程。
|
||||
*
|
||||
* 为什么需要:
|
||||
* `src-tauri/gen/` 不入库,CI 和换机器都会重新 `tauri android init`,
|
||||
* 而 init 只会写 Tauri 模板自带的默认图标(那个青黄「8」),**不会**读
|
||||
* `src-tauri/icons/android/`。于是本地手动拷过图标的人看着正常,
|
||||
* CI 打出来的包却是默认图标 —— 典型的「works on my machine」。
|
||||
*
|
||||
* 用法:
|
||||
* node scripts/sync-android-icons.mjs
|
||||
* (tauri.conf.json 的 beforeBuildCommand 已自动调用,一般不用手动跑)
|
||||
*/
|
||||
import { cpSync, existsSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const src = join(root, "src-tauri", "icons", "android");
|
||||
const dest = join(root, "src-tauri", "gen", "android", "app", "src", "main", "res");
|
||||
|
||||
if (!existsSync(src)) {
|
||||
console.log(`[icons] 跳过:缺少 ${src}`);
|
||||
process.exit(0);
|
||||
}
|
||||
if (!existsSync(dest)) {
|
||||
console.log("[icons] 跳过:gen/android 还没生成(先跑 tauri android init)");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
cpSync(src, dest, { recursive: true, force: true });
|
||||
console.log(`[icons] 安卓图标已同步 → ${dest}`);
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "HGhub",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"identifier": "com.hghub.huangguo",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
"beforeBuildCommand": "pnpm build && node scripts/sync-android-icons.mjs",
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
|
||||
Reference in New Issue
Block a user