Browse Source

添加发布版本和日期

Michael Wang 6 năm trước cách đây
mục cha
commit
3eb61b6732
4 tập tin đã thay đổi với 26 bổ sung0 xóa
  1. 1 0
      .env.production
  2. 1 0
      package.json
  3. 20 0
      prebuild.js
  4. 4 0
      public/index.html

+ 1 - 0
.env.production

@@ -1,2 +1,3 @@
 VUE_APP_TK_SERVER_URL=http://ecs.qmth.com.cn
 VUE_APP_WK_SERVER_SOCKET=wss://ecs.qmth.com.cn:8878/oewebsocket/
+VUE_APP_GIT_REPO_VERSION=TO_BE_OVERRIDED

+ 1 - 0
package.json

@@ -8,6 +8,7 @@
     "start": "vue-cli-service serve",
     "mock": "json-server --watch mock/db.json",
     "build:staging": "NODE_ENV=production vue-cli-service build --mode staging",
+    "prebuild:prod": "node prebuild",
     "build:prod": "vue-cli-service build",
     "test:unit": "vue-cli-service test:unit"
   },

+ 20 - 0
prebuild.js

@@ -0,0 +1,20 @@
+console.log("> prebuild");
+console.log("> prebuild create .env.production.local");
+
+console.log("  构建日期为 " + revision);
+const buildDate = require("moment")().format("YYYY-MM-DD HH:mm:SS");
+
+const revision = require("child_process")
+  .execSync("git rev-parse HEAD")
+  .toString()
+  .trim()
+  .slice(0, 7);
+const fs = require("fs");
+console.log("  当前的git版本为 " + revision);
+
+fs.writeFileSync(
+  ".env.production.local",
+  "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
+);
+
+console.log();

+ 4 - 0
public/index.html

@@ -58,6 +58,10 @@
     </script>
 
     <div id="app"></div>
+
+    <div style="position: absolute; right: 20px; bottom: 20px;">
+      版本: <%= VUE_APP_GIT_REPO_VERSION %>
+    </div>
     <!-- built files will be auto injected -->
 
     <!-- baidu tongji -->