From b2f124f457783d46a9dd9d157db5040f62d1579c Mon Sep 17 00:00:00 2001
From: liujiangnan <695541723@qq.com>
Date: Thu, 25 Nov 2021 18:40:23 +0800
Subject: [PATCH] docs:

---
 README.md                                     |  2 +-
 assets/cocos_generator.meta                   | 16 +------
 .../script/MyCocosSceneComponent.ts           |  2 +-
 bin/buildCocos.js                             | 45 +++++++++++++------
 4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/README.md b/README.md
index 750cdf2..62fbd90 100644
--- a/README.md
+++ b/README.md
@@ -81,4 +81,4 @@ npm start
 
 * 手机和电脑连接同一个Wifi
 * 打开调试app,根据提示输入IP地址,点击开始就可以在手机上预览模板了
-* 
\ No newline at end of file
+* 使用 this.log("==调试信息=="); 可以打印日志进行必要的调试
\ No newline at end of file
diff --git a/assets/cocos_generator.meta b/assets/cocos_generator.meta
index 0b430b3..35bb685 100644
--- a/assets/cocos_generator.meta
+++ b/assets/cocos_generator.meta
@@ -1,15 +1 @@
-{
-  "ver": "1.1.2",
-  "uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
-  "isBundle": false,
-  "bundleName": "",
-  "priority": 1,
-  "compressionType": {},
-  "optimizeHotUpdate": {},
-  "inlineSpriteFrames": {},
-  "isRemoteBundle": {
-    "ios": false,
-    "android": false
-  },
-  "subMetas": {}
-}
\ No newline at end of file
+{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
diff --git a/assets/cocos_generator/script/MyCocosSceneComponent.ts b/assets/cocos_generator/script/MyCocosSceneComponent.ts
index 69bd3c4..85b380d 100644
--- a/assets/cocos_generator/script/MyCocosSceneComponent.ts
+++ b/assets/cocos_generator/script/MyCocosSceneComponent.ts
@@ -126,7 +126,7 @@ export class MyCocosSceneComponent extends cc.Component {
   log (str) {
     const node = cc.find('middleLayer');
     if(node){
-      node.getComponent('middleLayer').showLog(str);
+      node.getComponent('middleLayer').log(str);
     }else{
       cc.log(str);
     }
diff --git a/bin/buildCocos.js b/bin/buildCocos.js
index 7ae80bc..1eb56fc 100644
--- a/bin/buildCocos.js
+++ b/bin/buildCocos.js
@@ -128,15 +128,28 @@ async function buildWebBundle() {
   await buildCocos(args);
 }
 
-function createConfigFile (projectName) {
-  const androidPaths = fs.readdirSync(`dist/android/${projectName}`);
-  const androidConfigFileName = androidPaths.find(path => path.indexOf('config') == 0);
-  const androidVersion = androidConfigFileName.split('.')[1];
-
-  const iosPaths = fs.readdirSync(`dist/ios/${projectName}`);
-  const iosConfigFileName = iosPaths.find(path => path.indexOf('config') == 0);
-  const iosVersion = iosConfigFileName.split('.')[1];
-
+function createConfigFile (projectName, type) {
+  let iosVersion = "";
+  let androidVersion = "";
+  if(!type){
+    const androidPaths = fs.readdirSync(`dist/android/${projectName}`);
+    const androidConfigFileName = androidPaths.find(path => path.indexOf('config') == 0);
+    androidVersion = androidConfigFileName.split('.')[1];
+    const iosPaths = fs.readdirSync(`dist/ios/${projectName}`);
+    const iosConfigFileName = iosPaths.find(path => path.indexOf('config') == 0);
+    iosVersion = iosConfigFileName.split('.')[1];
+  } else {
+    if(type=="android"){
+      const androidPaths = fs.readdirSync(`dist/android/${projectName}`);
+      const androidConfigFileName = androidPaths.find(path => path.indexOf('config') == 0);
+      androidVersion = androidConfigFileName.split('.')[1];
+    }else{
+      const iosPaths = fs.readdirSync(`dist/ios/${projectName}`);
+      const iosConfigFileName = iosPaths.find(path => path.indexOf('config') == 0);
+      iosVersion = iosConfigFileName.split('.')[1];
+    }
+  }
+  
   const config = {
     "ios": {
       "sceneName": projectName,
@@ -342,32 +355,38 @@ module.exports = {
   },
 
   buildAndroid: async function () {
+
+    // 构建前检查
+    const projectName = build_check();
     // 改设置为bundle
     changeSettingsToBundle();
   
     await removeDir('dist/android');
     await buildAndroidBundle();
     await copyDir('build_android/jsb-link/remote', 'dist/android');
-    console.log('构建 android bundle 成功!');
-
+    
     // 改设置为非bundle
     changeSettingToWebDesktop();
-
+    createConfigFile(projectName, "android");
     await removeDir('build_android');
+    console.log('构建 android bundle 成功!');
   },
 
   buildIos: async function () {
+    // 构建前检查
+    const projectName = build_check();
     // 改设置为bundle
     changeSettingsToBundle();
   
     await removeDir('dist/ios');
     await buildIosBundle();
     await copyDir('build_ios/jsb-link/remote', 'dist/ios');
-    console.log('构建 ios bundle 成功!');
 
     // 改设置为非bundle
     changeSettingToWebDesktop();
+    createConfigFile(projectName, "ios");
     await removeDir('build_ios');
+    console.log('构建 ios bundle 成功!');
   }
 
 };
-- 
2.21.0