Michael Wang 6 роки тому
батько
коміт
424a9ec4c3
5 змінених файлів з 45 додано та 25 видалено
  1. 1 1
      .browserslistrc
  2. 5 4
      .env.39
  3. 4 3
      .env.production
  4. 22 14
      src/main.js
  5. 13 3
      src/views/index.vue

+ 1 - 1
.browserslistrc

@@ -1 +1 @@
-chrome >= 61
+chrome >= 66

+ 5 - 4
.env.39

@@ -1,10 +1,11 @@
 NODE_ENV=production
 VUE_APP_ECS_CORE=https://ecs-dev.qmth.com.cn:8878
 VUE_APP_ENV=192.168.10.39(测试服务器)
-VUE_APP_FACEPP_API_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE 
-VUE_APP_FACEPP_API_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J
+VUE_APP_FACEPP_API_URL=https://api-cn.faceplusplus.com
+VUE_APP_FACEPP_API_KEY=VOlRKNlCSAYIOcSLDKOaZukkqpmi-Pwo
+VUE_APP_FACEPP_API_SECRET=bzMjy-JfwtVUxVDMzagFh7ggbQBC71f1
 VUE_APP_UPYUN_OPERATOR=examcloud
 VUE_APP_UPYUN_PASSWORD=examcloud123456
-VUE_APP_UPYUN_SERVER=v0.api.upyun.com
+VUE_APP_UPYUN_SERVER=https://v0.api.upyun.com
 VUE_APP_UPYUN_BUCKET=exam-cloud-test
-VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test/student_base_photo/
+VUE_APP_UPYUN_BUCKETURL=http://v0.api.upyun.com/exam-cloud-test/student_base_photo/

+ 4 - 3
.env.production

@@ -1,10 +1,11 @@
 NODE_ENV=production
-VUE_APP_ECS_CORE=https://ecs.qmth.com.cn:8878 
+VUE_APP_ECS_CORE=https://ecs.qmth.com.cn:8878
 VUE_APP_ENV=ecs.qmth.com.cn(线上服务器)
-VUE_APP_FACEPP_API_KEY=VOlRKNlCSAYIOcSLDKOaZukkqpmi-Pwo 
+VUE_APP_FACEPP_API_URL=https://api-cn.faceplusplus.com
+VUE_APP_FACEPP_API_KEY=VOlRKNlCSAYIOcSLDKOaZukkqpmi-Pwo
 VUE_APP_FACEPP_API_SECRET=bzMjy-JfwtVUxVDMzagFh7ggbQBC71f1
 VUE_APP_UPYUN_OPERATOR=examcloud
 VUE_APP_UPYUN_PASSWORD=examcloud123456
 VUE_APP_UPYUN_SERVER=v0.api.upyun.com
 VUE_APP_UPYUN_BUCKET=exam-cloud
-VUE_APP_UPYUN_BUCKETURL=/exam-cloud/student_base_photo/
+VUE_APP_UPYUN_BUCKETURL=http://v0.api.upyun.com/exam-cloud/student_base_photo/

+ 22 - 14
src/main.js

@@ -14,6 +14,7 @@ Vue.use(ElementUI);
 
 const qmInstance = axios.create({});
 let wk_token;
+let wk_key;
 // 正在处理的请求数
 window.requestInProcessingTotal = 0;
 // 并发的总错误数
@@ -23,19 +24,24 @@ window.faceppConcurrencyErrorNumPerMinute = 0;
 let faceppConCurrencyErrorArray = [];
 qmInstance.interceptors.request.use(
   config => {
-    if (config.url.includes("/login") === false) {
-      if (!wk_token) {
-        wk_token = window.localStorage.getItem("token");
-      }
-      if (wk_token && config.headers.common["token"] == null) {
-        config.headers.common["key"] = window.localStorage.getItem("key");
-        config.headers.common["token"] = wk_token;
+    if (config.url.startsWith("/")) {
+      if (config.url.includes("/login") === false) {
+        if (!wk_token) {
+          wk_token = window.localStorage.getItem("token");
+          wk_key = window.localStorage.getItem("key");
+        }
+        if (wk_token && config.headers.common["token"] == null) {
+          config.headers.common["key"] = wk_key;
+          config.headers.common["token"] = wk_token;
+        }
+      } else {
+        wk_token = null;
       }
-    } else {
-      wk_token = null;
     }
 
-    window.requestInProcessingTotal++;
+    if (config.url.startsWith("https://api-cn.faceplusplus.com")) {
+      window.requestInProcessingTotal++;
+    }
 
     return config;
   },
@@ -62,7 +68,9 @@ function calcErrorPerMinute(now) {
 //响应拦截
 qmInstance.interceptors.response.use(
   response => {
-    window.requestInProcessingTotal--;
+    if (response.config.url.startsWith("https://api-cn.faceplusplus.com")) {
+      window.requestInProcessingTotal--;
+    }
 
     // 相当于timer的作用
     const now = Date.now();
@@ -70,7 +78,9 @@ qmInstance.interceptors.response.use(
     return response;
   },
   error => {
-    window.requestInProcessingTotal--;
+    if (error.config.url.startsWith("https://api-cn.faceplusplus.com")) {
+      window.requestInProcessingTotal--;
+    }
     // 这里是返回状态码不为200时候的错误处理
     const status = error.response.status;
     if (status != 200) {
@@ -142,13 +152,11 @@ axiosRetry(qmInstance, {
       `below error status code: ${err.response.status} and retry ...`
     );
     console.log(err);
-    console.log();
     return true;
   }
 });
 
 Vue.prototype.$http = qmInstance;
-
 new Vue({
   router,
   render: h => h(App)

+ 13 - 3
src/views/index.vue

@@ -92,11 +92,15 @@ function readImageFiles(folderPath) {
       .forEach(fileName =>
         fs.renameSync(
           folderPath + "/" + fileName,
-          folderPath + "/" + fileName.toUpperCase()
+          folderPath +
+            "/" +
+            path.parse(fileName).name.toUpperCase() +
+            path.extname(fileName)
         )
       );
   } catch (e) {
     alert("将身份证号转为大写出错。");
+    throw "将身份证号转为大写出错。";
   }
   const files = fs.readdirSync(folderPath);
   return files
@@ -359,7 +363,10 @@ export default {
       formData_addface.append("face_tokens", face_token);
       return new Promise((resolve, reject) => {
         this.$http
-          .post("/facepp/v3/faceset/addface", formData_addface)
+          .post(
+            process.env.VUE_APP_FACEPP_API_URL + "/facepp/v3/faceset/addface",
+            formData_addface
+          )
           .then(res => {
             // console.log(
             //   `res.data.face_added: ${
@@ -399,7 +406,10 @@ export default {
       formData_face_token.append("image_file", fileBlob);
       return new Promise((resolve, reject) => {
         this.$http
-          .post("/facepp/v3/detect", formData_face_token)
+          .post(
+            process.env.VUE_APP_FACEPP_API_URL + "/facepp/v3/detect",
+            formData_face_token
+          )
           .then(res => {
             if (res.data.faces.length >= 1) {
               resolve(res.data.faces[0].face_token);