Ver Fonte

更新加载失败处理

fxs há 9 meses atrás
pai
commit
90f0456262

+ 6 - 2
src/components/dataAnalysis/StatisticText.vue

@@ -2,7 +2,7 @@
  * @Author: fxs bjnsfxs@163.com
  * @Date: 2024-08-26 13:57:37
  * @LastEditors: fxs bjnsfxs@163.com
- * @LastEditTime: 2024-08-30 11:40:29
+ * @LastEditTime: 2024-08-30 12:02:19
  * @FilePath: \Game-Backstage-Management-System\src\components\dataAnalysis\StatisticText.vue
  * @Description: 用于展示统计数据,如总览页面上方的总览数据
  * 
@@ -35,13 +35,16 @@ const getData = () => {
             value: data[item.name]
           })
         })
+
         dataState.value = true
       })
       .catch(() => {
         dataState.value = false
       })
   } else {
-    if (dataList.length) {
+    let hasNull = props.fieldsInfo.every((item) => item.value !== '')
+
+    if (hasNull) {
       dataList.splice(0, dataList.length) // 清空一下
       props.fieldsInfo.map((item) => {
         dataList.push({
@@ -50,6 +53,7 @@ const getData = () => {
           value: item.value
         })
       })
+
       dataState.value = true
     } else {
       dataState.value = false

+ 4 - 2
src/components/dataAnalysis/TemporalTrend.vue

@@ -24,6 +24,7 @@ const iconSize = ref(20) // 图标的尺寸
 const tableDataList = reactive<Array<any>>([])
 
 const loading = ref<Boolean>(true) // 是否在加载
+const dataState = ref<Boolean>(false) //数据是否加载成功
 
 // 配置表格分页数据
 const paginationConfig = reactive<TablePaginationSetting>({
@@ -138,7 +139,7 @@ const getData = async (type: number) => {
     .post(props.requestConfig.url, { ...props.requestConfig.otherOptions, type })
     .then((info) => {
       let data = info.data
-
+      dataState.value = true
       // 生成表格字段
       createTableField()
       // 生成表格数据
@@ -159,6 +160,7 @@ const getData = async (type: number) => {
       }
     })
     .catch((err) => {
+      dataState.value = false
       console.log(err)
     })
     .finally(() => {
@@ -227,7 +229,7 @@ onMounted(() => {
         <div class="chartContent" v-if="selectShape === 1">
           <div class="yesterDayDataBox">
             <StatisticText
-              v-if="staticFields"
+              v-if="staticFields && dataState"
               :fields-info="staticFields"
               :value-class="'chartStaticValue'"
             ></StatisticText>

+ 3 - 3
src/hooks/useRequest.ts

@@ -2,7 +2,7 @@
  * @Author: fxs bjnsfxs@163.com
  * @Date: 2024-08-20 17:24:06
  * @LastEditors: fxs bjnsfxs@163.com
- * @LastEditTime: 2024-08-30 11:35:44
+ * @LastEditTime: 2024-08-30 12:01:31
  * @FilePath: \Game-Backstage-Management-System\src\hooks\useRequest.ts
  * @Description:
  *
@@ -16,8 +16,8 @@ import type { AxiosResponse } from 'axios'
 import type { ResponseInfo } from '@/types/res'
 
 export function useRequest() {
-  const baseIp = 'http://server.ichunhao.cn' // 线上
-  // const baseIp = 'http://192.168.1.139:8000' // 本地
+  // const baseIp = 'http://server.ichunhao.cn' // 线上
+  const baseIp = 'http://192.168.1.139:8000' // 本地
 
   const AllApi = {
     mock: `http://127.0.0.1:8003/mock`,

+ 2 - 2
src/router/home.ts

@@ -2,7 +2,7 @@
  * @Author: fxs bjnsfxs@163.com
  * @Date: 2024-08-20 14:24:58
  * @LastEditors: fxs bjnsfxs@163.com
- * @LastEditTime: 2024-08-27 17:18:07
+ * @LastEditTime: 2024-08-30 11:58:59
  * @FilePath: \Game-Backstage-Management-System\src\router\home.ts
  * @Description:
  *
@@ -37,7 +37,7 @@ export default [
         name: 'PlayerManageView',
         component: PlayerManageView,
         meta: {
-          needKeepAlive: false
+          needKeepAlive: true
         }
       },
       {

+ 17 - 1
src/views/Home/HomeView.vue

@@ -153,8 +153,24 @@ getAllGameInfo().then((data) => {
         </el-popover>
       </div>
     </div>
-    <div class="content">
+    <!-- <div class="content">
       <RouterView v-if="gameinfoLoad" />
+    </div> -->
+    <div class="content">
+      <router-view v-slot="{ Component, route }">
+        <keep-alive>
+          <component
+            :is="Component"
+            :key="route.path"
+            v-if="route.meta.needKeepAlive == true"
+          ></component>
+        </keep-alive>
+        <component
+          :is="Component"
+          :key="route.path"
+          v-if="route.meta.needKeepAlive == false"
+        ></component>
+      </router-view>
     </div>
   </div>
 </template>

+ 0 - 1
src/views/Home/InfoManage/GameManageView.vue

@@ -194,7 +194,6 @@ const gameFormData = reactive<GameDialogFormData>({
 
 // 进入用户页面
 const enterUserPage = (row: any) => {
-  console.log(row)
   tableStore.updateQueryInfo(row.gid, 'web')
   router.push('/home/playerManageView')
 }