Переглянути джерело

优化食物列表响应速度

wangyang 4 роки тому
батько
коміт
9746b3d689
2 змінених файлів з 9 додано та 4 видалено
  1. 1 1
      src/utils/request.js
  2. 8 3
      src/views/food/index.vue

+ 1 - 1
src/utils/request.js

@@ -8,7 +8,7 @@ import { getToken } from '@/utils/auth'
 const service = axios.create({
   baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
   // withCredentials: true, // send cookies when cross-domain requests
-  timeout: 5000 // request timeout
+  timeout: 60000 // request timeout
 })
 
 // request interceptor

+ 8 - 3
src/views/food/index.vue

@@ -9,7 +9,7 @@
           class="filter-item"
           @keyup.enter.native="fetchData()"
         />
-        <el-select v-model="selectType" v-if="isUsda" clearable style="width: 160px;margin-left: 10px;" class="filter-item">
+        <el-select v-model="selectType" v-if="isUsda" style="width: 160px;margin-left: 10px;" class="filter-item">
           <el-option v-for="item in usdaTypes" :key="item.value" :label="item.label" :value="item.value" />
         </el-select>
         <el-select v-model="selectType" v-if="foodSourceIsAll" clearable style="width: 160px;margin-left: 10px;" class="filter-item">
@@ -244,7 +244,7 @@ export default {
       foodQRParams: {},
       isUsda: false,
       foodSourceIsAll: false,
-      usdaTypes: [{ 'label': '全部', 'value': 'ALL' }, { 'label': 'Foundation', 'value': 'USDA_FOUNDATION' },
+      usdaTypes: [{ 'label': 'Foundation', 'value': 'USDA_FOUNDATION' },
                   { 'label': 'SR Legacy', 'value': 'USDA_SR_LEGACY' }, { 'label': 'Branded', 'value': 'USDA_BRANDED' },
                   { 'label': 'FNDDS', 'value': 'USDA_FNDDS' }],
       allTypes: [{ 'label': '全部', 'value': 'ALL' }, { 'label': '录入', 'value': 'ENTRY' },
@@ -262,7 +262,12 @@ export default {
       this.listQuery.orderBy = 1
     }
     this.isUsda = isUsda(this.foodSource)
-    this.foodSourceIsAll = this.foodSource === ''
+    if (this.isUsda) {
+      this.foodSource = this.foodSource === 'USDA' ? 'USDA_SR_LEGACY' : this.foodSource
+      this.selectType = this.foodSource
+    } else {
+      this.foodSourceIsAll = this.foodSource === ''
+    }
     this.fetchData()
   },
   methods: {