Uniapp 怎么修改项目图标和启动页

一、修改项目图标
  1. 图标文件准备

    • 准备 1024×1024 像素的 PNG 格式主图标
    • 不同平台有特殊要求:
      • iOS:需 20×20 至 1024×1024 多种尺寸
      • Android:需 48×48/72×72/96×96 等尺寸
  2. 配置 manifest.json
    "app-plus" → "distribute" → "icons" 节点配置:

"icons": {
  "android": {
    "mdpi": "static/icon-48.png",
    "hdpi": "static/icon-72.png",
    "xhdpi": "static/icon-96.png"
  },
  "ios": {
    "appstore": "static/icon-1024.png",
    "iphone": {
      "2x": "static/icon-120.png",
      "3x": "static/icon-180.png"
    }
  }
}

二、修改启动页
  1. 启动页文件准备

    • 推荐尺寸:1242×2208 像素(iOS)/ 1080×1920 像素(Android)
    • 格式要求:PNG 或 JPG
  2. 配置 manifest.json
    "app-plus" → "splashscreen" 节点配置:

"splashscreen": {
  "autoclose": true,
  "waiting": true,
  "target": "splash",
  "ios": {
    "image": "static/splash-ios.png"
  },
  "android": {
    "image": "static/splash-android.png"
  }
}

三、manifest.json 配置详解
{
  "name": "应用名称",
  "appid": "唯一应用标识",
  "description": "应用描述",
  
  /* 基础配置 */
  "versionName": "1.0.0",
  "versionCode": "100",
  
  /* 图标配置 */
  "icons": { ... }, // 见上文配置
  
  /* 启动页配置 */
  "splashscreen": { ... }, // 见上文配置
  
  /* 模块配置 */
  "modules": {
    "Payment": {}, // 支付模块
    "Push": {}    // 推送模块
  },
  
  /* 平台特定配置 */
  "app-plus": {
    "distribute": {
      "android": {
        "packagename": "com.example.app"
      },
      "ios": {
        "bundleidentifier": "com.example.app"
      }
    }
  },
  
  /* H5 配置 */
  "h5": {
    "router": {
      "mode": "history"
    }
  },
  
  /* 权限配置 */
  "permissions": [
    "android.permission.INTERNET",
    "ios.permission.CAMERA"
  ]
}

四、关键配置说明
  1. 图标尺寸要求

    • Android 需提供 5 种分辨率图标
    • iOS 需提供 10 种分辨率图标
    • 可使用 图标生成工具 自动生成
  2. 启动页高级配置

"splashscreen": {
  "delay": 0, // 启动页延迟关闭时间(毫秒)
  "backgroundColor": "#FFFFFF", // 背景色
  "landscape": true // 是否支持横屏
}

  1. 生效流程
    graph LR
    A[准备图标/启动图] --> B[配置manifest.json]
    B --> C[执行发行操作]
    C --> D[生成新安装包]
    

五、常见问题解决
  1. 图标不更新

    • 删除 unpackage 目录后重新编译
    • 检查文件路径是否正确
  2. 启动页显示异常

    • 确保图片尺寸符合要求
    • 检查 autoclosewaiting 参数配置
  3. 多平台适配

    • 使用条件编译:
// #ifdef APP-PLUS
"platform": "特定配置"
// #endif

最佳实践

  1. 使用 HBuilderX 的「原生App-云打包」测试效果
  2. 每次修改后执行「清理项目」操作
  3. 复杂项目推荐使用 自定义启动页插件 实现动态控制
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值