就图标而言,Cordova是所有构建目标中最复杂的目标之一,因为您不仅需要将图标放在特定文件夹中,还需要在src-cordova/config.xml
文件中注册它们。 此外,如果您正在使用启动画面(您应该使用),您还需要安装cordova-plugin-splashscreen
并在config.xml中注册它。
如果您发现一个新的或丢失的文件,请打开问题。
Icon Genie CLI
TIP
我们强烈建议您使用Icon Genie CLI,因为它使用一个源图标并自动克隆、缩放、缩小图标并将其放置在适当的目录中。当需要时,它还会告诉您需要向/src/index.template.html文件添加哪些标记。
使用Icon Genie CLI快速启动必要的图像。有关选项的完整列表,请访问Icon Genie CLI命令列表页面。
$ icongenie generate -m capacitor -i /path/to/source/icon.png [-b /path/to/background.png]
手动指引
除非您使用的是Icon Genie应用扩展,否则您需要执行以下操作:
$ cd src-cordova
$ cordova plugin add cordova-plugin-splashscreen
$ cordova plugin save
$ cd ..
src-cordova/
config.xml
res/
android/
icon-36-ldpi.png
icon-48-mdpi.png
icon-72-hdpi.png
icon-96-xhdpi.png
icon-144-xxhdpi.png
icon-192-xxxhdpi.png
ios/
icon.png
icon-2x.png
icon-40.png
icon-40-2x.png
icon-50.png
icon-50-2x.png
icon-60.png
icon-60-2x.png
icon-60-3x.png
icon-72.png
icon-72-2x.png
icon-83.5-2x.png
icon-167.png
icon-1024.png
screen/
android/
screen-hdpi-landscape.png
screen-ldpi-portrait.png
screen-mdpi-landscape.png
screen-mdpi-portrait.png
screen-hdpi-landscape.png
screen-hdpi-portrait.png
screen-xhdpi-landscape.png
screen-xhdpi-portrait.png
screen-xxhdpi-landscape.png
screen-xxhdpi-portrait.png
screen-xxxhdpi-landscape.png
screen-xxxhdpi-portrait.png
ios/
screen-ipad-landscape.png
screen-ipad-landscape-2x.png
screen-ipad-portrait.png
screen-ipad-portrait-2x.png
screen-iphone-portrait.png
screen-iphone-portrait-2x.png
screen-iphone-landscape.png
screen-iphone-landscape-2x.png
screen-iphone-portrait-568h_2x.png
Default@2x~universal~anyany.png
你的config.xml应该是这样的:
<platform name="android">
<icon density="ldpi" src="res/android/icon-36-ldpi.png" />
<icon density="mdpi" src="res/android/icon-48-mdpi.png" />
<icon density="hdpi" src="res/android/icon-72-hdpi.png" />
<icon density="xhdpi" src="res/android/icon-96-xhdpi.png" />
<icon density="xxhdpi" src="res/android/icon-144-xxhdpi.png" />
<icon density="xxxhdpi" src="res/android/icon-192-xxxhdpi.png" />
<splash density="land-ldpi" src="res/screen/android/screen-ldpi-landscape.png" />
<splash density="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
<splash density="land-mdpi" src="res/screen/android/screen-mdpi-landscape.png" />
<splash density="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
<splash density="land-hdpi" src="res/screen/android/screen-hdpi-landscape.png" />
<splash density="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
<splash density="land-xhdpi" src="res/screen/android/screen-xhdpi-landscape.png" />
<splash density="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
<splash density="land-xxhdpi" src="res/screen/android/screen-xxhdpi-landscape.png" />
<splash density="port-xxhdpi" src="res/screen/android/screen-xxhdpi-portrait.png" />
<splash density="land-xxxhdpi" src="res/screen/android/screen-xxxhdpi-landscape.png" />
<splash density="port-xxxhdpi" src="res/screen/android/screen-xxxhdpi-portrait.png" />
</platform>
<platform name="ios">
<icon height="57" src="res/ios/icon.png" width="57" />
<icon height="114" src="res/ios/icon-2x.png" width="114" />
<icon height="40" src="res/ios/icon-40.png" width="40" />
<icon height="80" src="res/ios/icon-40-2x.png" width="80" />
<icon height="50" src="res/ios/icon-50.png" width="50" />
<icon height="100" src="res/ios/icon-50-2x.png" width="100" />
<icon height="60" src="res/ios/icon-60.png" width="60" />
<icon height="120" src="res/ios/icon-60-2x.png" width="120" />
<icon height="180" src="res/ios/icon-60-3x.png" width="180" />
<icon height="72" src="res/ios/icon-72.png" width="72" />
<icon height="144" src="res/ios/icon-72-2x.png" width="144" />
<icon height="167" src="res/ios/icon-83.5-2x.png" width="167" />
<icon height="167" src="res/ios/icon-167.png" width="167" />
<icon height="1024" src="res/ios/icon-1024.png" width="1024" />
<splash height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
<splash height="1536" src="res/screen/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
<splash height="2048" src="res/screen/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash height="320" src="res/screen/ios/screen-iphone-landscape.png" width="480" />
<splash height="640" src="res/screen/ios/screen-iphone-landscape-2x.png" width="960" />
<splash height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
<splash height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<splash height="1136" src="res/screen/ios/screen-iphone-portrait-568h_2x.png" width="640" />
<splash height="2732" src="res/screen/ios/Default@2x~universal~anyany.png" width="2732" />
</platform>
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />