commit f2fa697c68098718b0c17713a31c77fb1acaea09 Author: ssdfasd <2156608475@qq.com> Date: Wed Mar 18 14:09:06 2026 +0800 Initial commit: add project files and README diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b01a18a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +.vite/ +*.log +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..3cc4505 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# XCSDD - API 文档查看器 + +基于 React + TypeScript + Vite 构建的 API 文档查看和管理系统。 + +## 技术栈 + +- **前端框架**: React 18 + TypeScript +- **构建工具**: Vite +- **样式**: Tailwind CSS +- **图标**: Lucide React + +## 功能特性 + +- 文档树形导航 +- API 文档查看 +- 响应式布局 +- 美观的 UI 设计 + +## 快速开始 + +### 安装依赖 + +```bash +npm install +``` + +### 开发模式 + +```bash +npm run dev +``` + +### 构建生产版本 + +```bash +npm run build +``` + +### 预览构建结果 + +```bash +npm run preview +``` + +## 项目结构 + +``` +├── src/ +│ ├── components/ # React 组件 +│ ├── docs/ # 文档文件 +│ ├── lib/ # 工具函数和类型定义 +│ ├── config.ts # 配置文件 +│ ├── App.tsx # 主应用组件 +│ └── main.tsx # 入口文件 +├── dist/ # 构建输出 +├── index.html # HTML 入口 +└── vite.config.ts # Vite 配置 +``` + +## License + +MIT diff --git a/index.html b/index.html new file mode 100644 index 0000000..9102730 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + +
+ + +Select a document from the sidebar
+{doc.metadata.namespace}
+ {doc.metadata.package}
+ {doc.metadata.inherits}
+ {doc.metadata.description}
+ )} + + {doc.sections.map((section, idx) => ( + + ))} + + {doc.references.length > 0 && ( +{renderText()}
+} + +const TableContent = ({ table }: { table: DocTable }) => { + if (!table.headers.length || !table.rows.length) return null + + return ( +| + {header} + | + ))} +
|---|
| + {cell} + | + ))} +
+
+ {code.code}
+
+
+ )
+}
diff --git a/src/components/DocTree.tsx b/src/components/DocTree.tsx
new file mode 100644
index 0000000..9507936
--- /dev/null
+++ b/src/components/DocTree.tsx
@@ -0,0 +1,97 @@
+import React, { useState } from 'react'
+import { ChevronRight, ChevronDown, Folder, FileText } from 'lucide-react'
+import { clsx } from 'clsx'
+import type { DocFile } from '@/lib/types'
+import { getDisplayName } from '@/lib/parser'
+
+interface DocTreeProps {
+ files: DocFile[]
+ selectedPath?: string
+ onSelect: (file: DocFile) => void
+}
+
+interface DocTreeNodeProps {
+ file: DocFile
+ level: number
+ selectedPath?: string
+ onSelect: (file: DocFile) => void
+}
+
+const DocTreeNode = React.memo(({ file, level, selectedPath, onSelect }: DocTreeNodeProps) => {
+ const [expanded, setExpanded] = useState(level === 0)
+
+ const isSelected = selectedPath === file.relativePath
+ const isDir = file.isDir
+
+ const handleClick = (e: React.MouseEvent) => {
+ e.stopPropagation()
+ if (isDir) {
+ setExpanded(!expanded)
+ } else {
+ onSelect(file)
+ }
+ }
+
+ return (
+