This commit is contained in:
六如
2024-12-03 22:58:44 +08:00
parent 77b52508bb
commit c407261bd7
7 changed files with 86 additions and 4 deletions

View File

@@ -11,6 +11,8 @@ export const apiModules = ref([]);
export const dataNodeType = ref("Object");
export const requestParamsExample = ref({});
export const responseParamsExample = ref({});
export const defaultExpandedKeys = ref([]);
export const currentNodeKey = ref(0);
export const docAppId = ref(0);
export const docAppList = ref([]);
@@ -234,6 +236,16 @@ function loadDocTree(id) {
};
docApi.listDocTree(params).then(resp => {
docTree.value = resp.data;
// 默认展开并选中第一个
if (docTree.value?.length > 0) {
defaultExpandedKeys.value.push(docTree.value[0].docId);
const children = docTree.value[0]?.children;
if (children && children.length > 0) {
const firstNode = children[0];
currentNodeKey.value = firstNode.docId;
handleNodeClick(firstNode);
}
}
});
}

View File

@@ -15,7 +15,9 @@ import {
showUrl,
showProdUrl,
showSandBoxUrl,
showDoc
showDoc,
defaultExpandedKeys,
currentNodeKey
} from "./index";
import { ApiParamTable } from "@/components/ApiParamTable";
import { useRouter } from "vue-router";
@@ -45,6 +47,9 @@ const defaultProps = {
<el-tree
:data="docTree"
:props="defaultProps"
node-key="docId"
:default-expanded-keys="defaultExpandedKeys"
:current-node-key="currentNodeKey"
style="margin-top: 10px"
highlight-current
@node-click="handleNodeClick"