From 4ebe67388559f333f3c6ec96fffbdd004c086b2c Mon Sep 17 00:00:00 2001 From: iqudoo Date: Mon, 25 May 2026 11:42:34 +0800 Subject: [PATCH] fff --- src/App.vue | 1304 +++++++++++++++++++++++---------------------------- 1 file changed, 584 insertions(+), 720 deletions(-) diff --git a/src/App.vue b/src/App.vue index 02ba0ae..1486908 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,21 +1,14 @@ - +

导出接口文档为 Markdown 格式,支持导出全部或按需选择 @@ -811,12 +655,7 @@

一键导出所有接口文档

- + {{ downloading ? "下载中..." : "下载全部接口文档" }}
@@ -828,12 +667,7 @@

选择需要导出的接口,生成自定义文档

- +
全选 取消全选 @@ -843,33 +677,24 @@
- +
- + {{ downloading ? "导出中..." : "导出所选文档" }}
@@ -1151,7 +976,7 @@ onMounted(async () => { if (id) { const apiToShow = findApiById(id); if (apiToShow) { - showApiDetail(apiToShow); + goToApi(apiToShow); } } } @@ -1182,7 +1007,7 @@ onMounted(async () => { if (id) { const apiToShow = findApiById(id); if (apiToShow) { - showApiDetail(apiToShow); + goToApi(apiToShow); } } } catch (error) { @@ -1226,8 +1051,46 @@ const goHome = () => { updateUrlParameter(null); }; +// 在侧边栏树中查找 API 所在的目录路径 +const findApiMenuPath = (api) => { + if (!api) return { pathKeys: [], pathNames: [] }; + + const search = (nodes, pathKeys, pathNames) => { + for (const node of nodes) { + if (node.apis?.some((item) => item.uniqueId === api.uniqueId)) { + if (node.isUngrouped) { + return { pathKeys: [], pathNames: [] }; + } + return { + pathKeys: [...pathKeys, node.key], + pathNames: [...pathNames, node.displayName], + }; + } + if (node.children?.length) { + const result = search( + node.children, + [...pathKeys, node.key], + [...pathNames, node.displayName] + ); + if (result) return result; + } + } + return null; + }; + + return search(apiTree.value, [], []) || { pathKeys: [], pathNames: [] }; +}; + +// 将左侧菜单导航到 API 所在目录 +const navigateToApiInMenu = (api) => { + const { pathKeys, pathNames } = findApiMenuPath(api); + currentPathKeys.value = pathKeys; + currentPath.value = pathNames; +}; + // 路由到指定API const goToApi = (api) => { + navigateToApiInMenu(api); showApiDetail(api); updateUrlParameter(api.uniqueId); }; @@ -1293,10 +1156,9 @@ const generateCurlExample = (api) => { -d '{ "action": "${api.action}", "token": "YOUR_TOKEN", - "params": {${ - Object.entries(requiredParams) - .map(([key, value]) => '\n "' + key + '": ' + JSON.stringify(value)) - .join(",") || "" + "params": {${Object.entries(requiredParams) + .map(([key, value]) => '\n "' + key + '": ' + JSON.stringify(value)) + .join(",") || "" } } }'`; @@ -1316,11 +1178,10 @@ const generateJsExample = (api) => { axios.post('API_URL', { action: '${api.action}', token: 'YOUR_TOKEN', - params: {${ - Object.entries(requiredParams) + params: {${Object.entries(requiredParams) .map(([key, value]) => "\n " + key + ": " + JSON.stringify(value)) .join(",") || "" - } + } } }) .then(response => { @@ -2181,9 +2042,9 @@ const copyApiMarkdown = async () => { const exportTreeData = computed(() => { const apiList = exportSearchQuery.value ? apis.value.filter((api) => { - if (!api.action) return false; - return api.action.toLowerCase().includes(exportSearchQuery.value.toLowerCase()); - }) + if (!api.action) return false; + return api.action.toLowerCase().includes(exportSearchQuery.value.toLowerCase()); + }) : apis.value; return buildExportTree(apiList); }); @@ -3089,6 +2950,7 @@ const handleExportSelected = async () => { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); @@ -3159,6 +3021,7 @@ h4 { } @media (max-width: 768px) { + .content-nav-wrap, .content-page { padding-left: 16px; @@ -3596,6 +3459,7 @@ h4 { :deep(.el-table__inner-wrapper:before) { background-color: transparent; } + :deep(.el-collapse-item__wrap) { border-bottom: none; }