bugfix: 解决重新生成SQL后,调用树的数据没有刷新的问题

pull/27/head
watchingfun 2 years ago
parent 3f0fb620fc
commit 6fb9b4951e

@ -57,12 +57,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from "vue"; import { ref, watch } from "vue";
const props = defineProps<{ tree?: InvokeTree }>(); const props = withDefaults(defineProps<{ tree?: InvokeTree }>(), {
tree: () => [],
const tree = ref(props.tree); });
if (!tree.value) {
tree.value = [];
}
const expandedKeys = ref<string[]>([]); const expandedKeys = ref<string[]>([]);
const searchValue = ref<string>(""); const searchValue = ref<string>("");
@ -104,16 +101,16 @@ const generateList = (data: InvokeTreeNode[], preKey: string) => {
} }
} }
}; };
generateList(tree.value, ""); generateList(props.tree, "");
watch(searchValue, (value) => { watch(searchValue, (value) => {
if (!tree?.value) { if (!props.tree.length) {
return; return;
} }
expandedKeys.value = dataList expandedKeys.value = dataList
.map((item: InvokeTreeNode) => { .map((item: InvokeTreeNode) => {
if (item.title.indexOf(value) > -1) { if (item.title.indexOf(value) > -1) {
return getParentKey(item.key, tree.value as InvokeTree); return getParentKey(item.key, props.tree as InvokeTree);
} }
return null; return null;
}) })

Loading…
Cancel
Save