zoukankan      html  css  js  c++  java
  • ionic2性能提高方法记录

    1、问题:启动后短暂白屏。

       解决方法:

        (1)隐藏白屏。

              工程目录下config.xml添加以下:

    <preference name="SplashMaintainAspectRatio" value="true"/>
      <preference name="SplashScreen" value="screen"/>
      <preference name="SplashScreenDelay" value="30000"/>
      <preference name="AutoHideSplashScreen" value="false"/>
      <preference name="SplashShowOnlyFirstTime" value="false"/>
      <preference name="FadeSplashScreen" value="false"/>
    
    <feature name="SplashScreen">
            <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
        </feature>

            我这里的app.component.ts默认如下:

    export class MyApp {
      rootPage = TabsPage;
    
      constructor(platform: Platform) {
        platform.ready().then(() => {
          // Okay, so the platform is ready and our plugins are available.
          // Here you can do any higher level native things you might need.
          StatusBar.styleDefault();
          Splashscreen.hide();      //隐藏白屏
        });
      }
    }

         所以不需要再修改。

        (2)加载其他图片

          在index.html加载图片,如:

    <div class="appSplash">
    <div style="font-size: 30px;text-align: center">这里可以放广告图片</div>
    <img src="./assets/img/qr_code.png" alt=""
    </div>

    参考链接:http://www.jianshu.com/p/102bd23625cb

    2、去除启动时转的圈圈:config.xml加上<preference name="ShowSplashScreenSpinner" value="false"/>

    3、问题:APP启动过慢。

         解决方法:打包apk时,加上--prod

         以下是本人的粗略测试:

      红米4X DEVICE READY FIRED AFTER
    debug 10.4s 6559ms
    debug+prod 4.6s 1522ms

    release版本和debug时间差不多。

    4.打包apk时自动签名

       (1)生成签名文件:

              方法1:利用Android Studio生成。参考:http://www.jianshu.com/p/dfd98ad47af1

              方法2:利用jdk的KeyTool生成。

                        命令行:keytool -genkey -v -keystore appDemo.jks -alias test  -keyalg RSA -keysize 2048 -validity 10000

                                  appDemo和test自命名,如图:

                     注:确认信息是否有误时,要输入“是”/“否”。

                可发现目录下有appDemo.jks文件生成。

        (2)自动签名设置:

               工程目录/platforms/android目录新建名为release-signing.properties的文件,内容如下:

    storeFile=path to keystore
    keyAlias=your key alias
    storePassword=your store password
    keyPassword=you key password

                storeFile为appDemo.jks的路径,且windows下路径应使用Unix下的目录分隔符/。

          (3)打包时加上--release即可生成有签名的apk。

               

       

  • 相关阅读:
    《第一行代码》阅读笔记(三十一)——多线程
    《第一行代码》阅读笔记(三十)——MVP(补充)
    《第一行代码》阅读笔记(二十九)——网络框架 OkHttp+Retrofit+Rxjava
    《第一行代码》阅读笔记(二十八)——网络技术(OkHttp+JSON/GSON)
    sql server优化查询速度(子查询)
    sql server 查询字段是否为数字
    Git操作汇总
    解决github下载过慢方式
    InnoDB存储引擎简介
    MySQL主从复制详解
  • 原文地址:https://www.cnblogs.com/momoxiaoqing/p/6812506.html
Copyright © 2011-2022 走看看