xiongzhu 3 vuotta sitten
vanhempi
commit
d66d2df417
3 muutettua tiedostoa jossa 38 lisäystä ja 7 poistoa
  1. 2 1
      config.xml
  2. 30 0
      scripts/android/afterBuild.js
  3. 6 6
      www/index.html

+ 2 - 1
config.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<widget id="vip.raex.nft" version="1.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" ios-CFBundleIdentifier="me.zc.store" ios-CFBundleVersion="199" android-versionCode="1261">
+<widget id="vip.raex.nft" version="1.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" ios-CFBundleIdentifier="me.zc.store" ios-CFBundleVersion="199" android-versionCode="1274">
 	<name>绿洲宇宙</name>
 	<description>
         A sample Apache Cordova application that responds to the deviceready event.
@@ -42,6 +42,7 @@
 		<hook type="after_plugin_install" src="scripts/android/fixNotch.js"/>
 		<hook type="after_prepare" src="scripts/android/leftShift2doLast.js"/>
 		<hook type="after_prepare" src="scripts/android/imageSaver.js"/>
+		<hook type="after_build" src="scripts/android/afterBuild.js"/>
 		<allow-intent href="market:*"/>
 		<allow-intent href="alipays:*"/>
 		<allow-intent href="weixin:*"/>

+ 30 - 0
scripts/android/afterBuild.js

@@ -0,0 +1,30 @@
+const fs = require("fs");
+const path = require("path");
+module.exports = function (context) {
+    const projectRoot = context.opts.projectRoot;
+
+    const cordovaCommon = context.requireCordovaModule("cordova-common");
+    const { ConfigParser } = cordovaCommon;
+    const appConfig = new ConfigParser(path.resolve(projectRoot, "config.xml"));
+
+    if (context.cmdLine.includes("--release")) {
+        let version = appConfig.version();
+        let channel = "default";
+        let match = context.cmdLine.match(/channel=(.+?)(\s|$)/);
+        if (match) {
+            channel = match[1];
+            console.log("channel: " + channel);
+        }
+        const projectRoot = context.opts.projectRoot;
+        fs.copyFileSync(
+            path.resolve(
+                projectRoot,
+                "platforms/android/app/build/outputs/apk/release/app-release.apk"
+            ),
+            path.resolve(
+                projectRoot,
+                `platforms/android/app/build/outputs/apk/channel/app-release-${version}-${channel}.apk`
+            )
+        );
+    }
+};

+ 6 - 6
www/index.html

@@ -28,22 +28,22 @@
 
         var version = '1.0.3';
         var iosCFBundleVersion = '199';
-        var androidVersionCode = '1260';
+        var androidVersionCode = '1273';
         document.addEventListener("online", function () {
-            axios.get('https://www.raex.vip/appVersion/getVersion?version=' + version + '&platform=' + cordova.platformId + '&channel=huawei')
+            axios.get('https://www.raex.vip/appVersion/getVersion?version=' + version + '&platform=' + cordova.platformId + '&channel=qq')
                 .then(function (res) {
                     if (res.data.review) {
                         if ('ios' === cordova.platformId) {
-                            location.href = 'https://ios.raex.vip/9th/?review=true&dateFlag=' + dateFlag + '&channel=huawei';
+                            location.href = 'https://ios.raex.vip/9th/?review=true&dateFlag=' + dateFlag + '&channel=qq';
                         } else {
-                            location.href = 'https://www.raex.vip/9th/?review=true&reviewPay=true&dateFlag=' + dateFlag + '&channel=huawei';
+                            location.href = 'https://www.raex.vip/9th/?review=true&reviewPay=true&dateFlag=' + dateFlag + '&channel=qq';
                         }
                     } else {
-                        location.href = 'https://www.raex.vip/9th/?dateFlag=' + dateFlag + '&channel=huawei';
+                        location.href = 'https://www.raex.vip/9th/?dateFlag=' + dateFlag + '&channel=qq';
                     }
                 })
                 .catch(function (e) {
-                    location.href = 'https://www.raex.vip/9th/?dateFlag=' + dateFlag + '&channel=huawei';
+                    location.href = 'https://www.raex.vip/9th/?dateFlag=' + dateFlag + '&channel=qq';
                 });
         }, false);
     </script>