diff --git a/components.d.ts b/components.d.ts index c6352220..e1d825a2 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,29 +7,39 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { + ABadge: typeof import('ant-design-vue/es')['Badge'] AButton: typeof import('ant-design-vue/es')['Button'] + ACard: typeof import('ant-design-vue/es')['Card'] ACheckbox: typeof import('ant-design-vue/es')['Checkbox'] - ACheckboxGroup: typeof import('ant-design-vue/es')['CheckboxGroup'] ACol: typeof import('ant-design-vue/es')['Col'] - ACollapse: typeof import('ant-design-vue/es')['Collapse'] - ACollapsePanel: typeof import('ant-design-vue/es')['CollapsePanel'] + ADatePicker: typeof import('ant-design-vue/es')['DatePicker'] + ADivider: typeof import('ant-design-vue/es')['Divider'] + AEmpty: typeof import('ant-design-vue/es')['Empty'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] AInput: typeof import('ant-design-vue/es')['Input'] AInputNumber: typeof import('ant-design-vue/es')['InputNumber'] + AInputPassword: typeof import('ant-design-vue/es')['InputPassword'] AModal: typeof import('ant-design-vue/es')['Modal'] + APagination: typeof import('ant-design-vue/es')['Pagination'] + APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'] ARow: typeof import('ant-design-vue/es')['Row'] ASelect: typeof import('ant-design-vue/es')['Select'] - ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASpin: typeof import('ant-design-vue/es')['Spin'] + ATable: typeof import('ant-design-vue/es')['Table'] ATooltip: typeof import('ant-design-vue/es')['Tooltip'] + ATree: typeof import('ant-design-vue/es')['Tree'] AUpload: typeof import('ant-design-vue/es')['Upload'] BadgeStatus: typeof import('./src/components/BadgeStatus/index.vue')['default'] CardBox: typeof import('./src/components/CardBox/index.vue')['default'] + FormFormBuilder: typeof import('./src/components/Form/FormBuilder.vue')['default'] GeoComponent: typeof import('./src/components/GeoComponent/index.vue')['default'] MonacoEditor: typeof import('./src/components/MonacoEditor/index.vue')['default'] + PermissionButton: typeof import('./src/components/PermissionButton/index.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + Table: typeof import('./src/components/Table/index.vue')['default'] + TitleComponent: typeof import('./src/components/TitleComponent/index.vue')['default'] ValueItem: typeof import('./src/components/ValueItem/index.vue')['default'] } } diff --git a/src/views/system/apiPage/components/LeftTree.vue b/src/views/system/apiPage/components/LeftTree.vue index acdd1f5a..91f414d4 100644 --- a/src/views/system/apiPage/components/LeftTree.vue +++ b/src/views/system/apiPage/components/LeftTree.vue @@ -15,51 +15,62 @@ import { TreeProps } from 'ant-design-vue'; import { getTreeOne_api, getTreeTwo_api } from '@/api/system/apiPage'; +import { treeNodeTpye } from '../index'; -type treeNodeTpye = { - name: string; - url: string; - children?: treeNodeTpye[]; -}; const emits = defineEmits(['select']); -const treeData: TreeProps['treeData'] = ref([]); +const treeData = ref([]); const getTreeData = () => { let tree: treeNodeTpye[] = []; - getTreeOne_api().then((resp) => { - tree = resp.urls.map((item) => ({ + getTreeOne_api().then((resp: any) => { + tree = resp.urls.map((item: any) => ({ ...item, key: item.url, })); const allPromise = tree.map((item) => getTreeTwo_api(item.name)); Promise.all(allPromise).then((values) => { - values.forEach((item, i) => { - tree[i].children = combData(item.paths); + values.forEach((item: any, i) => { + tree[i].children = combData(item?.paths); }); - console.log(tree); - treeData.value = tree + treeData.value = tree; }); }); }; -const clickSelectItem = (key, { node }) => { - emits('select', node); +const clickSelectItem: TreeProps['onSelect'] = (key, node: any) => { + emits('select', node.node.dataRef); }; onMounted(() => { getTreeData(); }); -const combData = (dataSource: object): object[] => { - const apiList: object[] = []; +const combData = (dataSource: object) => { + const apiList: treeNodeTpye[] = []; const keys = Object.keys(dataSource); keys.forEach((key) => { const method = Object.keys(dataSource[key] || {})[0]; const name = dataSource[key][method].tags[0]; - let apiObj = apiList.find((item) => item.name === name); - if (!apiObj) { - apiObj = { name, link: key, methods: dataSource[key], key }; + let apiObj: treeNodeTpye | undefined = apiList.find( + (item) => item.name === name, + ); + if (apiObj) { + apiObj.apiList?.push({ + url: key, + method: dataSource[key], + }); + } else { + apiObj = { + name, + key: name, + apiList: [ + { + url: key, + method: dataSource[key], + }, + ], + }; apiList.push(apiObj); } }); @@ -68,4 +79,14 @@ const combData = (dataSource: object): object[] => { }; - + diff --git a/src/views/system/apiPage/index.d.ts b/src/views/system/apiPage/index.d.ts new file mode 100644 index 00000000..e0155dde --- /dev/null +++ b/src/views/system/apiPage/index.d.ts @@ -0,0 +1,14 @@ +export type treeNodeTpye = { + name: string; + key: string; + link?: string; + apiList?: object[]; + children?: treeNodeTpye[]; +}; +export type methodType = { + [key:string]: object +} +export type apiObjType = { + url: string, + method: methodType +} \ No newline at end of file diff --git a/src/views/system/apiPage/index.vue b/src/views/system/apiPage/index.vue index 92339a94..6cc516ba 100644 --- a/src/views/system/apiPage/index.vue +++ b/src/views/system/apiPage/index.vue @@ -1,15 +1,37 @@ \ No newline at end of file +