Browse Source

feat: 增加数据容错处理

lanjianrong 4 năm trước cách đây
mục cha
commit
7b868f7f11

+ 0 - 21
LICENSE

@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020-present, Vben
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.

+ 3 - 3
src/views/design-directive/catalog/index.vue

@@ -88,7 +88,7 @@
   }
   export default defineComponent({
     name: 'Catalog',
-    components: { BasicTree, Icon, BasicUpload, Tree },
+    components: { Icon, BasicUpload, Tree },
     setup() {
       const treeData = ref<TreeResultModel[]>([])
       const row = ref<ATreeRow>({
@@ -107,7 +107,7 @@
       const detail = ref({ name: '', content: '', filepath: '', filename: '', ext: '', fid: '' })
       async function initData() {
         const result = await sectionAllApi()
-        treeData.value = result.children
+        treeData.value = result.children || []
       }
 
       async function initSectionDetail(id: string) {
@@ -129,7 +129,7 @@
       const replaceFields = { children: 'children', title: 'name', key: 'id' }
 
       const onSelect = (selectedKeys: Event, { selectedNodes }) => {
-        if (selectedKeys!.length) {
+        if (selectedKeys && selectedNodes && selectedKeys!.length) {
           const {
             id,
             parentId,

+ 3 - 14
src/views/design-directive/management/index.vue

@@ -12,7 +12,7 @@
     </header>
     <section class="p-3">
       <ATable
-        v-if="treeData.length"
+        v-if="treeData && treeData.length"
         :data-source="treeData"
         :columns="columns"
         size="small"
@@ -88,18 +88,7 @@
   </div>
 </template>
 <script lang="ts">
-  import {
-    computed,
-    defineComponent,
-    onMounted,
-    onUnmounted,
-    reactive,
-    ref,
-    toRaw,
-    toRefs,
-    unref,
-    UnwrapRef
-  } from 'vue'
+  import { computed, defineComponent, reactive, ref, toRaw, toRefs, unref, UnwrapRef } from 'vue'
   import { useDesign } from '/@/hooks/web/useDesign'
   import { Table, Modal, Form, Input, TreeSelect, Popconfirm, message } from 'ant-design-vue'
   import { CheckOutlined, EditOutlined, CloseOutlined } from '@ant-design/icons-vue'
@@ -220,7 +209,7 @@
       }
       async function initData() {
         const result = await sectionAllApi()
-        treeData.value = result.children
+        treeData.value = result.children || []
       }
       initData()
 

+ 3 - 3
src/views/sys/preview/index.vue

@@ -7,7 +7,7 @@
     <div class="flex py-5 container w-full">
       <div class="w-1/4 border-gray-300 border-1 border overflow-y-scroll overflow-x-hidden">
         <Tree
-          v-if="treeData.length"
+          v-if="treeData && treeData.length"
           :tree-data="treeData"
           :replace-fields="replaceFields"
           :show-line="true"
@@ -61,13 +61,13 @@
       const detail = ref({ name: '', content: '', filepath: '', filename: '', ext: '', fid: '' })
       async function initData() {
         const result = await sectionAllApi()
-        treeData.value = result.children
+        treeData.value = result.children || []
       }
 
       initData()
 
       const onSelect = (selectedKeys: Event, { selectedNodes }) => {
-        if (selectedKeys!.length) {
+        if (selectedKeys && selectedNodes && selectedKeys!.length) {
           const {
             id,
             parentId,