Browse Source

request报错处理

lmc 4 years ago
parent
commit
04de3ac957
4 changed files with 52 additions and 34 deletions
  1. 2 2
      src/components/content/Layout.vue
  2. 29 10
      src/views/Dashboard.vue
  3. 20 22
      src/views/DevStudentPage.vue
  4. 1 0
      vue.config.js

+ 2 - 2
src/components/content/Layout.vue

@@ -55,8 +55,8 @@
         <!--                </el-menu-item>-->
       </el-menu>
       <div class="logout-fix">
-        <div class="logout-name">{{ getUsername() }}</div>
-        <div class="logout" @click="logout()">退出</div>
+        <!-- <div class="logout-name">{{ getUsername() }}</div> -->
+        <!-- <div class="logout" @click="logout()">退出</div> -->
       </div>
     </el-aside>
 

+ 29 - 10
src/views/Dashboard.vue

@@ -27,7 +27,16 @@
         </el-card>
       </div>
     </div>
-    <el-pagination style="text-align:center;" background layout="prev, pager, next" :current-page="page" :total="studentList.length" :page-size="8" @current-change="pageChange"> </el-pagination>
+    <el-pagination
+      style="text-align: center"
+      background
+      layout="prev, pager, next"
+      :current-page="page"
+      :total="studentList.length"
+      :page-size="8"
+      @current-change="pageChange"
+    >
+    </el-pagination>
   </div>
 </template>
 
@@ -36,24 +45,34 @@ import { getAllUsers } from "@/network/dashboard/index.js";
 export default {
   data() {
     return {
-      page:1,
+      page: 1,
       studentList: [],
-      pageList:[]
+      pageList: [],
     };
   },
   created() {
     this.getAllUsers();
   },
   methods: {
-    pageChange(currentPage){
-        this.page = currentPage;
-         this.pageList = this.studentList.slice((this.page-1) * 8, this.page * 8)
+    pageChange(currentPage) {
+      this.page = currentPage;
+      this.pageList = this.studentList.slice(
+        (this.page - 1) * 8,
+        this.page * 8
+      );
     },
     async getAllUsers() {
-      let res = await getAllUsers();
-      if (res.success) {
-        this.studentList = res.content;
-          this.pageList = this.studentList.slice((this.page-1) * 8, this.page * 8)
+      try {
+        let res = await getAllUsers();
+        if (res.success) {
+          this.studentList = res.content;
+          this.pageList = this.studentList.slice(
+            (this.page - 1) * 8,
+            this.page * 8
+          );
+        }
+      } catch (e) {
+        this.$message.error(e.message);
       }
     },
   },

+ 20 - 22
src/views/DevStudentPage.vue

@@ -163,17 +163,11 @@ export default {
       testAnalysis: [],
       visible3: false,
       deployAnalysis: [],
-      pipeline: {
-      },
-      user: {
-      },
-      test: {
-      },
-      commitMessage: {
-        
-      },
-      productList: [
-      ],
+      pipeline: {},
+      user: {},
+      test: {},
+      commitMessage: {},
+      productList: [],
     };
   },
   created() {
@@ -184,17 +178,21 @@ export default {
   },
   methods: {
     async getData() {
-      let res = await getStudentAnalysis({
-        params: {
-          user_id: this.$route.params.id,
-        },
-      });
-      if (res.success) {
-        this.user = res.content;
-        this.productList = res.content.projects
-        this.commitMessage = res.content.commit
-        this.test = res.content.test
-        this.pipeline = res.content.pipeline
+      try {
+        let res = await getStudentAnalysis({
+          params: {
+            user_id: this.$route.params.id,
+          },
+        });
+        if (res.success) {
+          this.user = res.content;
+          this.productList = res.content.projects;
+          this.commitMessage = res.content.commit;
+          this.test = res.content.test;
+          this.pipeline = res.content.pipeline;
+        }
+      } catch (e) {
+        this.$message.error(e.message);
       }
     },
     getAnaylysis() {

+ 1 - 0
vue.config.js

@@ -8,6 +8,7 @@ module.exports = {
         '/api': {
           target: 'http://smart-server.seec.seecoder.cn',
           changeOrigin: true,
+          ws:true,
           pathRewrite:{
             '^/api': ''
           }