浏览代码

环境检测功能更新

Michael Wang 5 年之前
父节点
当前提交
71d3522058
共有 5 个文件被更改,包括 95 次插入28 次删除
  1. 3 3
      jest.config.js
  2. 1 0
      serviceWorkerAppend.js
  3. 88 22
      src/features/OnlineExam/CheckComputer.vue
  4. 2 2
      tests/unit/.eslintrc.js
  5. 1 1
      tests/unit/example.spec.js

+ 3 - 3
jest.config.js

@@ -4,7 +4,7 @@ module.exports = {
     "^.+\\.vue$": "vue-jest",
     ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
       "jest-transform-stub",
-    "^.+\\.jsx?$": "babel-jest"
+    "^.+\\.jsx?$": "babel-jest",
   },
   transformIgnorePatterns: ["/node_modules/"],
   moduleNameMapper: {
@@ -17,6 +17,6 @@ module.exports = {
   testURL: "http://localhost/",
   watchPlugins: [
     "jest-watch-typeahead/filename",
-    "jest-watch-typeahead/testname"
-  ]
+    "jest-watch-typeahead/testname",
+  ],
 };

+ 1 - 0
serviceWorkerAppend.js

@@ -62,6 +62,7 @@ if (!stop) {
           // Step 3: read the data
           let receivedLength = 0; // received that many bytes at the moment
           let chunks = []; // array of received binary chunks (comprises the body)
+          // eslint-disable-next-line
           while (true) {
             const { done, value } = await reader.read();
 

+ 88 - 22
src/features/OnlineExam/CheckComputer.vue

@@ -127,7 +127,7 @@
 
     <div v-show="current === 2" class="section">
       <div>
-        <div style="display: flex; justify-content: center;">
+        <div style="display: flex;">
           <video
             id="video"
             ref="video"
@@ -136,15 +136,27 @@
             autoplay
           ></video>
 
-          <!-- <div style="margin-left: 50px; margin-top: 100px;">
-            <Button type="warning" @click="camera = '没有摄像头'">
-              摄像头没有启用
+          <div style="margin-left: 50px; margin-top: 100px;">
+            <Button
+              type="warning"
+              @click="
+                camera.resolved = true;
+                camera.status = false;
+              "
+            >
+              图像中不是电脑操作者本人
             </Button>
             <div style="width: 30px; height: 30px;"></div>
-            <Button type="primary" @click="camera = 'OK'">
-              摄像头正常工作
+            <Button
+              type="primary"
+              @click="
+                camera.resolved = true;
+                camera.status = true;
+              "
+            >
+              图像中是电脑操作者本人&nbsp;&nbsp;&nbsp;&nbsp;
             </Button>
-          </div> -->
+          </div>
         </div>
       </div>
 
@@ -159,17 +171,29 @@
 
             <tr>
               <td>摄像头正常启用</td>
-              <td>{{ camera ? "正常" : "请检查摄像头" }}</td>
               <td>
-                <div v-if="camera">
-                  <Icon class="pass-check" type="md-checkmark" />
+                <div v-if="camera.resolved">
+                  {{ camera.status ? "正常" : "请检查摄像头" }}
                 </div>
                 <div v-else>
-                  <Icon
-                    class="fail-cross"
-                    title="请检查摄像头"
-                    type="md-close"
-                  />
+                  <PulseLoader />
+                </div>
+              </td>
+              <td>
+                <div v-if="camera.resolved">
+                  <div v-if="camera.status">
+                    <Icon class="pass-check" type="md-checkmark" />
+                  </div>
+                  <div v-else>
+                    <Icon
+                      class="fail-cross"
+                      title="请检查摄像头"
+                      type="md-close"
+                    />
+                  </div>
+                </div>
+                <div v-else>
+                  <PulseLoader />
                 </div>
               </td>
             </tr>
@@ -457,11 +481,16 @@
             <tr>
               <td>摄像头</td>
               <td>
-                <div v-if="step3Status">
-                  <Icon class="pass-check" type="md-checkmark" />
+                <div v-if="step3StatusResolved">
+                  <div v-if="step3Status">
+                    <Icon class="pass-check" type="md-checkmark" />
+                  </div>
+                  <div v-else>
+                    <Icon class="fail-cross" type="md-close" />
+                  </div>
                 </div>
-                <div v-else>
-                  <Icon class="fail-cross" type="md-close" />
+                <div v-else class="fail-cross">
+                  请在“摄像头”步骤进行人工确认!
                 </div>
               </td>
             </tr>
@@ -500,6 +529,37 @@
           </tbody>
         </table>
       </div>
+
+      <div style="color: red;">
+        <div v-if="!step1Status">
+          检查网络是否连接,路由器是否正常工作。
+        </div>
+        <div v-if="step2StatusResolved && !step2Status">
+          请调整电脑时间和社区与北京时间一致。
+        </div>
+        <div v-if="step3StatusResolved && !step3Status">
+          请确认摄像头连接线正常,能正常工作,关闭杀毒软件、关闭摄像头滤镜软件;请确认您的电脑是否为双摄摄像头,启用的摄像头是否正确。
+        </div>
+        <div v-if="step4StatusResolved && !step4Status">
+          请确认音箱连接正常,调整音量开关及大小。
+        </div>
+        <div v-if="step5StatusResolved && !step5Status">
+          请确认微信已登录并连接网络。
+        </div>
+
+        <div
+          v-if="
+            !step1Status ||
+              (step2StatusResolved && !step2Status) ||
+              (step3StatusResolved && !step3Status) ||
+              (step4StatusResolved && !step4Status) ||
+              (step5StatusResolved && !step5Status)
+          "
+        >
+          请按提示检查并调试,调试后可再次进行环境检测,如仍有问题可致电
+          400-8585-755
+        </div>
+      </div>
     </div>
 
     <div style="margin-top: 30px; text-align: center;">
@@ -561,7 +621,10 @@ export default {
         clockRateStateResolved: false,
         clockRateStatus: false,
       },
-      camera: false,
+      camera: {
+        status: false,
+        resolved: false,
+      },
       sound: {
         downloadResolved: false,
         downloadStatus: false,
@@ -660,7 +723,7 @@ export default {
             video.srcObject = stream;
             try {
               await video.play();
-              this.camera = true;
+              // this.camera = true;
             } catch (error) {
               console.log("摄像头没有正常启用", error);
               this.$Message.error({
@@ -731,8 +794,11 @@ export default {
     step2Status() {
       return this.time.timeZoneStatus && this.time.clockRateStatus;
     },
+    step3StatusResolved() {
+      return this.camera.cameraResolved;
+    },
     step3Status() {
-      return this.camera;
+      return this.camera.status;
     },
     step4StatusResolved() {
       return this.sound.downloadResolved && this.sound.playedStatusResolved;

+ 2 - 2
tests/unit/.eslintrc.js

@@ -1,5 +1,5 @@
 module.exports = {
   env: {
-    jest: true
-  }
+    jest: true,
+  },
 };

+ 1 - 1
tests/unit/example.spec.js

@@ -5,7 +5,7 @@ describe("HelloWorld.vue", () => {
   it("renders props.msg when passed", () => {
     const msg = "new message";
     const wrapper = shallowMount(HelloWorld, {
-      propsData: { msg }
+      propsData: { msg },
     });
     expect(wrapper.text()).toMatch(msg);
   });